diff --git a/packages/coding-agent/test/session-file-invalid.test.ts b/packages/coding-agent/test/session-file-invalid.test.ts index c69ef43a1..e2eb7015c 100644 --- a/packages/coding-agent/test/session-file-invalid.test.ts +++ b/packages/coding-agent/test/session-file-invalid.test.ts @@ -6,6 +6,7 @@ import { afterEach, describe, expect, it } from "vitest"; import { ENV_AGENT_DIR } from "../src/config.ts"; const cliPath = resolve(__dirname, "../src/cli.ts"); +const sourceResolverPath = resolve(__dirname, "../src/experimental/source-resolver.ts"); const tempDirs: string[] = []; afterEach(() => { @@ -23,13 +24,12 @@ function createTempDir(): string { async function runCli(args: string[], cwd: string, agentDir: string): Promise<{ code: number | null; stderr: string }> { let stderr = ""; const code = await new Promise((resolvePromise, reject) => { - const child = spawn(process.execPath, [cliPath, ...args], { + const child = spawn(process.execPath, ["--import", sourceResolverPath, cliPath, ...args], { cwd, env: { ...process.env, [ENV_AGENT_DIR]: agentDir, PI_OFFLINE: "1", - TSX_TSCONFIG_PATH: resolve(__dirname, "../../../tsconfig.json"), }, stdio: ["ignore", "ignore", "pipe"], }); diff --git a/packages/coding-agent/test/session-id-readonly.test.ts b/packages/coding-agent/test/session-id-readonly.test.ts index 5527193ec..20a129977 100644 --- a/packages/coding-agent/test/session-id-readonly.test.ts +++ b/packages/coding-agent/test/session-id-readonly.test.ts @@ -10,6 +10,7 @@ import { SettingsManager } from "../src/core/settings-manager.ts"; import { createSessionManager } from "../src/main.ts"; const cliPath = resolve(__dirname, "../src/cli.ts"); +const sourceResolverPath = resolve(__dirname, "../src/experimental/source-resolver.ts"); const tempDirs: string[] = []; afterEach(() => { @@ -54,13 +55,12 @@ async function runCli(args: string[]): Promise<{ code: number | null; agentDir: mkdirSync(projectDir, { recursive: true }); const code = await new Promise((resolvePromise, reject) => { - const child = spawn(process.execPath, [cliPath, ...args], { + const child = spawn(process.execPath, ["--import", sourceResolverPath, cliPath, ...args], { cwd: projectDir, env: { ...process.env, [ENV_AGENT_DIR]: agentDir, PI_OFFLINE: "1", - TSX_TSCONFIG_PATH: resolve(__dirname, "../../../tsconfig.json"), }, stdio: ["ignore", "ignore", "ignore"], }); diff --git a/packages/coding-agent/test/startup-session-name.test.ts b/packages/coding-agent/test/startup-session-name.test.ts index 3571ce666..c953cd1ae 100644 --- a/packages/coding-agent/test/startup-session-name.test.ts +++ b/packages/coding-agent/test/startup-session-name.test.ts @@ -6,6 +6,7 @@ import { afterEach, describe, expect, it } from "vitest"; import { ENV_AGENT_DIR } from "../src/config.ts"; const cliPath = resolve(__dirname, "../src/cli.ts"); +const sourceResolverPath = resolve(__dirname, "../src/experimental/source-resolver.ts"); const tempDirs: string[] = []; afterEach(() => { @@ -65,13 +66,12 @@ function readSessionInfoNames(sessionFile: string): string[] { async function runCli(args: string[], dirs: CliDirs): Promise { let stderr = ""; - const child = spawn(process.execPath, [cliPath, ...args], { + const child = spawn(process.execPath, ["--import", sourceResolverPath, cliPath, ...args], { cwd: dirs.projectDir, env: { ...process.env, [ENV_AGENT_DIR]: dirs.agentDir, PI_OFFLINE: "1", - TSX_TSCONFIG_PATH: resolve(__dirname, "../../../tsconfig.json"), }, stdio: ["ignore", "ignore", "pipe"], }); diff --git a/packages/coding-agent/test/stdout-cleanliness.test.ts b/packages/coding-agent/test/stdout-cleanliness.test.ts index a5ffa5e68..baaf296a5 100644 --- a/packages/coding-agent/test/stdout-cleanliness.test.ts +++ b/packages/coding-agent/test/stdout-cleanliness.test.ts @@ -7,6 +7,7 @@ import { ENV_AGENT_DIR } from "../src/config.ts"; import { allowNetwork } from "./test-network-env.ts"; const cliPath = resolve(__dirname, "../src/cli.ts"); +const sourceResolverPath = resolve(__dirname, "../src/experimental/source-resolver.ts"); const tempDirs: string[] = []; @@ -59,12 +60,11 @@ async function runCli(args: string[]): Promise<{ stdout: string; stderr: string; ); return await new Promise((resolvePromise, reject) => { - const child = spawn(process.execPath, [cliPath, ...args], { + const child = spawn(process.execPath, ["--import", sourceResolverPath, cliPath, ...args], { cwd: projectDir, env: { ...process.env, [ENV_AGENT_DIR]: agentDir, - TSX_TSCONFIG_PATH: resolve(__dirname, "../../../tsconfig.json"), }, stdio: ["ignore", "pipe", "pipe"], }); diff --git a/vitest.base.ts b/vitest.base.ts index d21ad3b7e..9394bcb1e 100644 --- a/vitest.base.ts +++ b/vitest.base.ts @@ -2,6 +2,11 @@ import { fileURLToPath } from "node:url"; import { defineConfig } from "vitest/config"; export const workspaceSourcePaths = { + chordIndex: fileURLToPath(new URL("./packages/chord/src/index.ts", import.meta.url)), + chordContext: fileURLToPath(new URL("./packages/chord/src/context/index.ts", import.meta.url)), + chordDelta: fileURLToPath(new URL("./packages/chord/src/delta/index.ts", import.meta.url)), + chordBundler: fileURLToPath(new URL("./packages/chord/src/bundler.ts", import.meta.url)), + chordNode: fileURLToPath(new URL("./packages/chord/src/node.ts", import.meta.url)), telemetryIndex: fileURLToPath(new URL("./packages/telemetry/src/index.ts", import.meta.url)), telemetryTesting: fileURLToPath(new URL("./packages/telemetry/src/testing/index.ts", import.meta.url)), aiIndex: fileURLToPath(new URL("./packages/ai/src/index.ts", import.meta.url)), @@ -21,8 +26,12 @@ export const workspaceSourcePaths = { export default defineConfig({ resolve: { - conditions: ["source"], alias: [ + { find: /^@earendil-works\/chord$/, replacement: workspaceSourcePaths.chordIndex }, + { find: /^@earendil-works\/chord\/context$/, replacement: workspaceSourcePaths.chordContext }, + { find: /^@earendil-works\/chord\/delta$/, replacement: workspaceSourcePaths.chordDelta }, + { find: /^@earendil-works\/chord\/bundler$/, replacement: workspaceSourcePaths.chordBundler }, + { find: /^@earendil-works\/chord\/node$/, replacement: workspaceSourcePaths.chordNode }, { find: /^@earendil-works\/pi-telemetry$/, replacement: workspaceSourcePaths.telemetryIndex }, { find: /^@earendil-works\/pi-telemetry\/testing$/, replacement: workspaceSourcePaths.telemetryTesting }, { find: /^@earendil-works\/pi-ai$/, replacement: workspaceSourcePaths.aiIndex }, @@ -42,5 +51,4 @@ export default defineConfig({ { find: /^@earendil-works\/pi-tui$/, replacement: workspaceSourcePaths.tuiIndex }, ], }, - ssr: { resolve: { conditions: ["source"] } }, });