@vitest-agent/sdk 7.0.5 → 7.1.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/index.d.ts +108 -5
- package/index.js +2 -2
- package/package.json +1 -1
- package/schemas/Config.js +72 -5
- package/schemas/Options.js +31 -3
- package/version.js +1 -1
package/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PubSub, Schema } from "effect";
|
|
1
|
+
import { Option, PubSub, Schema } from "effect";
|
|
2
2
|
/**
|
|
3
3
|
* Aggregate coverage percentages across four istanbul metrics.
|
|
4
4
|
* @public
|
|
@@ -1517,6 +1517,21 @@ export interface ResolvedReporterConfig {
|
|
|
1517
1517
|
* @internal
|
|
1518
1518
|
*/
|
|
1519
1519
|
readonly coverageMode: "full" | "ui-only";
|
|
1520
|
+
/**
|
|
1521
|
+
* Whether this run is recorded in the SQLite `data.db` (issue #625).
|
|
1522
|
+
* `false` when the user passed `AgentPlugin({ persist: false })` or
|
|
1523
|
+
* the `VITEST_AGENT_PERSIST` operator override turned persistence
|
|
1524
|
+
* off: the run still renders, but classifications are empty and
|
|
1525
|
+
* coverage carries no baseline delta or trend, because there is no
|
|
1526
|
+
* history to read. Independent of `coverageMode` — a UI-only run
|
|
1527
|
+
* (`coverage.enabled: false`) skips persistence too, with this field
|
|
1528
|
+
* still reporting what the user asked for.
|
|
1529
|
+
*
|
|
1530
|
+
* The plugin always populates it; it is optional only because a
|
|
1531
|
+
* consumer constructing `ResolvedReporterConfig` by hand may omit it,
|
|
1532
|
+
* in which case treat it as `true`.
|
|
1533
|
+
*/
|
|
1534
|
+
readonly persist?: boolean;
|
|
1520
1535
|
readonly detail: DetailLevel;
|
|
1521
1536
|
readonly noColor: boolean;
|
|
1522
1537
|
readonly runCommand?: string;
|
|
@@ -2395,16 +2410,46 @@ export type ChannelEvent = typeof ChannelEvent.Type;
|
|
|
2395
2410
|
export declare const BehaviorScopedEventTypes: readonly ["behavior_started", "phase_transition", "behavior_completed", "behavior_abandoned", "blocked"];
|
|
2396
2411
|
/** @public */
|
|
2397
2412
|
export type BehaviorScopedEventType = (typeof BehaviorScopedEventTypes)[number];
|
|
2413
|
+
declare const RetentionConfig_base: Schema.Class<RetentionConfig, Schema.Struct<{
|
|
2414
|
+
readonly enabled: Schema.optionalKey<Schema.Boolean>;
|
|
2415
|
+
readonly keepRuns: Schema.optionalKey<Schema.Int>;
|
|
2416
|
+
readonly maxAgeDays: Schema.optionalKey<Schema.Int>;
|
|
2417
|
+
}>, {}>;
|
|
2418
|
+
/**
|
|
2419
|
+
* The optional `[retention]` table of `vitest-agent.config.toml`: how many
|
|
2420
|
+
* `test_runs` rows (and their cascaded modules, cases, errors, coverage
|
|
2421
|
+
* rows) the per-project `data.db` keeps.
|
|
2422
|
+
*
|
|
2423
|
+
* Every field is optional. An absent table means the default policy
|
|
2424
|
+
* (`RunRetentionPolicy.DEFAULT_KEEP_RUNS` newest runs per project, no age
|
|
2425
|
+
* limit); `enabled = false` turns run pruning off entirely.
|
|
2426
|
+
*
|
|
2427
|
+
* Fields:
|
|
2428
|
+
* - `enabled` — `false` disables run retention. Defaults to `true`.
|
|
2429
|
+
* - `keepRuns` — the newest N runs per project to keep. A positive integer;
|
|
2430
|
+
* defaults to `RunRetentionPolicy.DEFAULT_KEEP_RUNS`.
|
|
2431
|
+
* - `maxAgeDays` — additionally drop any run older than this many days,
|
|
2432
|
+
* even inside the newest N. A positive integer; no age limit by default.
|
|
2433
|
+
*
|
|
2434
|
+
* @remarks
|
|
2435
|
+
* `keepRuns = 0` is rejected rather than read as "keep nothing": the run
|
|
2436
|
+
* being written is always kept, and `enabled = false` is the explicit
|
|
2437
|
+
* off switch, so a zero would have two readings.
|
|
2438
|
+
* @public
|
|
2439
|
+
*/
|
|
2440
|
+
export declare class RetentionConfig extends RetentionConfig_base {}
|
|
2398
2441
|
declare const VitestAgentConfig_base: Schema.Class<VitestAgentConfig, Schema.Struct<{
|
|
2399
2442
|
readonly cacheDir: Schema.optional<Schema.String>;
|
|
2400
2443
|
readonly projectKey: Schema.optional<Schema.String>;
|
|
2444
|
+
readonly retention: Schema.optionalKey<typeof RetentionConfig>;
|
|
2401
2445
|
}>, {}>;
|
|
2402
2446
|
/**
|
|
2403
2447
|
* Schema for the optional `vitest-agent.config.toml` file.
|
|
2404
2448
|
*
|
|
2405
|
-
*
|
|
2449
|
+
* Every field is optional. When the file is absent or these fields are
|
|
2406
2450
|
* unset, `resolveDataPath` falls back to deriving the path from the
|
|
2407
|
-
* workspace's `package.json` `name` under the XDG data directory
|
|
2451
|
+
* workspace's `package.json` `name` under the XDG data directory, and run
|
|
2452
|
+
* retention uses the default policy.
|
|
2408
2453
|
*
|
|
2409
2454
|
* Fields:
|
|
2410
2455
|
* - `cacheDir` — absolute path overriding the entire data directory. Highest
|
|
@@ -2415,9 +2460,39 @@ declare const VitestAgentConfig_base: Schema.Class<VitestAgentConfig, Schema.Str
|
|
|
2415
2460
|
* directory. Use this when two unrelated projects on the same machine
|
|
2416
2461
|
* share a `package.json` `name` (the collision case for workspace-name
|
|
2417
2462
|
* keying), or when you want a stable key independent of `name` changes.
|
|
2463
|
+
* - `retention` — the `[retention]` table; see `RetentionConfig`.
|
|
2418
2464
|
* @public
|
|
2419
2465
|
*/
|
|
2420
2466
|
export declare class VitestAgentConfig extends VitestAgentConfig_base {}
|
|
2467
|
+
declare const RunRetentionPolicy_base: Schema.Class<RunRetentionPolicy, Schema.Struct<{
|
|
2468
|
+
readonly keepRuns: Schema.Int;
|
|
2469
|
+
readonly maxAgeDays: Schema.optionalKey<Schema.Int>;
|
|
2470
|
+
}>, {}>;
|
|
2471
|
+
/**
|
|
2472
|
+
* The resolved run-retention policy a `data.db` prune applies: keep the
|
|
2473
|
+
* newest `keepRuns` runs of every project, and drop any run older than
|
|
2474
|
+
* `maxAgeDays` days when set. The run being persisted is never pruned.
|
|
2475
|
+
*
|
|
2476
|
+
* @remarks
|
|
2477
|
+
* The default of 200 runs per project is sized against what reads the
|
|
2478
|
+
* data: failure classification reads the newest 10 `test_history` rows per
|
|
2479
|
+
* test and coverage trends keep 50 entries, so 200 leaves both a wide
|
|
2480
|
+
* margin while bounding a 7k-test suite (about 3 MB per run) to a few
|
|
2481
|
+
* hundred megabytes instead of growing without bound (issue 623, where an
|
|
2482
|
+
* unpruned database reached 880 MB over 4,484 runs). `maxAgeDays` is the
|
|
2483
|
+
* lever for a project that runs rarely but wants a calendar bound.
|
|
2484
|
+
* @public
|
|
2485
|
+
*/
|
|
2486
|
+
export declare class RunRetentionPolicy extends RunRetentionPolicy_base {
|
|
2487
|
+
/** Newest runs per project kept when the config names no `keepRuns`. */
|
|
2488
|
+
static readonly DEFAULT_KEEP_RUNS = 200;
|
|
2489
|
+
/**
|
|
2490
|
+
* Resolve the policy a loaded config asks for: `Option.none()` when
|
|
2491
|
+
* `retention.enabled` is `false`, otherwise the configured values over
|
|
2492
|
+
* the defaults.
|
|
2493
|
+
*/
|
|
2494
|
+
static fromConfig(config: VitestAgentConfig): Option.Option<RunRetentionPolicy>;
|
|
2495
|
+
}
|
|
2421
2496
|
/**
|
|
2422
2497
|
* Per-file stray-console-output detail. Counts are of console writes
|
|
2423
2498
|
* (one `console.*` call), not lines.
|
|
@@ -2676,10 +2751,10 @@ export type ReportOption = typeof ReportOption.Type;
|
|
|
2676
2751
|
/**
|
|
2677
2752
|
* The 2.0 user-facing options for `AgentPlugin`.
|
|
2678
2753
|
*
|
|
2679
|
-
*
|
|
2754
|
+
* Seven fields total. Two are function-typed (`reporter`, `onRunEvent`)
|
|
2680
2755
|
* and live on the `AgentPluginConstructorOptions` companion interface in
|
|
2681
2756
|
* `@vitest-agent/plugin` — Effect Schema cannot encode functions cleanly,
|
|
2682
|
-
* so the schema-decodable struct carries the
|
|
2757
|
+
* so the schema-decodable struct carries the five data-shaped fields.
|
|
2683
2758
|
* @public
|
|
2684
2759
|
*/
|
|
2685
2760
|
export declare const AgentPluginOptions: Schema.Struct<{
|
|
@@ -2707,6 +2782,34 @@ export declare const AgentPluginOptions: Schema.Struct<{
|
|
|
2707
2782
|
readonly report: Schema.optional<Schema.Union<readonly [Schema.Literal<false>, Schema.Struct<{
|
|
2708
2783
|
readonly scope: Schema.optional<Schema.String>;
|
|
2709
2784
|
}>]>>;
|
|
2785
|
+
/**
|
|
2786
|
+
* Whether a run is recorded in the SQLite `data.db` (default `true`).
|
|
2787
|
+
*
|
|
2788
|
+
* `false` is the explicit opt-out for a runner where nothing reads the
|
|
2789
|
+
* database back — a throwaway CI job, say. The run still renders every
|
|
2790
|
+
* console and report-file output, still emits every `RunEvent`, and
|
|
2791
|
+
* Vitest still enforces `coverage.thresholds` through its own
|
|
2792
|
+
* mechanism; only the database writes are skipped: run rows, test
|
|
2793
|
+
* cases, failure history, coverage rows and trends, and the baselines
|
|
2794
|
+
* they feed. Consequences a renderer sees: failure classifications are
|
|
2795
|
+
* empty (there is no history to classify against, so no test is
|
|
2796
|
+
* labelled `stable`, `new-failure`, `persistent`, `flaky` or
|
|
2797
|
+
* `recovered`), and coverage renders without a baseline delta or a
|
|
2798
|
+
* trend line. The `data.db` file is never created or opened.
|
|
2799
|
+
*
|
|
2800
|
+
* The opt-out is never automatic: `CI=true` does not imply it, because
|
|
2801
|
+
* some CI setups cache `data.db` between jobs and query it. The
|
|
2802
|
+
* `VITEST_AGENT_PERSIST` environment variable (`0` / `false` / `off`
|
|
2803
|
+
* to disable, `1` / `true` / `on` to enable) is the operator spelling
|
|
2804
|
+
* for a runner whose config cannot be edited, and it wins over this
|
|
2805
|
+
* option in either direction; any other value is ignored with one
|
|
2806
|
+
* stderr line.
|
|
2807
|
+
*
|
|
2808
|
+
* `coverage.enabled: false` in Vitest's own config already skips
|
|
2809
|
+
* persistence (UI-only mode, Decision 38) — this option is for a run
|
|
2810
|
+
* that keeps coverage on and still wants no database.
|
|
2811
|
+
*/
|
|
2812
|
+
readonly persist: Schema.optional<Schema.Boolean>;
|
|
2710
2813
|
}>;
|
|
2711
2814
|
/** @public */
|
|
2712
2815
|
export type AgentPluginOptions = typeof AgentPluginOptions.Type;
|
package/index.js
CHANGED
|
@@ -16,7 +16,7 @@ import { AgentReport, ModuleReport, ReportSummary, TagCountEntry, TestReport } f
|
|
|
16
16
|
import { CoverageBaselines } from "./schemas/Baselines.js";
|
|
17
17
|
import { CacheManifest, CacheManifestEntry } from "./schemas/CacheManifest.js";
|
|
18
18
|
import { BehaviorAbandonedEvent, BehaviorAddedEvent, BehaviorCompletedEvent, BehaviorScopedEventTypes, BehaviorStartedEvent, BehaviorsReadyEvent, BlockedEvent, ChannelEvent, GoalAbandonedEvent, GoalAddedEvent, GoalCompletedEvent, GoalStartedEvent, GoalsReadyEvent, PhaseTransitionEvent, SessionCompleteEvent, SessionOutcome } from "./schemas/ChannelEvent.js";
|
|
19
|
-
import { VitestAgentConfig } from "./schemas/Config.js";
|
|
19
|
+
import { RetentionConfig, RunRetentionPolicy, VitestAgentConfig } from "./schemas/Config.js";
|
|
20
20
|
import { CoverageLevel, resolveCoverageInput, validateCoverageConfig } from "./schemas/CoverageLevel.js";
|
|
21
21
|
import { CoverageTargets, CoverageTargetsMetrics } from "./schemas/CoverageTargets.js";
|
|
22
22
|
import { HistoryRecord, TestHistory, TestRun } from "./schemas/History.js";
|
|
@@ -64,4 +64,4 @@ import { validateCoverageTargetsShape } from "./utils/validate-coverage-targets-
|
|
|
64
64
|
import { requiredArtifactForTransition, transitionEnforcesBehaviorMatch, validatePhaseTransition } from "./utils/validate-phase-transition.js";
|
|
65
65
|
import { CURRENT_SDK_VERSION } from "./version.js";
|
|
66
66
|
|
|
67
|
-
export { ActionSeverity, ActorType, Agent, AgentConsoleMode, AgentId, AgentNotFoundError, AgentPluginOptions, AgentReport, AgentReporterOptions, BATS_FILE_GLOB_SUFFIX, BehaviorAbandonedEvent, BehaviorAddedEvent, BehaviorCompletedEvent, BehaviorDetail, BehaviorNotFoundError, BehaviorRow, BehaviorScopedEventTypes, BehaviorStartedEvent, BehaviorStatus, BehaviorsReadyEvent, BlockedEvent, CURRENT_SDK_VERSION, CacheManifest, CacheManifestEntry, ChannelEvent, ChatId, CiConsoleMode, ConsoleLeakFile, ConsoleLeaks, ConsoleLeaksFromFailingTests, ConsoleLogLevel, ConsoleMode, ConsoleOutputMode, ConsoleOutputs, ConversationId, ConversationNotFoundError, CoverageBaselines, FileCoverageReport as CoverageFile, CoverageGap, CoverageLevel, CoverageMetric, CoverageRenderState, CoverageReport, CoverageTargets, CoverageTargetsMetrics, CoverageTotals, DataStoreError, DetailLevel, DiscoveryError, Environment, Executor, FailureRecord, FileCoverageReport, FileEditPayload, GitCommandError, GlobShortfall, GoalAbandonedEvent, GoalAddedEvent, GoalCompletedEvent, GoalDetail, GoalNotFoundError, GoalRow, GoalStartedEvent, GoalStatus, GoalsReadyEvent, HistoryRecord, HookFirePayload, HookStatus, HookType, HostKind, HostMetadataParseError, HumanConsoleMode, HypothesisPayload, IdempotencyHit, IllegalStatusTransitionError, MetricThresholds, ModuleRecord, ModuleReport, NON_DISCOVERABLE_DIRS, NotePayload, PackageManager, PathResolutionError, PatternMetricThresholds, PatternThresholds, PerFileThresholds, PhaseTransitionEvent, ProbeMissError, ProjectIdentityNotResolvableError, ProjectKey, RUN_REPORT_FILE_SCHEMA_URL, RegistrationConflictError, RenderState, RenderTotals, ReportError, ReportOption, ReportSettings, ReportSummary, ResolvedThresholds, RunEvent, RunReportFile, SRC_DIR, STRAY_OUTPUT_SOURCE, SessionCompleteEvent, SessionNotFoundError, SessionOutcome, SidecarTimeoutError, StrayOutput, StrayOutputSample, SuggestedActionRecord, TEST_DIR, TEST_FILE_GLOB_SUFFIX, TEST_HELPER_DIRS, TagCountEntry, TddTaskAlreadyEndedError, TddTaskId, TddTaskNotFoundError, TestAnnotation, TestArtifact, TestArtifactLocation, TestAttachment, TestClassification, TestHistory, TestRecord, TestReport, TestRun, TestRunReason, TestState, ToolCallPayload, ToolResultPayload, Transport, TrendEntry, TrendRecord, TurnPayload, UserPromptPayload, VitestAgentConfig, ansi, basenamePosix, buildAgentReport, buildConsoleLeaks, buildEnvPrefix, canonicalizeGitUrl, classifyTest, classifyTestPath, coerceErrorField, coerceErrorText, collectConsoleLeakEntries, compressLines, computeTrend, countSuiteFailures, detectNonDefaultDiscoverStrategy, detectPackageManager, detectVitestScripts, determineTier, extractSqlReason, findFunctionBoundary, findOwningWorkspace, formatConsoleMarkdown, formatFatalError, formatGfm, formatScopedCoverageNote, formatStrayOutputNote, getRecentDirection, getRunCommand, getWorstMetric, gitUrlToProjectKey, hashTargets, initialRenderState, isEscapeOnly, isTestFileName, isTimeoutError, isVitestInvocation, joinPosix, makeStrayOutputRecorder, normalizeWorkspaceKey, osc8, probeHostMetadataFromEnv, readStrayOutput, relativePath, relativePosix, requiredArtifactForTransition, resolveCoverageInput, rewriteBashCommand, safeFilename, stripAnsi, toPosix, transitionEnforcesBehaviorMatch, validateCoverageConfig, validateCoverageTargetsShape, validatePhaseTransition };
|
|
67
|
+
export { ActionSeverity, ActorType, Agent, AgentConsoleMode, AgentId, AgentNotFoundError, AgentPluginOptions, AgentReport, AgentReporterOptions, BATS_FILE_GLOB_SUFFIX, BehaviorAbandonedEvent, BehaviorAddedEvent, BehaviorCompletedEvent, BehaviorDetail, BehaviorNotFoundError, BehaviorRow, BehaviorScopedEventTypes, BehaviorStartedEvent, BehaviorStatus, BehaviorsReadyEvent, BlockedEvent, CURRENT_SDK_VERSION, CacheManifest, CacheManifestEntry, ChannelEvent, ChatId, CiConsoleMode, ConsoleLeakFile, ConsoleLeaks, ConsoleLeaksFromFailingTests, ConsoleLogLevel, ConsoleMode, ConsoleOutputMode, ConsoleOutputs, ConversationId, ConversationNotFoundError, CoverageBaselines, FileCoverageReport as CoverageFile, CoverageGap, CoverageLevel, CoverageMetric, CoverageRenderState, CoverageReport, CoverageTargets, CoverageTargetsMetrics, CoverageTotals, DataStoreError, DetailLevel, DiscoveryError, Environment, Executor, FailureRecord, FileCoverageReport, FileEditPayload, GitCommandError, GlobShortfall, GoalAbandonedEvent, GoalAddedEvent, GoalCompletedEvent, GoalDetail, GoalNotFoundError, GoalRow, GoalStartedEvent, GoalStatus, GoalsReadyEvent, HistoryRecord, HookFirePayload, HookStatus, HookType, HostKind, HostMetadataParseError, HumanConsoleMode, HypothesisPayload, IdempotencyHit, IllegalStatusTransitionError, MetricThresholds, ModuleRecord, ModuleReport, NON_DISCOVERABLE_DIRS, NotePayload, PackageManager, PathResolutionError, PatternMetricThresholds, PatternThresholds, PerFileThresholds, PhaseTransitionEvent, ProbeMissError, ProjectIdentityNotResolvableError, ProjectKey, RUN_REPORT_FILE_SCHEMA_URL, RegistrationConflictError, RenderState, RenderTotals, ReportError, ReportOption, ReportSettings, ReportSummary, ResolvedThresholds, RetentionConfig, RunEvent, RunReportFile, RunRetentionPolicy, SRC_DIR, STRAY_OUTPUT_SOURCE, SessionCompleteEvent, SessionNotFoundError, SessionOutcome, SidecarTimeoutError, StrayOutput, StrayOutputSample, SuggestedActionRecord, TEST_DIR, TEST_FILE_GLOB_SUFFIX, TEST_HELPER_DIRS, TagCountEntry, TddTaskAlreadyEndedError, TddTaskId, TddTaskNotFoundError, TestAnnotation, TestArtifact, TestArtifactLocation, TestAttachment, TestClassification, TestHistory, TestRecord, TestReport, TestRun, TestRunReason, TestState, ToolCallPayload, ToolResultPayload, Transport, TrendEntry, TrendRecord, TurnPayload, UserPromptPayload, VitestAgentConfig, ansi, basenamePosix, buildAgentReport, buildConsoleLeaks, buildEnvPrefix, canonicalizeGitUrl, classifyTest, classifyTestPath, coerceErrorField, coerceErrorText, collectConsoleLeakEntries, compressLines, computeTrend, countSuiteFailures, detectNonDefaultDiscoverStrategy, detectPackageManager, detectVitestScripts, determineTier, extractSqlReason, findFunctionBoundary, findOwningWorkspace, formatConsoleMarkdown, formatFatalError, formatGfm, formatScopedCoverageNote, formatStrayOutputNote, getRecentDirection, getRunCommand, getWorstMetric, gitUrlToProjectKey, hashTargets, initialRenderState, isEscapeOnly, isTestFileName, isTimeoutError, isVitestInvocation, joinPosix, makeStrayOutputRecorder, normalizeWorkspaceKey, osc8, probeHostMetadataFromEnv, readStrayOutput, relativePath, relativePosix, requiredArtifactForTransition, resolveCoverageInput, rewriteBashCommand, safeFilename, stripAnsi, toPosix, transitionEnforcesBehaviorMatch, validateCoverageConfig, validateCoverageTargetsShape, validatePhaseTransition };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitest-agent/sdk",
|
|
3
|
-
"version": "7.0
|
|
3
|
+
"version": "7.1.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Platform-free core for the vitest-agent package family: Effect Schema definitions, reporter and dispatcher contracts, errors, and pure utilities.",
|
|
6
6
|
"keywords": [
|
package/schemas/Config.js
CHANGED
|
@@ -1,12 +1,42 @@
|
|
|
1
|
-
import { Schema } from "effect";
|
|
1
|
+
import { Option, Schema } from "effect";
|
|
2
2
|
|
|
3
3
|
// src/schemas/Config.ts
|
|
4
|
+
/** A whole number of runs or days, at least one. */
|
|
5
|
+
const PositiveInt = Schema.Int.check(Schema.isGreaterThanOrEqualTo(1));
|
|
6
|
+
/**
|
|
7
|
+
* The optional `[retention]` table of `vitest-agent.config.toml`: how many
|
|
8
|
+
* `test_runs` rows (and their cascaded modules, cases, errors, coverage
|
|
9
|
+
* rows) the per-project `data.db` keeps.
|
|
10
|
+
*
|
|
11
|
+
* Every field is optional. An absent table means the default policy
|
|
12
|
+
* (`RunRetentionPolicy.DEFAULT_KEEP_RUNS` newest runs per project, no age
|
|
13
|
+
* limit); `enabled = false` turns run pruning off entirely.
|
|
14
|
+
*
|
|
15
|
+
* Fields:
|
|
16
|
+
* - `enabled` — `false` disables run retention. Defaults to `true`.
|
|
17
|
+
* - `keepRuns` — the newest N runs per project to keep. A positive integer;
|
|
18
|
+
* defaults to `RunRetentionPolicy.DEFAULT_KEEP_RUNS`.
|
|
19
|
+
* - `maxAgeDays` — additionally drop any run older than this many days,
|
|
20
|
+
* even inside the newest N. A positive integer; no age limit by default.
|
|
21
|
+
*
|
|
22
|
+
* @remarks
|
|
23
|
+
* `keepRuns = 0` is rejected rather than read as "keep nothing": the run
|
|
24
|
+
* being written is always kept, and `enabled = false` is the explicit
|
|
25
|
+
* off switch, so a zero would have two readings.
|
|
26
|
+
* @public
|
|
27
|
+
*/
|
|
28
|
+
var RetentionConfig = class extends Schema.Class("RetentionConfig")({
|
|
29
|
+
enabled: Schema.optionalKey(Schema.Boolean),
|
|
30
|
+
keepRuns: Schema.optionalKey(PositiveInt),
|
|
31
|
+
maxAgeDays: Schema.optionalKey(PositiveInt)
|
|
32
|
+
}) {};
|
|
4
33
|
/**
|
|
5
34
|
* Schema for the optional `vitest-agent.config.toml` file.
|
|
6
35
|
*
|
|
7
|
-
*
|
|
36
|
+
* Every field is optional. When the file is absent or these fields are
|
|
8
37
|
* unset, `resolveDataPath` falls back to deriving the path from the
|
|
9
|
-
* workspace's `package.json` `name` under the XDG data directory
|
|
38
|
+
* workspace's `package.json` `name` under the XDG data directory, and run
|
|
39
|
+
* retention uses the default policy.
|
|
10
40
|
*
|
|
11
41
|
* Fields:
|
|
12
42
|
* - `cacheDir` — absolute path overriding the entire data directory. Highest
|
|
@@ -17,11 +47,48 @@ import { Schema } from "effect";
|
|
|
17
47
|
* directory. Use this when two unrelated projects on the same machine
|
|
18
48
|
* share a `package.json` `name` (the collision case for workspace-name
|
|
19
49
|
* keying), or when you want a stable key independent of `name` changes.
|
|
50
|
+
* - `retention` — the `[retention]` table; see `RetentionConfig`.
|
|
20
51
|
* @public
|
|
21
52
|
*/
|
|
22
53
|
var VitestAgentConfig = class extends Schema.Class("VitestAgentConfig")({
|
|
23
54
|
cacheDir: Schema.optional(Schema.String),
|
|
24
|
-
projectKey: Schema.optional(Schema.String)
|
|
55
|
+
projectKey: Schema.optional(Schema.String),
|
|
56
|
+
retention: Schema.optionalKey(RetentionConfig)
|
|
25
57
|
}) {};
|
|
58
|
+
/**
|
|
59
|
+
* The resolved run-retention policy a `data.db` prune applies: keep the
|
|
60
|
+
* newest `keepRuns` runs of every project, and drop any run older than
|
|
61
|
+
* `maxAgeDays` days when set. The run being persisted is never pruned.
|
|
62
|
+
*
|
|
63
|
+
* @remarks
|
|
64
|
+
* The default of 200 runs per project is sized against what reads the
|
|
65
|
+
* data: failure classification reads the newest 10 `test_history` rows per
|
|
66
|
+
* test and coverage trends keep 50 entries, so 200 leaves both a wide
|
|
67
|
+
* margin while bounding a 7k-test suite (about 3 MB per run) to a few
|
|
68
|
+
* hundred megabytes instead of growing without bound (issue 623, where an
|
|
69
|
+
* unpruned database reached 880 MB over 4,484 runs). `maxAgeDays` is the
|
|
70
|
+
* lever for a project that runs rarely but wants a calendar bound.
|
|
71
|
+
* @public
|
|
72
|
+
*/
|
|
73
|
+
var RunRetentionPolicy = class RunRetentionPolicy extends Schema.Class("RunRetentionPolicy")({
|
|
74
|
+
keepRuns: PositiveInt,
|
|
75
|
+
maxAgeDays: Schema.optionalKey(PositiveInt)
|
|
76
|
+
}) {
|
|
77
|
+
/** Newest runs per project kept when the config names no `keepRuns`. */
|
|
78
|
+
static DEFAULT_KEEP_RUNS = 200;
|
|
79
|
+
/**
|
|
80
|
+
* Resolve the policy a loaded config asks for: `Option.none()` when
|
|
81
|
+
* `retention.enabled` is `false`, otherwise the configured values over
|
|
82
|
+
* the defaults.
|
|
83
|
+
*/
|
|
84
|
+
static fromConfig(config) {
|
|
85
|
+
const retention = config.retention;
|
|
86
|
+
if (retention?.enabled === false) return Option.none();
|
|
87
|
+
return Option.some(RunRetentionPolicy.make({
|
|
88
|
+
keepRuns: retention?.keepRuns ?? RunRetentionPolicy.DEFAULT_KEEP_RUNS,
|
|
89
|
+
...retention?.maxAgeDays !== void 0 && { maxAgeDays: retention.maxAgeDays }
|
|
90
|
+
}));
|
|
91
|
+
}
|
|
92
|
+
};
|
|
26
93
|
|
|
27
|
-
export { VitestAgentConfig };
|
|
94
|
+
export { RetentionConfig, RunRetentionPolicy, VitestAgentConfig };
|
package/schemas/Options.js
CHANGED
|
@@ -42,17 +42,45 @@ const ReportOption = Schema.Union([Schema.Literal(false), ReportSettings]).annot
|
|
|
42
42
|
/**
|
|
43
43
|
* The 2.0 user-facing options for `AgentPlugin`.
|
|
44
44
|
*
|
|
45
|
-
*
|
|
45
|
+
* Seven fields total. Two are function-typed (`reporter`, `onRunEvent`)
|
|
46
46
|
* and live on the `AgentPluginConstructorOptions` companion interface in
|
|
47
47
|
* `@vitest-agent/plugin` — Effect Schema cannot encode functions cleanly,
|
|
48
|
-
* so the schema-decodable struct carries the
|
|
48
|
+
* so the schema-decodable struct carries the five data-shaped fields.
|
|
49
49
|
* @public
|
|
50
50
|
*/
|
|
51
51
|
const AgentPluginOptions = Schema.Struct({
|
|
52
52
|
console: Schema.optional(ConsoleOutputs),
|
|
53
53
|
coverageTargets: Schema.optional(CoverageTargets),
|
|
54
54
|
transport: Schema.optional(Transport),
|
|
55
|
-
report: Schema.optional(ReportOption)
|
|
55
|
+
report: Schema.optional(ReportOption),
|
|
56
|
+
/**
|
|
57
|
+
* Whether a run is recorded in the SQLite `data.db` (default `true`).
|
|
58
|
+
*
|
|
59
|
+
* `false` is the explicit opt-out for a runner where nothing reads the
|
|
60
|
+
* database back — a throwaway CI job, say. The run still renders every
|
|
61
|
+
* console and report-file output, still emits every `RunEvent`, and
|
|
62
|
+
* Vitest still enforces `coverage.thresholds` through its own
|
|
63
|
+
* mechanism; only the database writes are skipped: run rows, test
|
|
64
|
+
* cases, failure history, coverage rows and trends, and the baselines
|
|
65
|
+
* they feed. Consequences a renderer sees: failure classifications are
|
|
66
|
+
* empty (there is no history to classify against, so no test is
|
|
67
|
+
* labelled `stable`, `new-failure`, `persistent`, `flaky` or
|
|
68
|
+
* `recovered`), and coverage renders without a baseline delta or a
|
|
69
|
+
* trend line. The `data.db` file is never created or opened.
|
|
70
|
+
*
|
|
71
|
+
* The opt-out is never automatic: `CI=true` does not imply it, because
|
|
72
|
+
* some CI setups cache `data.db` between jobs and query it. The
|
|
73
|
+
* `VITEST_AGENT_PERSIST` environment variable (`0` / `false` / `off`
|
|
74
|
+
* to disable, `1` / `true` / `on` to enable) is the operator spelling
|
|
75
|
+
* for a runner whose config cannot be edited, and it wins over this
|
|
76
|
+
* option in either direction; any other value is ignored with one
|
|
77
|
+
* stderr line.
|
|
78
|
+
*
|
|
79
|
+
* `coverage.enabled: false` in Vitest's own config already skips
|
|
80
|
+
* persistence (UI-only mode, Decision 38) — this option is for a run
|
|
81
|
+
* that keeps coverage on and still wants no database.
|
|
82
|
+
*/
|
|
83
|
+
persist: Schema.optional(Schema.Boolean)
|
|
56
84
|
}).annotate({ identifier: "AgentPluginOptions" });
|
|
57
85
|
/**
|
|
58
86
|
* Reporter-implementation options.
|