@vitest-agent/sdk 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DataReader-2kJ9I9Hh.d.ts +1809 -0
- package/LICENSE +21 -0
- package/README.md +52 -0
- package/dispatch.d.ts +48 -0
- package/dispatch.js +5 -0
- package/errors/AgentErrors.js +65 -0
- package/errors/DataStoreError.js +44 -0
- package/errors/DiscoveryError.js +21 -0
- package/errors/PathResolutionError.js +27 -0
- package/errors/ProjectIdentityError.js +29 -0
- package/errors/RunContextError.js +35 -0
- package/errors/TddErrors.js +66 -0
- package/exit-code-for-tag.js +18 -0
- package/formatters/ci-annotations.js +61 -0
- package/formatters/gfm.js +20 -0
- package/formatters/json.js +18 -0
- package/formatters/markdown.js +39 -0
- package/formatters/silent.js +9 -0
- package/formatters/terminal.js +56 -0
- package/index.d.ts +3334 -0
- package/index.js +120 -0
- package/internal-inject-env.js +42 -0
- package/layers/ConfigLive.js +47 -0
- package/layers/DataReaderLive.js +1666 -0
- package/layers/DataStoreLive.js +1185 -0
- package/layers/DetailResolverLive.js +9 -0
- package/layers/DiscoveryRegistryLive.js +70 -0
- package/layers/EnvironmentDetectorLive.js +21 -0
- package/layers/EnvironmentDetectorTest.js +13 -0
- package/layers/ExecutorResolverLive.js +9 -0
- package/layers/FormatSelectorLive.js +20 -0
- package/layers/HistoryTrackerLive.js +47 -0
- package/layers/HistoryTrackerTest.js +25 -0
- package/layers/LoggerLive.js +64 -0
- package/layers/OutputPipelineLive.js +13 -0
- package/layers/OutputRendererLive.js +28 -0
- package/layers/PathResolutionLive.js +36 -0
- package/layers/PerClientSessionMapLive.js +145 -0
- package/layers/ProjectDiscoveryLive.js +70 -0
- package/layers/ProjectDiscoveryTest.js +12 -0
- package/layers/ProjectIdentityLive.js +92 -0
- package/layers/RunContextLive.js +81 -0
- package/lib/format-triage.js +103 -0
- package/lib/format-wrapup.js +67 -0
- package/migrations/0001_initial.js +849 -0
- package/migrations/registry_0001_initial.js +39 -0
- package/migrations/session_map_0001_initial.js +61 -0
- package/package.json +64 -0
- package/schemas/Agent.js +42 -0
- package/schemas/AgentReport.js +71 -0
- package/schemas/Baselines.js +16 -0
- package/schemas/CacheManifest.js +27 -0
- package/schemas/ChannelEvent.js +138 -0
- package/schemas/Common.js +105 -0
- package/schemas/Config.js +28 -0
- package/schemas/Coverage.js +51 -0
- package/schemas/CoverageLevel.js +117 -0
- package/schemas/CoverageTargets.js +39 -0
- package/schemas/History.js +31 -0
- package/schemas/Identity.js +64 -0
- package/schemas/Options.js +57 -0
- package/schemas/RenderState.js +161 -0
- package/schemas/RunEvent.js +163 -0
- package/schemas/Tdd.js +44 -0
- package/schemas/Thresholds.js +30 -0
- package/schemas/Transport.js +16 -0
- package/schemas/Trends.js +23 -0
- package/schemas/turns/FileEditPayload.js +15 -0
- package/schemas/turns/HookFirePayload.js +13 -0
- package/schemas/turns/HypothesisPayload.js +13 -0
- package/schemas/turns/NotePayload.js +13 -0
- package/schemas/turns/ToolCallPayload.js +13 -0
- package/schemas/turns/ToolResultPayload.js +15 -0
- package/schemas/turns/UserPromptPayload.js +12 -0
- package/schemas/turns/index.js +15 -0
- package/services/Config.js +15 -0
- package/services/DataReader.js +8 -0
- package/services/DataStore.js +8 -0
- package/services/DetailResolver.js +8 -0
- package/services/DiscoveryRegistry.js +8 -0
- package/services/EnvironmentDetector.js +8 -0
- package/services/ExecutorResolver.js +8 -0
- package/services/FormatSelector.js +8 -0
- package/services/HistoryTracker.js +8 -0
- package/services/OutputRenderer.js +8 -0
- package/services/PerClientSessionMap.js +22 -0
- package/services/ProjectDiscovery.js +8 -0
- package/services/ProjectIdentity.js +63 -0
- package/services/RunContext.js +53 -0
- package/services/idempotency.js +57 -0
- package/sidecar-dispatch.js +84 -0
- package/sql/assemblers.js +59 -0
- package/testing/layers.js +21 -0
- package/testing.d.ts +25 -0
- package/testing.js +243 -0
- package/tsdoc-metadata.json +11 -0
- package/utils/ansi.js +49 -0
- package/utils/build-report.js +130 -0
- package/utils/canonicalize-git-url.js +66 -0
- package/utils/classify-test.js +22 -0
- package/utils/compress-lines.js +45 -0
- package/utils/compute-trend.js +88 -0
- package/utils/detect-pm.js +58 -0
- package/utils/detect-timeout.js +17 -0
- package/utils/ensure-migrated.js +52 -0
- package/utils/failure-signature.js +33 -0
- package/utils/format-console.js +219 -0
- package/utils/format-fatal-error.js +35 -0
- package/utils/format-gfm.js +161 -0
- package/utils/format-terminal.js +480 -0
- package/utils/function-boundary.js +75 -0
- package/utils/hyperlink.js +11 -0
- package/utils/match-vitest-command.js +88 -0
- package/utils/normalize-workspace-key.js +34 -0
- package/utils/probe-host-metadata.js +99 -0
- package/utils/resolve-data-path.js +66 -0
- package/utils/resolve-project-key-from-cwd.js +52 -0
- package/utils/resolve-workspace-key.js +33 -0
- package/utils/safe-filename.js +34 -0
- package/utils/validate-coverage-targets-shape.js +84 -0
- package/utils/validate-phase-transition.js +113 -0
package/index.js
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { AgentNotFoundError, ConversationNotFoundError, HostMetadataParseError, RegistrationConflictError, SessionNotFoundError, SidecarTimeoutError } from "./errors/AgentErrors.js";
|
|
2
|
+
import { DataStoreError, extractSqlReason } from "./errors/DataStoreError.js";
|
|
3
|
+
import { DiscoveryError } from "./errors/DiscoveryError.js";
|
|
4
|
+
import { PathResolutionError } from "./errors/PathResolutionError.js";
|
|
5
|
+
import { ProjectIdentityNotResolvableError } from "./errors/ProjectIdentityError.js";
|
|
6
|
+
import { GitCommandError, ProbeMissError } from "./errors/RunContextError.js";
|
|
7
|
+
import { BehaviorNotFoundError, GoalNotFoundError, IllegalStatusTransitionError, TddTaskAlreadyEndedError, TddTaskNotFoundError } from "./errors/TddErrors.js";
|
|
8
|
+
import { ciAnnotationsFormatter } from "./formatters/ci-annotations.js";
|
|
9
|
+
import { formatGfm } from "./utils/format-gfm.js";
|
|
10
|
+
import { GfmFormatter } from "./formatters/gfm.js";
|
|
11
|
+
import { JsonFormatter } from "./formatters/json.js";
|
|
12
|
+
import { ansi, stripAnsi } from "./utils/ansi.js";
|
|
13
|
+
import { determineTier, formatConsoleMarkdown, getWorstMetric, relativePath } from "./utils/format-console.js";
|
|
14
|
+
import { MarkdownFormatter } from "./formatters/markdown.js";
|
|
15
|
+
import { SilentFormatter } from "./formatters/silent.js";
|
|
16
|
+
import { compressLines } from "./utils/compress-lines.js";
|
|
17
|
+
import { osc8 } from "./utils/hyperlink.js";
|
|
18
|
+
import { TerminalFormatter } from "./formatters/terminal.js";
|
|
19
|
+
import { VitestAgentConfig } from "./schemas/Config.js";
|
|
20
|
+
import { VitestAgentConfigFile } from "./services/Config.js";
|
|
21
|
+
import { ConfigLive } from "./layers/ConfigLive.js";
|
|
22
|
+
import { DataReader } from "./services/DataReader.js";
|
|
23
|
+
import { DataReaderLive } from "./layers/DataReaderLive.js";
|
|
24
|
+
import { ActorType, AgentId, ChatId, ConversationId, HostKind, ProjectKey, TddTaskId } from "./schemas/Identity.js";
|
|
25
|
+
import { Agent, IdempotencyHit } from "./schemas/Agent.js";
|
|
26
|
+
import { DataStore } from "./services/DataStore.js";
|
|
27
|
+
import { DataStoreLive } from "./layers/DataStoreLive.js";
|
|
28
|
+
import { DetailResolver } from "./services/DetailResolver.js";
|
|
29
|
+
import { DetailResolverLive } from "./layers/DetailResolverLive.js";
|
|
30
|
+
import { DiscoveryRegistry } from "./services/DiscoveryRegistry.js";
|
|
31
|
+
import { DiscoveryRegistryLive } from "./layers/DiscoveryRegistryLive.js";
|
|
32
|
+
import { EnvironmentDetector } from "./services/EnvironmentDetector.js";
|
|
33
|
+
import { EnvironmentDetectorLive } from "./layers/EnvironmentDetectorLive.js";
|
|
34
|
+
import { EnvironmentDetectorTest } from "./layers/EnvironmentDetectorTest.js";
|
|
35
|
+
import { ExecutorResolver } from "./services/ExecutorResolver.js";
|
|
36
|
+
import { ExecutorResolverLive } from "./layers/ExecutorResolverLive.js";
|
|
37
|
+
import { FormatSelector } from "./services/FormatSelector.js";
|
|
38
|
+
import { FormatSelectorLive } from "./layers/FormatSelectorLive.js";
|
|
39
|
+
import { HistoryTracker } from "./services/HistoryTracker.js";
|
|
40
|
+
import { classifyTest } from "./utils/classify-test.js";
|
|
41
|
+
import { HistoryTrackerLive } from "./layers/HistoryTrackerLive.js";
|
|
42
|
+
import { HistoryTrackerTest } from "./layers/HistoryTrackerTest.js";
|
|
43
|
+
import { LoggerLive, resolveLogFile, resolveLogLevel } from "./layers/LoggerLive.js";
|
|
44
|
+
import { OutputRenderer } from "./services/OutputRenderer.js";
|
|
45
|
+
import { OutputRendererLive } from "./layers/OutputRendererLive.js";
|
|
46
|
+
import { OutputPipelineLive } from "./layers/OutputPipelineLive.js";
|
|
47
|
+
import { PathResolutionLive } from "./layers/PathResolutionLive.js";
|
|
48
|
+
import { PerClientSessionMapReader, PerClientSessionMapWriter } from "./services/PerClientSessionMap.js";
|
|
49
|
+
import { PerClientSessionMapReaderLive, PerClientSessionMapWriterLive } from "./layers/PerClientSessionMapLive.js";
|
|
50
|
+
import { ProjectDiscovery } from "./services/ProjectDiscovery.js";
|
|
51
|
+
import { ProjectDiscoveryLive } from "./layers/ProjectDiscoveryLive.js";
|
|
52
|
+
import { ProjectDiscoveryTest } from "./layers/ProjectDiscoveryTest.js";
|
|
53
|
+
import { canonicalizeGitUrl, gitUrlToProjectKey } from "./utils/canonicalize-git-url.js";
|
|
54
|
+
import { normalizeWorkspaceKey } from "./utils/normalize-workspace-key.js";
|
|
55
|
+
import { ProjectIdentity, resolveProjectIdentityFromCandidates } from "./services/ProjectIdentity.js";
|
|
56
|
+
import { ProjectIdentityLive, ProjectIdentityTest } from "./layers/ProjectIdentityLive.js";
|
|
57
|
+
import { AgentContext, RunContext, RunContext$, RunContextService } from "./services/RunContext.js";
|
|
58
|
+
import { probeHostMetadataFromEnv } from "./utils/probe-host-metadata.js";
|
|
59
|
+
import { RunContextLive, RunContextTest } from "./layers/RunContextLive.js";
|
|
60
|
+
import { formatTriageEffect } from "./lib/format-triage.js";
|
|
61
|
+
import { formatWrapupEffect } from "./lib/format-wrapup.js";
|
|
62
|
+
import migration from "./migrations/0001_initial.js";
|
|
63
|
+
import migration$1 from "./migrations/registry_0001_initial.js";
|
|
64
|
+
import migration$2 from "./migrations/session_map_0001_initial.js";
|
|
65
|
+
import { AgentConsoleMode, CiConsoleMode, ConsoleMode, ConsoleOutputMode, DetailLevel, Environment, Executor, HumanConsoleMode, OutputFormat, PackageManager, ReportError, TestClassification, TestRunReason, TestState } from "./schemas/Common.js";
|
|
66
|
+
import { MetricThresholds, PatternThresholds, ResolvedThresholds } from "./schemas/Thresholds.js";
|
|
67
|
+
import { CoverageReport, CoverageTotals, FileCoverageReport } from "./schemas/Coverage.js";
|
|
68
|
+
import { AgentReport, ModuleReport, ReportSummary, TagCountEntry, TestReport } from "./schemas/AgentReport.js";
|
|
69
|
+
import { CoverageBaselines } from "./schemas/Baselines.js";
|
|
70
|
+
import { CacheManifest, CacheManifestEntry } from "./schemas/CacheManifest.js";
|
|
71
|
+
import { BehaviorAbandonedEvent, BehaviorAddedEvent, BehaviorCompletedEvent, BehaviorScopedEventTypes, BehaviorStartedEvent, BehaviorsReadyEvent, BlockedEvent, ChannelEvent, GoalAbandonedEvent, GoalAddedEvent, GoalCompletedEvent, GoalStartedEvent, GoalsReadyEvent, PhaseTransitionEvent, SessionCompleteEvent, SessionOutcome } from "./schemas/ChannelEvent.js";
|
|
72
|
+
import { CoverageLevel, resolveCoverageInput, validateCoverageConfig } from "./schemas/CoverageLevel.js";
|
|
73
|
+
import { CoverageTargets, CoverageTargetsMetrics } from "./schemas/CoverageTargets.js";
|
|
74
|
+
import { HistoryRecord, TestHistory, TestRun } from "./schemas/History.js";
|
|
75
|
+
import { Transport } from "./schemas/Transport.js";
|
|
76
|
+
import { AgentPluginOptions, AgentReporterOptions, ConsoleOutputs } from "./schemas/Options.js";
|
|
77
|
+
import { ActionSeverity, ConsoleLogLevel, CoverageGap, CoverageMetric, HookStatus, HookType, RunEvent } from "./schemas/RunEvent.js";
|
|
78
|
+
import { CoverageRenderState, FailureRecord, ModuleRecord, RenderState, RenderTotals, SuggestedActionRecord, TestRecord, initialRenderState } from "./schemas/RenderState.js";
|
|
79
|
+
import { BehaviorDetail, BehaviorRow, BehaviorStatus, GoalDetail, GoalRow, GoalStatus } from "./schemas/Tdd.js";
|
|
80
|
+
import { TrendEntry, TrendRecord } from "./schemas/Trends.js";
|
|
81
|
+
import { FileEditPayload } from "./schemas/turns/FileEditPayload.js";
|
|
82
|
+
import { HookFirePayload } from "./schemas/turns/HookFirePayload.js";
|
|
83
|
+
import { HypothesisPayload } from "./schemas/turns/HypothesisPayload.js";
|
|
84
|
+
import { NotePayload } from "./schemas/turns/NotePayload.js";
|
|
85
|
+
import { ToolCallPayload } from "./schemas/turns/ToolCallPayload.js";
|
|
86
|
+
import { ToolResultPayload } from "./schemas/turns/ToolResultPayload.js";
|
|
87
|
+
import { UserPromptPayload } from "./schemas/turns/UserPromptPayload.js";
|
|
88
|
+
import { TurnPayload } from "./schemas/turns/index.js";
|
|
89
|
+
import { IDEMPOTENCY_ROOT_SENTINEL, deriveIdempotencyKey } from "./services/idempotency.js";
|
|
90
|
+
import { assembleHistoryRecord, assembleManifest } from "./sql/assemblers.js";
|
|
91
|
+
import { buildAgentReport } from "./utils/build-report.js";
|
|
92
|
+
import { computeTrend, getRecentDirection, hashTargets } from "./utils/compute-trend.js";
|
|
93
|
+
import { detectPackageManager, getRunCommand } from "./utils/detect-pm.js";
|
|
94
|
+
import { isTimeoutError } from "./utils/detect-timeout.js";
|
|
95
|
+
import { _resetMigrationCacheForTesting, ensureMigrated } from "./utils/ensure-migrated.js";
|
|
96
|
+
import { computeFailureSignature, normalizeAssertionShape } from "./utils/failure-signature.js";
|
|
97
|
+
import { formatFatalError } from "./utils/format-fatal-error.js";
|
|
98
|
+
import { findFunctionBoundary } from "./utils/function-boundary.js";
|
|
99
|
+
import { buildEnvPrefix, detectVitestScripts, isVitestInvocation, rewriteBashCommand } from "./utils/match-vitest-command.js";
|
|
100
|
+
import { resolveProjectKeyFromCwd } from "./utils/resolve-project-key-from-cwd.js";
|
|
101
|
+
import { DATABASE_FILENAME, resolveDataPath } from "./utils/resolve-data-path.js";
|
|
102
|
+
import { resolveWorkspaceKey } from "./utils/resolve-workspace-key.js";
|
|
103
|
+
import { safeFilename } from "./utils/safe-filename.js";
|
|
104
|
+
import { validateCoverageTargetsShape } from "./utils/validate-coverage-targets-shape.js";
|
|
105
|
+
import { requiredArtifactForTransition, validatePhaseTransition } from "./utils/validate-phase-transition.js";
|
|
106
|
+
|
|
107
|
+
//#region src/index.ts
|
|
108
|
+
/**
|
|
109
|
+
* The version of this package. Inlined at build time from
|
|
110
|
+
* package.json#version via rslib-builder's __PACKAGE_VERSION__ substitution.
|
|
111
|
+
* Source-level reads (workspace `exports: "./src/index.ts"` during dev)
|
|
112
|
+
* see the `"0.0.0"` fallback — a clear signal the build pipeline has not
|
|
113
|
+
* substituted yet. Read by the plugin / MCP / CLI init-time drift check.
|
|
114
|
+
* See the root CLAUDE.md "Cross-package version drift" section.
|
|
115
|
+
* @public
|
|
116
|
+
*/
|
|
117
|
+
const CURRENT_SDK_VERSION = "1.0.0";
|
|
118
|
+
|
|
119
|
+
//#endregion
|
|
120
|
+
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, 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, buildEnvPrefix, canonicalizeGitUrl, ciAnnotationsFormatter, classifyTest, compressLines, computeFailureSignature, computeTrend, deriveIdempotencyKey, detectPackageManager, detectVitestScripts, determineTier, ensureMigrated, extractSqlReason, findFunctionBoundary, formatConsoleMarkdown, formatFatalError, formatGfm, formatTriageEffect, formatWrapupEffect, getRecentDirection, getRunCommand, getWorstMetric, gitUrlToProjectKey, hashTargets, 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, validateCoverageConfig, validateCoverageTargetsShape, validatePhaseTransition };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { detectVitestScripts, rewriteBashCommand } from "./utils/match-vitest-command.js";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { readFileSync } from "node:fs";
|
|
4
|
+
|
|
5
|
+
//#region src/internal-inject-env.ts
|
|
6
|
+
const readPackageScripts = (cwd) => {
|
|
7
|
+
try {
|
|
8
|
+
const raw = readFileSync(join(cwd, "package.json"), "utf-8");
|
|
9
|
+
return JSON.parse(raw).scripts ?? {};
|
|
10
|
+
} catch {
|
|
11
|
+
return {};
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Compute the (possibly rewritten) Bash command. Returns the original
|
|
16
|
+
* unchanged when:
|
|
17
|
+
*
|
|
18
|
+
* - The command does not match any Vitest pattern
|
|
19
|
+
* - `VITEST_AGENT_CONVERSATION_ID` or `VITEST_AGENT_AGENT_ID` is
|
|
20
|
+
* missing from env (no agent context to attribute to)
|
|
21
|
+
*
|
|
22
|
+
* Always synchronous — the package.json read is the only I/O and is
|
|
23
|
+
* fast enough not to need Effect wrapping.
|
|
24
|
+
* @public
|
|
25
|
+
*/
|
|
26
|
+
const injectEnv = (input) => {
|
|
27
|
+
const conversationId = input.env.VITEST_AGENT_CONVERSATION_ID;
|
|
28
|
+
const agentId = input.env.VITEST_AGENT_AGENT_ID;
|
|
29
|
+
if (conversationId === void 0 || agentId === void 0) return input.command;
|
|
30
|
+
const vitestScripts = detectVitestScripts(readPackageScripts(input.cwd));
|
|
31
|
+
const parentAgentId = input.env.VITEST_AGENT_PARENT_AGENT_ID;
|
|
32
|
+
return rewriteBashCommand({
|
|
33
|
+
command: input.command,
|
|
34
|
+
vitestScripts,
|
|
35
|
+
conversationId,
|
|
36
|
+
agentId,
|
|
37
|
+
...parentAgentId !== void 0 && { parentAgentId }
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
//#endregion
|
|
42
|
+
export { injectEnv };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { VitestAgentConfig } from "../schemas/Config.js";
|
|
2
|
+
import { VitestAgentConfigFile } from "../services/Config.js";
|
|
3
|
+
import { ConfigFile, FirstMatch, GitRoot, TomlCodec, UpwardWalk, WorkspaceRoot } from "config-file-effect";
|
|
4
|
+
|
|
5
|
+
//#region src/layers/ConfigLive.ts
|
|
6
|
+
const CONFIG_FILENAME = "vitest-agent.config.toml";
|
|
7
|
+
/**
|
|
8
|
+
* Build the live `ConfigFile` layer for a given project directory.
|
|
9
|
+
*
|
|
10
|
+
* Resolves the optional `vitest-agent.config.toml` from (in order):
|
|
11
|
+
*
|
|
12
|
+
* 1. The workspace root (when `projectDir` is inside a pnpm/npm/yarn workspace).
|
|
13
|
+
* 2. The git repository root (when `projectDir` is inside a git repo).
|
|
14
|
+
* 3. Walking upward from `projectDir`.
|
|
15
|
+
*
|
|
16
|
+
* The first found file wins (`FirstMatch` strategy). If no file is present,
|
|
17
|
+
* downstream callers use `loadOrDefault(new VitestAgentConfig({}))`
|
|
18
|
+
* to get an empty config.
|
|
19
|
+
*
|
|
20
|
+
* @param projectDir - Absolute path inside the user's workspace. Resolvers
|
|
21
|
+
* anchor here rather than `process.cwd()` so the plugin-spawned MCP server
|
|
22
|
+
* sees the right config even when invoked from elsewhere.
|
|
23
|
+
* @public
|
|
24
|
+
*/
|
|
25
|
+
const ConfigLive = (projectDir) => ConfigFile.Live({
|
|
26
|
+
tag: VitestAgentConfigFile,
|
|
27
|
+
schema: VitestAgentConfig,
|
|
28
|
+
codec: TomlCodec,
|
|
29
|
+
strategy: FirstMatch,
|
|
30
|
+
resolvers: [
|
|
31
|
+
WorkspaceRoot({
|
|
32
|
+
filename: CONFIG_FILENAME,
|
|
33
|
+
cwd: projectDir
|
|
34
|
+
}),
|
|
35
|
+
GitRoot({
|
|
36
|
+
filename: CONFIG_FILENAME,
|
|
37
|
+
cwd: projectDir
|
|
38
|
+
}),
|
|
39
|
+
UpwardWalk({
|
|
40
|
+
filename: CONFIG_FILENAME,
|
|
41
|
+
cwd: projectDir
|
|
42
|
+
})
|
|
43
|
+
]
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
//#endregion
|
|
47
|
+
export { ConfigLive };
|