@vitest-agent/sdk 8.0.0 → 9.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +140 -317
- package/index.js +5 -10
- package/package.json +1 -1
- package/schemas/5.0/run.json +95 -0
- package/schemas/RunDiagnostics.js +61 -0
- package/schemas/RunReportFile.js +3 -1
- package/tsdoc-metadata.json +1 -1
- package/utils/ansi.js +1 -35
- package/utils/run-diagnostics-actions.js +58 -0
- package/utils/vitest-config-files.js +24 -0
- package/version.js +1 -1
- package/utils/compress-lines.js +0 -44
- package/utils/detect-pm.js +0 -57
- package/utils/format-console.js +0 -222
- package/utils/format-fatal-error.js +0 -46
- package/utils/format-gfm.js +0 -160
- package/utils/normalize-workspace-key.js +0 -33
- package/utils/probe-host-metadata.js +0 -98
- package/utils/safe-filename.js +0 -33
package/index.d.ts
CHANGED
|
@@ -1118,6 +1118,85 @@ export declare const ReportError: Schema.Struct<{
|
|
|
1118
1118
|
}>;
|
|
1119
1119
|
/** @public */
|
|
1120
1120
|
export type ReportError = typeof ReportError.Type;
|
|
1121
|
+
/**
|
|
1122
|
+
* Which Vitest performance diagnostic a hint came from.
|
|
1123
|
+
* @public
|
|
1124
|
+
*/
|
|
1125
|
+
export declare const PerformanceHintKind: Schema.Literals<readonly ["environment", "import", "transform", "isolate"]>;
|
|
1126
|
+
/** @public */
|
|
1127
|
+
export type PerformanceHintKind = typeof PerformanceHintKind.Type;
|
|
1128
|
+
/**
|
|
1129
|
+
* One performance hint derived from Vitest's run diagnostics. `project` is
|
|
1130
|
+
* omitted for a hint that applies to the whole run (for example `isolate`).
|
|
1131
|
+
* @public
|
|
1132
|
+
*/
|
|
1133
|
+
export declare const PerformanceHint: Schema.Struct<{
|
|
1134
|
+
readonly kind: Schema.Literals<readonly ["environment", "import", "transform", "isolate"]>;
|
|
1135
|
+
readonly project: Schema.optionalKey<Schema.String>;
|
|
1136
|
+
readonly message: Schema.String;
|
|
1137
|
+
readonly remedy: Schema.String;
|
|
1138
|
+
readonly detail: Schema.String;
|
|
1139
|
+
readonly learnMoreUrl: Schema.String;
|
|
1140
|
+
readonly estimatedSavingMs: Schema.optionalKey<Schema.Finite>;
|
|
1141
|
+
readonly share: Schema.optionalKey<Schema.Finite>;
|
|
1142
|
+
}>;
|
|
1143
|
+
/** @public */
|
|
1144
|
+
export type PerformanceHint = typeof PerformanceHint.Type;
|
|
1145
|
+
/**
|
|
1146
|
+
* Wall-clock timing of the plugin's post-run work, in milliseconds.
|
|
1147
|
+
* @public
|
|
1148
|
+
*/
|
|
1149
|
+
export declare const PostRunTiming: Schema.Struct<{
|
|
1150
|
+
readonly persistMs: Schema.Finite;
|
|
1151
|
+
readonly coverageScanMs: Schema.Finite;
|
|
1152
|
+
readonly totalMs: Schema.Finite;
|
|
1153
|
+
readonly renderMs: Schema.optionalKey<Schema.Finite>;
|
|
1154
|
+
readonly vitestDurationMs: Schema.optionalKey<Schema.Finite>;
|
|
1155
|
+
}>;
|
|
1156
|
+
/** @public */
|
|
1157
|
+
export type PostRunTiming = typeof PostRunTiming.Type;
|
|
1158
|
+
/**
|
|
1159
|
+
* Whether the run's results were persisted to the database.
|
|
1160
|
+
* @public
|
|
1161
|
+
*/
|
|
1162
|
+
export declare const PersistenceStatus: Schema.Struct<{
|
|
1163
|
+
readonly ok: Schema.Boolean;
|
|
1164
|
+
readonly reason: Schema.optionalKey<Schema.String>;
|
|
1165
|
+
readonly migrationFailed: Schema.optionalKey<Schema.Boolean>;
|
|
1166
|
+
}>;
|
|
1167
|
+
/** @public */
|
|
1168
|
+
export type PersistenceStatus = typeof PersistenceStatus.Type;
|
|
1169
|
+
/**
|
|
1170
|
+
* Run-level diagnostics: performance hints, post-run timing and persistence
|
|
1171
|
+
* status (issue #544).
|
|
1172
|
+
* @public
|
|
1173
|
+
*/
|
|
1174
|
+
export declare const RunDiagnostics: Schema.Struct<{
|
|
1175
|
+
readonly performanceHints: Schema.$Array<Schema.Struct<{
|
|
1176
|
+
readonly kind: Schema.Literals<readonly ["environment", "import", "transform", "isolate"]>;
|
|
1177
|
+
readonly project: Schema.optionalKey<Schema.String>;
|
|
1178
|
+
readonly message: Schema.String;
|
|
1179
|
+
readonly remedy: Schema.String;
|
|
1180
|
+
readonly detail: Schema.String;
|
|
1181
|
+
readonly learnMoreUrl: Schema.String;
|
|
1182
|
+
readonly estimatedSavingMs: Schema.optionalKey<Schema.Finite>;
|
|
1183
|
+
readonly share: Schema.optionalKey<Schema.Finite>;
|
|
1184
|
+
}>>;
|
|
1185
|
+
readonly postRun: Schema.optionalKey<Schema.Struct<{
|
|
1186
|
+
readonly persistMs: Schema.Finite;
|
|
1187
|
+
readonly coverageScanMs: Schema.Finite;
|
|
1188
|
+
readonly totalMs: Schema.Finite;
|
|
1189
|
+
readonly renderMs: Schema.optionalKey<Schema.Finite>;
|
|
1190
|
+
readonly vitestDurationMs: Schema.optionalKey<Schema.Finite>;
|
|
1191
|
+
}>>;
|
|
1192
|
+
readonly persistence: Schema.optionalKey<Schema.Struct<{
|
|
1193
|
+
readonly ok: Schema.Boolean;
|
|
1194
|
+
readonly reason: Schema.optionalKey<Schema.String>;
|
|
1195
|
+
readonly migrationFailed: Schema.optionalKey<Schema.Boolean>;
|
|
1196
|
+
}>>;
|
|
1197
|
+
}>;
|
|
1198
|
+
/** @public */
|
|
1199
|
+
export type RunDiagnostics = typeof RunDiagnostics.Type;
|
|
1121
1200
|
/**
|
|
1122
1201
|
* Coverage metric whose threshold can be violated independently.
|
|
1123
1202
|
* @public
|
|
@@ -1687,6 +1766,8 @@ export interface ReporterRenderInput {
|
|
|
1687
1766
|
* when the plugin has nothing to suggest (issue #544).
|
|
1688
1767
|
*/
|
|
1689
1768
|
readonly suggestedActions?: ReadonlyArray<SuggestedActionRecord>;
|
|
1769
|
+
/** Run-level diagnostics (performance hints, post-run timing, persistence status); absent when none were collected (issue #544). */
|
|
1770
|
+
readonly runDiagnostics?: RunDiagnostics;
|
|
1690
1771
|
readonly trendSummary?: {
|
|
1691
1772
|
readonly direction: "improving" | "regressing" | "stable";
|
|
1692
1773
|
readonly runCount: number;
|
|
@@ -3163,6 +3244,30 @@ export declare const RunReportFile: Schema.Struct<{
|
|
|
3163
3244
|
}>>;
|
|
3164
3245
|
}>>;
|
|
3165
3246
|
}>>;
|
|
3247
|
+
readonly runDiagnostics: Schema.optionalKey<Schema.Struct<{
|
|
3248
|
+
readonly performanceHints: Schema.$Array<Schema.Struct<{
|
|
3249
|
+
readonly kind: Schema.Literals<readonly ["environment", "import", "transform", "isolate"]>;
|
|
3250
|
+
readonly project: Schema.optionalKey<Schema.String>;
|
|
3251
|
+
readonly message: Schema.String;
|
|
3252
|
+
readonly remedy: Schema.String;
|
|
3253
|
+
readonly detail: Schema.String;
|
|
3254
|
+
readonly learnMoreUrl: Schema.String;
|
|
3255
|
+
readonly estimatedSavingMs: Schema.optionalKey<Schema.Finite>;
|
|
3256
|
+
readonly share: Schema.optionalKey<Schema.Finite>;
|
|
3257
|
+
}>>;
|
|
3258
|
+
readonly postRun: Schema.optionalKey<Schema.Struct<{
|
|
3259
|
+
readonly persistMs: Schema.Finite;
|
|
3260
|
+
readonly coverageScanMs: Schema.Finite;
|
|
3261
|
+
readonly totalMs: Schema.Finite;
|
|
3262
|
+
readonly renderMs: Schema.optionalKey<Schema.Finite>;
|
|
3263
|
+
readonly vitestDurationMs: Schema.optionalKey<Schema.Finite>;
|
|
3264
|
+
}>>;
|
|
3265
|
+
readonly persistence: Schema.optionalKey<Schema.Struct<{
|
|
3266
|
+
readonly ok: Schema.Boolean;
|
|
3267
|
+
readonly reason: Schema.optionalKey<Schema.String>;
|
|
3268
|
+
readonly migrationFailed: Schema.optionalKey<Schema.Boolean>;
|
|
3269
|
+
}>>;
|
|
3270
|
+
}>>;
|
|
3166
3271
|
}>;
|
|
3167
3272
|
/** @public */
|
|
3168
3273
|
export type RunReportFile = typeof RunReportFile.Type;
|
|
@@ -3527,34 +3632,6 @@ export declare const TurnPayload: Schema.Union<readonly [Schema.Struct<{
|
|
|
3527
3632
|
}>]>;
|
|
3528
3633
|
/** @public */
|
|
3529
3634
|
export type TurnPayload = typeof TurnPayload.Type;
|
|
3530
|
-
/**
|
|
3531
|
-
* Options for ANSI color output control.
|
|
3532
|
-
*
|
|
3533
|
-
* @internal
|
|
3534
|
-
*/
|
|
3535
|
-
export interface AnsiOptions {
|
|
3536
|
-
noColor?: boolean;
|
|
3537
|
-
}
|
|
3538
|
-
/**
|
|
3539
|
-
* Wrap text with an ANSI color/style escape code.
|
|
3540
|
-
*
|
|
3541
|
-
* No-ops when `options.noColor` is true, keeping output as valid plain
|
|
3542
|
-
* markdown when captured by agents or piped to files.
|
|
3543
|
-
*
|
|
3544
|
-
* @privateRemarks
|
|
3545
|
-
* Uses raw ANSI escape sequences (`\x1b[...m`) rather than a dependency
|
|
3546
|
-
* like `chalk` or `picocolors` to keep the package zero-dependency. The
|
|
3547
|
-
* `noColor` flag respects the `NO_COLOR` environment variable convention.
|
|
3548
|
-
*
|
|
3549
|
-
* @param text - Text to wrap
|
|
3550
|
-
* @param color - ANSI code name: `reset`, `bold`, `dim`, `red`, `green`, `yellow`, `cyan`
|
|
3551
|
-
* @param options - Control color output
|
|
3552
|
-
* @returns Text with ANSI escape codes, or plain text if noColor
|
|
3553
|
-
*
|
|
3554
|
-
* @see {@link https://no-color.org/ | NO_COLOR convention}
|
|
3555
|
-
* @internal
|
|
3556
|
-
*/
|
|
3557
|
-
export declare function ansi(text: string, color: string, options?: AnsiOptions): string;
|
|
3558
3635
|
/**
|
|
3559
3636
|
* Strip all ANSI escape codes from a string.
|
|
3560
3637
|
*
|
|
@@ -3816,33 +3893,6 @@ export declare const coerceErrorText: (value: unknown) => string | undefined;
|
|
|
3816
3893
|
* @public
|
|
3817
3894
|
*/
|
|
3818
3895
|
export declare const coerceErrorField: (source: unknown, key: string) => string | undefined;
|
|
3819
|
-
/**
|
|
3820
|
-
* Compress an array of line numbers into a compact range string.
|
|
3821
|
-
*
|
|
3822
|
-
* Consecutive line numbers are collapsed into `start-end` ranges,
|
|
3823
|
-
* separated by commas. Duplicate values are removed and the input
|
|
3824
|
-
* is sorted ascending before processing.
|
|
3825
|
-
*
|
|
3826
|
-
* @param lines - Array of line numbers to compress
|
|
3827
|
-
* @returns Compressed range string, or empty string for empty input
|
|
3828
|
-
*
|
|
3829
|
-
* @example
|
|
3830
|
-
* ```typescript
|
|
3831
|
-
* import { compressLines } from "@vitest-agent/sdk/utils";
|
|
3832
|
-
*
|
|
3833
|
-
* compressLines([1, 2, 3, 5, 10, 11, 12]);
|
|
3834
|
-
* // Returns: "1-3,5,10-12"
|
|
3835
|
-
*
|
|
3836
|
-
* compressLines([42]);
|
|
3837
|
-
* // Returns: "42"
|
|
3838
|
-
*
|
|
3839
|
-
* compressLines([]);
|
|
3840
|
-
* // Returns: ""
|
|
3841
|
-
* ```
|
|
3842
|
-
*
|
|
3843
|
-
* @public
|
|
3844
|
-
*/
|
|
3845
|
-
export declare function compressLines(lines: number[]): string;
|
|
3846
3896
|
/**
|
|
3847
3897
|
* Hash resolved targets to detect configuration changes.
|
|
3848
3898
|
*
|
|
@@ -3958,66 +4008,6 @@ export declare const formatConsoleLeaksNote: (leaks: ConsoleLeaks) => ReadonlyAr
|
|
|
3958
4008
|
* @public
|
|
3959
4009
|
*/
|
|
3960
4010
|
export declare function detectNonDefaultDiscoverStrategy(source: string): boolean;
|
|
3961
|
-
/**
|
|
3962
|
-
* Filesystem abstraction for package manager detection.
|
|
3963
|
-
*
|
|
3964
|
-
* @remarks
|
|
3965
|
-
* This interface allows dependency injection for testability. In production,
|
|
3966
|
-
* pass an adapter backed by `node:fs/promises`. In tests, provide a mock
|
|
3967
|
-
* implementation.
|
|
3968
|
-
*
|
|
3969
|
-
* @example
|
|
3970
|
-
* ```typescript
|
|
3971
|
-
* import type { FileSystemAdapter } from "@vitest-agent/sdk/detect-pm";
|
|
3972
|
-
* import { readFile, access } from "node:fs/promises";
|
|
3973
|
-
*
|
|
3974
|
-
* const fsAdapter: FileSystemAdapter = {
|
|
3975
|
-
* readFile: (path: string) => readFile(path, "utf-8"),
|
|
3976
|
-
* exists: async (path: string) => {
|
|
3977
|
-
* try {
|
|
3978
|
-
* await access(path);
|
|
3979
|
-
* return true;
|
|
3980
|
-
* } catch {
|
|
3981
|
-
* return false;
|
|
3982
|
-
* }
|
|
3983
|
-
* },
|
|
3984
|
-
* };
|
|
3985
|
-
* ```
|
|
3986
|
-
*
|
|
3987
|
-
* @internal
|
|
3988
|
-
*/
|
|
3989
|
-
export interface FileSystemAdapter {
|
|
3990
|
-
readFile(path: string): Promise<string>;
|
|
3991
|
-
exists(path: string): Promise<boolean>;
|
|
3992
|
-
}
|
|
3993
|
-
/**
|
|
3994
|
-
* Detect the package manager used in a project by inspecting the root directory.
|
|
3995
|
-
*
|
|
3996
|
-
* @remarks
|
|
3997
|
-
* Detection order:
|
|
3998
|
-
* 1. The `packageManager` field in `package.json` (e.g., `"pnpm\@10.32.1"`)
|
|
3999
|
-
* 2. Lockfile presence: `pnpm-lock.yaml`, `package-lock.json`, `yarn.lock`, `bun.lock`
|
|
4000
|
-
*
|
|
4001
|
-
* Returns `null` when no package manager can be determined.
|
|
4002
|
-
*
|
|
4003
|
-
* @param root - Absolute path to the project root directory
|
|
4004
|
-
* @param fs - Filesystem adapter for reading files and checking existence
|
|
4005
|
-
* @returns The detected package manager, or `null`
|
|
4006
|
-
*
|
|
4007
|
-
* @internal
|
|
4008
|
-
*/
|
|
4009
|
-
export declare function detectPackageManager(root: string, fs: FileSystemAdapter): Promise<PackageManager | null>;
|
|
4010
|
-
/**
|
|
4011
|
-
* Return the vitest run command for the given package manager.
|
|
4012
|
-
*
|
|
4013
|
-
* Falls back to `"npx vitest run"` when `pm` is `null`.
|
|
4014
|
-
*
|
|
4015
|
-
* @param pm - Detected package manager, or `null` for unknown
|
|
4016
|
-
* @returns Shell command string for running vitest
|
|
4017
|
-
*
|
|
4018
|
-
* @internal
|
|
4019
|
-
*/
|
|
4020
|
-
export declare function getRunCommand(pm: PackageManager | null): string;
|
|
4021
4011
|
/**
|
|
4022
4012
|
* True when the error looks like a Vitest test or hook timeout. Either
|
|
4023
4013
|
* the message matches "timed out in Nms" or the error name contains
|
|
@@ -4028,132 +4018,6 @@ export declare const isTimeoutError: (error: {
|
|
|
4028
4018
|
message?: string;
|
|
4029
4019
|
name?: string;
|
|
4030
4020
|
}) => boolean;
|
|
4031
|
-
/**
|
|
4032
|
-
* Options controlling console markdown output formatting.
|
|
4033
|
-
*
|
|
4034
|
-
* @internal
|
|
4035
|
-
*/
|
|
4036
|
-
export interface ConsoleFormatOptions {
|
|
4037
|
-
/** Absolute project root; stripped from file paths for display. */
|
|
4038
|
-
cwd: string;
|
|
4039
|
-
/** Output verbosity: `"failures"` (default), `"full"`, or `"silent"`. */
|
|
4040
|
-
consoleOutput: "failures" | "full" | "silent";
|
|
4041
|
-
/** Maximum number of low-coverage files to show in console output. */
|
|
4042
|
-
coverageConsoleLimit: number;
|
|
4043
|
-
/** When `true`, suppress ANSI color codes for valid plain markdown. */
|
|
4044
|
-
noColor: boolean;
|
|
4045
|
-
/** Optional trend summary for tiered coverage output. */
|
|
4046
|
-
trendSummary?: {
|
|
4047
|
-
direction: "improving" | "regressing" | "stable";
|
|
4048
|
-
runCount: number;
|
|
4049
|
-
firstMetric?: {
|
|
4050
|
-
name: string;
|
|
4051
|
-
from: number;
|
|
4052
|
-
to: number;
|
|
4053
|
-
target?: number;
|
|
4054
|
-
};
|
|
4055
|
-
};
|
|
4056
|
-
/** CLI run command prefix for coverage/trends hints (e.g., `"pnpm vitest-agent"`). */
|
|
4057
|
-
runCommand?: string;
|
|
4058
|
-
/** When true, suggest MCP tools instead of CLI commands in Next Steps. */
|
|
4059
|
-
mcp?: boolean;
|
|
4060
|
-
}
|
|
4061
|
-
/**
|
|
4062
|
-
* Return the metric with the lowest percentage from a `FileCoverageReport`.
|
|
4063
|
-
*
|
|
4064
|
-
* @remarks
|
|
4065
|
-
* Used to surface the single worst coverage metric per file in console output,
|
|
4066
|
-
* keeping the display compact. Labels are abbreviated: `"Stmts"`, `"Branch"`,
|
|
4067
|
-
* `"Funcs"`, `"Lines"`.
|
|
4068
|
-
*
|
|
4069
|
-
* @param f - File coverage report to analyze
|
|
4070
|
-
* @returns Object with `label` and `pct` of the worst metric
|
|
4071
|
-
*
|
|
4072
|
-
* @internal
|
|
4073
|
-
*/
|
|
4074
|
-
export declare function getWorstMetric(f: FileCoverageReport): {
|
|
4075
|
-
label: string;
|
|
4076
|
-
pct: number;
|
|
4077
|
-
};
|
|
4078
|
-
/**
|
|
4079
|
-
* Strip the working directory prefix from a file path to produce a
|
|
4080
|
-
* project-relative path for display.
|
|
4081
|
-
*
|
|
4082
|
-
* @param filePath - Absolute or relative file path
|
|
4083
|
-
* @param cwd - Working directory to strip
|
|
4084
|
-
* @returns Project-relative path string
|
|
4085
|
-
*
|
|
4086
|
-
* @internal
|
|
4087
|
-
*/
|
|
4088
|
-
export declare function relativePath(filePath: string, cwd: string): string;
|
|
4089
|
-
/**
|
|
4090
|
-
* Determine the output tier based on test results and coverage state.
|
|
4091
|
-
*
|
|
4092
|
-
* - `"red"` -- failures, unhandled errors, or files below threshold
|
|
4093
|
-
* - `"yellow"` -- all tests pass but coverage targets exist (room to improve)
|
|
4094
|
-
* - `"green"` -- all tests pass, all coverage targets met
|
|
4095
|
-
*
|
|
4096
|
-
* @internal
|
|
4097
|
-
*/
|
|
4098
|
-
export declare function determineTier(report: AgentReport): "green" | "yellow" | "red";
|
|
4099
|
-
/**
|
|
4100
|
-
* Format an {@link (AgentReport:variable)} as compact, actionable console markdown.
|
|
4101
|
-
*
|
|
4102
|
-
* @remarks
|
|
4103
|
-
* The output is structured for LLM agent consumption with four sections:
|
|
4104
|
-
*
|
|
4105
|
-
* 1. **Compact header** with pass/fail counts and duration
|
|
4106
|
-
* 2. **Failed test details** with error messages and diffs (the core value)
|
|
4107
|
-
* 3. **Coverage gaps** showing only files below threshold, worst metric first
|
|
4108
|
-
* 4. **Next steps** with re-run commands and cache file pointer
|
|
4109
|
-
*
|
|
4110
|
-
* When all tests pass, the output collapses to a single success line
|
|
4111
|
-
* with an optional cache file reference.
|
|
4112
|
-
*
|
|
4113
|
-
* Returns an empty string when `consoleOutput` is `"silent"`.
|
|
4114
|
-
*
|
|
4115
|
-
* @param report - The report to format
|
|
4116
|
-
* @param options - Formatting options controlling verbosity and color
|
|
4117
|
-
* @returns Formatted markdown string, or empty string for silent mode
|
|
4118
|
-
*
|
|
4119
|
-
* @internal
|
|
4120
|
-
*/
|
|
4121
|
-
export declare function formatConsoleMarkdown(report: AgentReport, options: ConsoleFormatOptions): string;
|
|
4122
|
-
/**
|
|
4123
|
-
* Format an unknown error into a human-readable string with issue URL.
|
|
4124
|
-
*
|
|
4125
|
-
* Extraction order:
|
|
4126
|
-
* 1. Effect Cause — use `Cause.pretty()` for full formatting
|
|
4127
|
-
* 2. Effect FiberFailure — extract Cause and use `Cause.pretty()`
|
|
4128
|
-
* 3. Plain Error — extract `.message` and `.stack`
|
|
4129
|
-
* 4. Unknown — `String(err)`
|
|
4130
|
-
*
|
|
4131
|
-
* @public
|
|
4132
|
-
*/
|
|
4133
|
-
export declare function formatFatalError(err: unknown): string;
|
|
4134
|
-
/**
|
|
4135
|
-
* Format one or more {@link (AgentReport:variable) | AgentReports} as a GitHub-Flavored
|
|
4136
|
-
* Markdown string for writing to `GITHUB_STEP_SUMMARY`.
|
|
4137
|
-
*
|
|
4138
|
-
* @remarks
|
|
4139
|
-
* GFM-specific features used in the output:
|
|
4140
|
-
*
|
|
4141
|
-
* - **Summary table** with pass/fail counts across all projects
|
|
4142
|
-
* - **Collapsible `<details>` blocks** for per-project results in monorepo setups
|
|
4143
|
-
* - **Tables** for coverage metrics
|
|
4144
|
-
* - **Diff-fenced code blocks** for expected/received comparison output
|
|
4145
|
-
* - **GitHub Alert callouts** (`[!WARNING]`) for coverage threshold violations
|
|
4146
|
-
*
|
|
4147
|
-
* For a single report, the project body is rendered directly without
|
|
4148
|
-
* a `<details>` wrapper. For multiple reports (monorepo), each project
|
|
4149
|
-
* gets its own collapsible section with a status icon in the summary line.
|
|
4150
|
-
*
|
|
4151
|
-
* @param reports - One or more agent reports to format
|
|
4152
|
-
* @returns GFM-formatted string ready for appending to `GITHUB_STEP_SUMMARY`
|
|
4153
|
-
*
|
|
4154
|
-
* @public
|
|
4155
|
-
*/
|
|
4156
|
-
export declare function formatGfm(reports: AgentReport[]): string;
|
|
4157
4021
|
/**
|
|
4158
4022
|
* Format the informational note shown when coverage thresholds were
|
|
4159
4023
|
* skipped because a run only exercised a subset of the project's test
|
|
@@ -4234,34 +4098,6 @@ export declare const rewriteBashCommand: (input: {
|
|
|
4234
4098
|
* @public
|
|
4235
4099
|
*/
|
|
4236
4100
|
export declare const detectVitestScripts: (scripts: Record<string, string>) => Set<string>;
|
|
4237
|
-
/**
|
|
4238
|
-
* Normalize a workspace name into a filesystem-safe directory segment.
|
|
4239
|
-
*
|
|
4240
|
-
* The workspace key drives the per-project subdirectory under the XDG data
|
|
4241
|
-
* directory (e.g. `$XDG_DATA_HOME/vitest-agent/<key>/data.db`). The
|
|
4242
|
-
* key must be deterministic for a given input and safe to use as a single
|
|
4243
|
-
* path segment on macOS, Linux, and Windows.
|
|
4244
|
-
*
|
|
4245
|
-
* Rules (applied in order):
|
|
4246
|
-
*
|
|
4247
|
-
* 1. Replace `/` with `__` so scoped names like `@org/pkg` collapse to
|
|
4248
|
-
* `@org__pkg` rather than introducing a subdirectory boundary. Scoped
|
|
4249
|
-
* npm names contain at most one `/` (between scope and name), and
|
|
4250
|
-
* leading-`@` requires the scope/name form, so `@org__pkg` is not a
|
|
4251
|
-
* valid unscoped npm name -- the `__` token is unambiguous in
|
|
4252
|
-
* practice.
|
|
4253
|
-
* 2. Replace any character outside `[A-Za-z0-9._@-]` with `_`. This catches
|
|
4254
|
-
* Windows-reserved characters (`\`, `:`, `*`, `?`, `"`, `<`, `>`, `|`),
|
|
4255
|
-
* control characters, whitespace, and anything else that varies in
|
|
4256
|
-
* interpretation across filesystems.
|
|
4257
|
-
* 3. Collapse runs of underscores produced by the substitution above into a
|
|
4258
|
-
* single `_` so the output stays compact.
|
|
4259
|
-
*
|
|
4260
|
-
* @param name - The raw `name` field from a workspace's `package.json`.
|
|
4261
|
-
* @returns A filesystem-safe single path segment.
|
|
4262
|
-
* @public
|
|
4263
|
-
*/
|
|
4264
|
-
export declare function normalizeWorkspaceKey(name: string): string;
|
|
4265
4101
|
/**
|
|
4266
4102
|
* Pure POSIX path helpers for the platform-free core.
|
|
4267
4103
|
*
|
|
@@ -4295,60 +4131,33 @@ export declare const joinPosix: (...parts: ReadonlyArray<string>) => string;
|
|
|
4295
4131
|
* @public
|
|
4296
4132
|
*/
|
|
4297
4133
|
export declare const relativePosix: (from: string, to: string) => string;
|
|
4298
|
-
/** @public */
|
|
4299
|
-
export interface HostMetadataResult {
|
|
4300
|
-
readonly source: string | null;
|
|
4301
|
-
readonly value: string | null;
|
|
4302
|
-
readonly metadata: Record<string, unknown> | null;
|
|
4303
|
-
}
|
|
4304
4134
|
/**
|
|
4305
|
-
*
|
|
4306
|
-
* along with any decorating metadata (`term_program`, `ci_provider`,
|
|
4307
|
-
* etc.) for that source. When no probe matches, `source`/`value`/
|
|
4308
|
-
* `metadata` are all `null`.
|
|
4309
|
-
*
|
|
4310
|
-
* The probe order matches the plan's table exactly:
|
|
4311
|
-
*
|
|
4312
|
-
* 1. `TMUX_PANE` (tmux reattach-stable)
|
|
4313
|
-
* 2. `WT_SESSION` (Windows Terminal pane)
|
|
4314
|
-
* 3. `WEZTERM_PANE` (WezTerm pane)
|
|
4315
|
-
* 4. `KITTY_WINDOW_ID` (kitty window)
|
|
4316
|
-
* 5. `TERM_SESSION_ID` (iTerm2, Terminal.app)
|
|
4317
|
-
* 6. `VSCODE_INJECTION` + `process.ppid` (handled by the Live layer
|
|
4318
|
-
* since it needs `process.ppid`, not env)
|
|
4319
|
-
* 7. `GITHUB_RUN_ID` + `GITHUB_RUN_ATTEMPT`
|
|
4320
|
-
* 8. `BUILDKITE_JOB_ID` / `CIRCLE_BUILD_NUM` / `GITLAB_CI_JOB_ID`
|
|
4321
|
-
* 9. `process.ppid` walk (handled by the Live layer)
|
|
4135
|
+
* Post-run work at or above this many milliseconds is always "slow".
|
|
4322
4136
|
* @public
|
|
4323
4137
|
*/
|
|
4324
|
-
export declare const
|
|
4138
|
+
export declare const POST_RUN_SLOW_MS = 5000;
|
|
4325
4139
|
/**
|
|
4326
|
-
*
|
|
4327
|
-
*
|
|
4328
|
-
*
|
|
4329
|
-
|
|
4330
|
-
|
|
4331
|
-
|
|
4332
|
-
*
|
|
4333
|
-
* @
|
|
4334
|
-
|
|
4335
|
-
|
|
4336
|
-
|
|
4337
|
-
*
|
|
4338
|
-
*
|
|
4339
|
-
|
|
4340
|
-
|
|
4341
|
-
|
|
4342
|
-
*
|
|
4343
|
-
*
|
|
4344
|
-
*
|
|
4345
|
-
* safeFilename("");
|
|
4346
|
-
* // Returns: "default"
|
|
4347
|
-
* ```
|
|
4348
|
-
*
|
|
4140
|
+
* Post-run work at or above this share of Vitest's own duration is "slow"
|
|
4141
|
+
* (once it also clears {@link POST_RUN_SLOW_MIN_MS}).
|
|
4142
|
+
* @public
|
|
4143
|
+
*/
|
|
4144
|
+
export declare const POST_RUN_SLOW_SHARE = 0.1;
|
|
4145
|
+
/**
|
|
4146
|
+
* Minimum post-run milliseconds before the share rule applies.
|
|
4147
|
+
* @public
|
|
4148
|
+
*/
|
|
4149
|
+
export declare const POST_RUN_SLOW_MIN_MS = 1000;
|
|
4150
|
+
/**
|
|
4151
|
+
* Whether the plugin's post-run work was slow enough to surface.
|
|
4152
|
+
* @public
|
|
4153
|
+
*/
|
|
4154
|
+
export declare function isPostRunSlow(timing: PostRunTiming): boolean;
|
|
4155
|
+
/**
|
|
4156
|
+
* Map run diagnostics onto suggested actions: persistence failure first, then
|
|
4157
|
+
* slow post-run work, then performance hints in input order.
|
|
4349
4158
|
* @public
|
|
4350
4159
|
*/
|
|
4351
|
-
export declare function
|
|
4160
|
+
export declare function suggestedActionsFromRunDiagnostics(d: RunDiagnostics): ReadonlyArray<SuggestedActionRecord>;
|
|
4352
4161
|
/**
|
|
4353
4162
|
* A stream stray output was written to.
|
|
4354
4163
|
* @public
|
|
@@ -4658,6 +4467,20 @@ export declare const requiredArtifactForTransition: (from: Phase, to: Phase) =>
|
|
|
4658
4467
|
export declare const transitionEnforcesBehaviorMatch: (from: Phase, to: Phase) => boolean;
|
|
4659
4468
|
/** @public */
|
|
4660
4469
|
export declare const validatePhaseTransition: (ctx: PhaseTransitionContext) => PhaseTransitionResult;
|
|
4470
|
+
/**
|
|
4471
|
+
* The config filenames Vitest 5 itself loads, in the order it prefers them:
|
|
4472
|
+
* `vitest.config.*` before `vite.config.*`, each across
|
|
4473
|
+
* `ts` / `mts` / `cts` / `js` / `mjs` / `cjs`. Mirrors `configFiles` in
|
|
4474
|
+
* Vitest's own `constants.ts`. `vitest.workspace.*` is absent on purpose:
|
|
4475
|
+
* Vitest no longer reads a workspace file (projects live in the config's
|
|
4476
|
+
* `test.projects`).
|
|
4477
|
+
*
|
|
4478
|
+
* The single source both front ends derive their config lookups from, so the
|
|
4479
|
+
* CLI's `check-test-path` and the MCP `run_tests` root walk cannot drift.
|
|
4480
|
+
*
|
|
4481
|
+
* @public
|
|
4482
|
+
*/
|
|
4483
|
+
export declare const VITEST_CONFIG_FILES: ReadonlyArray<string>;
|
|
4661
4484
|
/**
|
|
4662
4485
|
* The version of this package. Inlined at build time from
|
|
4663
4486
|
* package.json#version via rslib-builder's __PACKAGE_VERSION__ substitution.
|
package/index.js
CHANGED
|
@@ -25,6 +25,7 @@ import { AgentPluginOptions, AgentReporterOptions, ConsoleOutputs, ReportOption,
|
|
|
25
25
|
import { TestAnnotation, TestArtifact, TestArtifactLocation, TestAttachment } from "./schemas/TestArtifacts.js";
|
|
26
26
|
import { ActionSeverity, ConsoleLogLevel, CoverageGap, CoverageMetric, HookStatus, HookType, RunEvent } from "./schemas/RunEvent.js";
|
|
27
27
|
import { CoverageRenderState, FailureRecord, ModuleRecord, RenderState, RenderTotals, SuggestedActionRecord, TestRecord, initialRenderState } from "./schemas/RenderState.js";
|
|
28
|
+
import { PerformanceHint, PerformanceHintKind, PersistenceStatus, PostRunTiming, RunDiagnostics } from "./schemas/RunDiagnostics.js";
|
|
28
29
|
import { RUN_REPORT_FILE_SCHEMA_URL, RunReportFile } from "./schemas/RunReportFile.js";
|
|
29
30
|
import { BehaviorDetail, BehaviorRow, BehaviorStatus, GoalDetail, GoalRow, GoalStatus } from "./schemas/Tdd.js";
|
|
30
31
|
import { TrendEntry, TrendRecord } from "./schemas/Trends.js";
|
|
@@ -36,31 +37,25 @@ import { ToolCallPayload } from "./schemas/turns/ToolCallPayload.js";
|
|
|
36
37
|
import { ToolResultPayload } from "./schemas/turns/ToolResultPayload.js";
|
|
37
38
|
import { UserPromptPayload } from "./schemas/turns/UserPromptPayload.js";
|
|
38
39
|
import { TurnPayload } from "./schemas/turns/index.js";
|
|
39
|
-
import {
|
|
40
|
+
import { stripAnsi } from "./utils/ansi.js";
|
|
40
41
|
import { coerceErrorField, coerceErrorText } from "./utils/coerce-error-text.js";
|
|
41
42
|
import { buildAgentReport, countSuiteFailures } from "./utils/build-report.js";
|
|
42
43
|
import { canonicalizeGitUrl, gitUrlToProjectKey } from "./utils/canonicalize-git-url.js";
|
|
43
44
|
import { classifyTest } from "./utils/classify-test.js";
|
|
44
|
-
import { compressLines } from "./utils/compress-lines.js";
|
|
45
45
|
import { computeTrend, getRecentDirection, hashTargets } from "./utils/compute-trend.js";
|
|
46
46
|
import { buildConsoleLeaks, collectConsoleLeakEntries, formatConsoleLeaksNote } from "./utils/console-leaks.js";
|
|
47
47
|
import { detectNonDefaultDiscoverStrategy } from "./utils/detect-non-default-discover-strategy.js";
|
|
48
|
-
import { detectPackageManager, getRunCommand } from "./utils/detect-pm.js";
|
|
49
48
|
import { isTimeoutError } from "./utils/detect-timeout.js";
|
|
50
49
|
import { formatScopedCoverageNote } from "./utils/format-scoped-coverage-note.js";
|
|
51
|
-
import { determineTier, formatConsoleMarkdown, getWorstMetric, relativePath } from "./utils/format-console.js";
|
|
52
|
-
import { formatFatalError } from "./utils/format-fatal-error.js";
|
|
53
|
-
import { formatGfm } from "./utils/format-gfm.js";
|
|
54
50
|
import { findFunctionBoundary } from "./utils/function-boundary.js";
|
|
55
51
|
import { buildEnvPrefix, detectVitestScripts, isVitestInvocation, rewriteBashCommand } from "./utils/match-vitest-command.js";
|
|
56
|
-
import { normalizeWorkspaceKey } from "./utils/normalize-workspace-key.js";
|
|
57
52
|
import { basenamePosix, joinPosix, relativePosix, toPosix } from "./utils/posix-path.js";
|
|
58
|
-
import {
|
|
59
|
-
import { safeFilename } from "./utils/safe-filename.js";
|
|
53
|
+
import { POST_RUN_SLOW_MIN_MS, POST_RUN_SLOW_MS, POST_RUN_SLOW_SHARE, isPostRunSlow, suggestedActionsFromRunDiagnostics } from "./utils/run-diagnostics-actions.js";
|
|
60
54
|
import { STRAY_OUTPUT_SOURCE, formatStrayOutputNote, isEscapeOnly, makeStrayOutputRecorder, readStrayOutput } from "./utils/stray-output.js";
|
|
61
55
|
import { BATS_FILE_GLOB_SUFFIX, NON_DISCOVERABLE_DIRS, SRC_DIR, TEST_DIR, TEST_FILE_GLOB_SUFFIX, TEST_HELPER_DIRS, classifyTestPath, findOwningWorkspace, isTestFileName } from "./utils/test-location.js";
|
|
62
56
|
import { validateCoverageTargetsShape } from "./utils/validate-coverage-targets-shape.js";
|
|
63
57
|
import { requiredArtifactForTransition, transitionEnforcesBehaviorMatch, validatePhaseTransition } from "./utils/validate-phase-transition.js";
|
|
58
|
+
import { VITEST_CONFIG_FILES } from "./utils/vitest-config-files.js";
|
|
64
59
|
import { CURRENT_SDK_VERSION } from "./version.js";
|
|
65
60
|
|
|
66
|
-
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, FiniteNumber, 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, ProjectIdentitySourceError, 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,
|
|
61
|
+
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, FiniteNumber, 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, POST_RUN_SLOW_MIN_MS, POST_RUN_SLOW_MS, POST_RUN_SLOW_SHARE, PackageManager, PathResolutionError, PatternMetricThresholds, PatternThresholds, PerFileThresholds, PerformanceHint, PerformanceHintKind, PersistenceStatus, PhaseTransitionEvent, PostRunTiming, ProbeMissError, ProjectIdentityNotResolvableError, ProjectIdentitySourceError, ProjectKey, RUN_REPORT_FILE_SCHEMA_URL, RegistrationConflictError, RenderState, RenderTotals, ReportError, ReportOption, ReportSettings, ReportSummary, ResolvedThresholds, RetentionConfig, RunDiagnostics, 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, VITEST_CONFIG_FILES, VitestAgentConfig, basenamePosix, buildAgentReport, buildConsoleLeaks, buildEnvPrefix, canonicalizeGitUrl, classifyTest, classifyTestPath, coerceErrorField, coerceErrorText, collectConsoleLeakEntries, computeTrend, countSuiteFailures, detectNonDefaultDiscoverStrategy, detectVitestScripts, extractSqlReason, findFunctionBoundary, findOwningWorkspace, formatConsoleLeaksNote, formatScopedCoverageNote, formatStrayOutputNote, getRecentDirection, gitUrlToProjectKey, hashTargets, initialRenderState, isEscapeOnly, isPostRunSlow, isTestFileName, isTimeoutError, isVitestInvocation, joinPosix, makeStrayOutputRecorder, readStrayOutput, relativePosix, requiredArtifactForTransition, resolveCoverageInput, rewriteBashCommand, stripAnsi, suggestedActionsFromRunDiagnostics, toPosix, transitionEnforcesBehaviorMatch, validateCoverageConfig, validateCoverageTargetsShape, validatePhaseTransition };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitest-agent/sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.0.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": [
|