Skip to content

armgit / eve

Public Imported from GitHub
0

The Open Framework for Building Agents

fix(eve): update `/channels` flow to correctly reconcile Vercel project settings Signed-off-by: owenkephart <[email protected]> (#868)

OwenKephartf7c69b1a2ad0
diff --git a/.changeset/reconcile-framework-preset-on-every-deploy.md b/.changeset/reconcile-framework-preset-on-every-deploy.md
new file mode 100644
index 000000000..3751b230b
--- /dev/null
+++ b/.changeset/reconcile-framework-preset-on-every-deploy.md
@@ -0,0 +1,5 @@
+---
+"eve": patch
+---
+
+The Vercel Framework Preset is now reconciled with the host framework on disk when running `/deploy` via the TUI.
diff --git a/packages/eve/src/cli/commands/channels.integration.test.ts b/packages/eve/src/cli/commands/channels.integration.test.ts
index 6cdfa2e36..bae1c62fb 100644
--- a/packages/eve/src/cli/commands/channels.integration.test.ts
+++ b/packages/eve/src/cli/commands/channels.integration.test.ts
@@ -133,6 +133,7 @@ function createDeployProjectDeps(probe: DeploymentInfo = DEPLOYED) {
async () => true,
),
detectDeployment: vi.fn<DeployProjectDeps["detectDeployment"]>(async () => probe),
+ syncHostFrameworkPreset: vi.fn<DeployProjectDeps["syncHostFrameworkPreset"]>(async () => {}),
};
}
diff --git a/packages/eve/src/cli/commands/channels.ts b/packages/eve/src/cli/commands/channels.ts
index 2e021f7e4..abfb502ac 100644
--- a/packages/eve/src/cli/commands/channels.ts
+++ b/packages/eve/src/cli/commands/channels.ts
@@ -3,7 +3,6 @@ import { isEveProject, listAuthoredChannels, type ChannelKind } from "#setup/sca
import { interactiveAsker } from "#setup/ask.js";
import { addChannels, type AddChannelsDeps } from "#setup/boxes/add-channels.js";
import { deployProject, type DeployProjectDeps } from "#setup/boxes/deploy-project.js";
-import { reconcileHostFrameworkPreset } from "#setup/boxes/reconcile-host-framework-preset.js";
import { selectChannels } from "#setup/boxes/select-channels.js";
import {
detectDeployment,
@@ -130,10 +129,6 @@ async function runAddChannelsFlow(
ensureLinkedProject: "interactive-vercel-link",
deps: dependencies.addChannelsDeps,
}),
- // A web (Next.js) channel added to an already-linked eve project may leave
- // the project's Vercel Framework Preset on `eve`; switch it before deploying
- // so the host app actually builds.
- reconcileHostFrameworkPreset({ prompter }),
deployProject({
prompter,
ensureLinkedProject: "interactive-vercel-link",
diff --git a/packages/eve/src/cli/commands/deploy.integration.test.ts b/packages/eve/src/cli/commands/deploy.integration.test.ts
index b11e67e29..3856f684d 100644
--- a/packages/eve/src/cli/commands/deploy.integration.test.ts
+++ b/packages/eve/src/cli/commands/deploy.integration.test.ts
@@ -54,6 +54,7 @@ function createDeployProjectDeps() {
async () => true,
),
detectDeployment: vi.fn<DeployProjectDeps["detectDeployment"]>(async () => DEPLOYED),
+ syncHostFrameworkPreset: vi.fn<DeployProjectDeps["syncHostFrameworkPreset"]>(async () => {}),
};
}
diff --git a/packages/eve/src/setup/boxes/deploy-project.test.ts b/packages/eve/src/setup/boxes/deploy-project.test.ts
index 9df3b7343..6f59287e3 100644
--- a/packages/eve/src/setup/boxes/deploy-project.test.ts
+++ b/packages/eve/src/setup/boxes/deploy-project.test.ts
@@ -34,6 +34,7 @@ function createDeps() {
async () => true,
),
detectDeployment: vi.fn<DeployProjectDeps["detectDeployment"]>(async () => DEPLOYED),
+ syncHostFrameworkPreset: vi.fn<DeployProjectDeps["syncHostFrameworkPreset"]>(async () => {}),
};
}
@@ -170,6 +171,50 @@ describe("deployProject box", () => {
expect(installOrder).toBeLessThan(deployOrder);
});
+ it("reconciles the host framework preset for the linked project before deploying", async () => {
+ const deps = createDeps();
+ const box = headlessBox({ deps });
+
+ await runHeadless([box], pendingState(), silentSink);
+
+ expect(deps.syncHostFrameworkPreset).toHaveBeenCalledWith(
+ expect.anything(),
+ "/tmp/project",
+ expect.anything(),
+ expect.anything(),
+ );
+ // The preset must be aligned before the deploy subprocess so Vercel builds
+ // the right framework, and only after the project is linked.
+ const reconcileOrder = deps.syncHostFrameworkPreset.mock.invocationCallOrder[0]!;
+ const deployOrder = deps.runVercel.mock.invocationCallOrder[0]!;
+ expect(reconcileOrder).toBeLessThan(deployOrder);
+ });
+
+ it("reconciles the preset only after linking a previously unlinked directory", async () => {
+ const deps = createDeps();
+ const box = deployProject({ prompter: createPrompter(), deps });
+ const state = pendingState();
+ state.project = { kind: "unresolved" };
+
+ await runInteractive([box], state, silentSink);
+
+ // A stale preset can only be read once the directory is linked, so the
+ // reconcile must follow the interactive `vercel link`.
+ const linkOrder = deps.runVercel.mock.invocationCallOrder[0]!;
+ const reconcileOrder = deps.syncHostFrameworkPreset.mock.invocationCallOrder[0]!;
+ expect(deps.runVercel.mock.calls[0]?.[0]).toEqual(["link"]);
+ expect(linkOrder).toBeLessThan(reconcileOrder);
+ });
+
+ it("does not reconcile the preset when the deploy is skipped", async () => {
+ const deps = createDeps();
+ const box = headlessBox({ deps, skip: true });
+
+ await runHeadless([box], pendingState(), silentSink);
+
+ expect(deps.syncHostFrameworkPreset).not.toHaveBeenCalled();
+ });
+
it("throws the vercel-link human action headlessly when no project resolution exists", async () => {
const deps = createDeps();
const box = headlessBox({ deps });
diff --git a/packages/eve/src/setup/boxes/deploy-project.ts b/packages/eve/src/setup/boxes/deploy-project.ts
index 3d05bb2da..b50343b71 100644
--- a/packages/eve/src/setup/boxes/deploy-project.ts
+++ b/packages/eve/src/setup/boxes/deploy-project.ts
@@ -14,6 +14,7 @@ import {
} from "../project-resolution.js";
import { hasVercelProject, requireProjectPath, type SetupState } from "../state.js";
import type { SetupBox } from "../step.js";
+import { syncHostFrameworkPreset } from "../vercel-project-framework.js";
const VERCEL_DEPLOY_ENV: Readonly<Record<string, string>> = {
VERCEL_USE_EXPERIMENTAL_FRAMEWORKS: "1",
@@ -25,6 +26,7 @@ export interface DeployProjectDeps {
detectPackageManager: typeof detectPackageManager;
runPackageManagerInstall: typeof runPackageManagerInstall;
detectDeployment: typeof detectDeployment;
+ syncHostFrameworkPreset: typeof syncHostFrameworkPreset;
}
export interface DeployProjectOptions {
@@ -67,13 +69,21 @@ export interface DeployProjectPayload {
/**
* THE DEPLOY BOX. Owns the post-channel `vercel deploy --prod` once channel
* setup has marked deployment work pending: dependency install (once per
- * state), the production deploy, the env pull, and the deployment probe.
+ * state), aligning the Vercel Framework Preset with the host framework on disk,
+ * the production deploy, the env pull, and the deployment probe.
*
* The project was linked up front by the link box, so `perform` reuses
* `state.project` and never triggers a second interactive `vercel link` (the
* #1020 deadlock). When no resolution exists (no link box ran, e.g. the
* `eve channels add` composition), it falls back to the interactive bare
* `vercel link`, or throws {@link HumanActionRequiredError} headlessly.
+ *
+ * Once the project is linked, {@link syncHostFrameworkPreset} runs before the
+ * deploy so a project that gained a host framework (e.g. a web channel) builds
+ * the host app instead of the stale `eve` agent preset. It is a no-op for a
+ * plain agent (no host framework on disk) or an already-correct preset, so
+ * every deploy surface — `eve channels add`, the dev TUI `/deploy`, onboarding —
+ * gets the reconcile without composing a separate box.
*/
export function deployProject(
options: DeployProjectOptions,
@@ -83,6 +93,7 @@ export function deployProject(
detectPackageManager,
runPackageManagerInstall,
detectDeployment,
+ syncHostFrameworkPreset,
};
return {
@@ -130,6 +141,18 @@ export function deployProject(
}
}
+ // The directory is now linked, so align the project's Framework Preset with
+ // the host framework on disk before deploying — deploy is deliberately the
+ // only place this server-side setting is touched, so a local `/channels` add
+ // never mutates deployed settings unless the user is actively deploying.
+ // Best-effort and a no-op for a plain agent or an already-correct preset.
+ await deps.syncHostFrameworkPreset(
+ options.prompter,
+ projectPath,
+ onOutput,
+ signal ? { signal } : {},
+ );
+
if (!state.deploymentDependenciesInstalled) {
const packageManager = await deps.detectPackageManager(projectPath);
const installed = await withPhase(
diff --git a/packages/eve/src/setup/boxes/reconcile-host-framework-preset.test.ts b/packages/eve/src/setup/boxes/reconcile-host-framework-preset.test.ts
deleted file mode 100644
index 7a65c79c9..000000000
--- a/packages/eve/src/setup/boxes/reconcile-host-framework-preset.test.ts
+++ /dev/null
@@ -1,100 +0,0 @@
-import { describe, expect, it, vi } from "vitest";
-
-import { createFakePrompter } from "#internal/testing/fake-prompter.js";
-
-import type { Prompter } from "../prompter.js";
-import { runHeadless } from "../runner.js";
-import { createDefaultSetupState, type SetupState } from "../state.js";
-import type { OutputSink } from "../step.js";
-import {
- reconcileHostFrameworkPreset,
- type ReconcileHostFrameworkPresetDeps,
-} from "./reconcile-host-framework-preset.js";
-
-const silentSink: OutputSink = { write: () => {} };
-
-function createPrompter(): Prompter {
- return createFakePrompter().prompter;
-}
-
-function fakeDeps(): ReconcileHostFrameworkPresetDeps {
- return { syncHostFrameworkPreset: vi.fn(async () => {}) };
-}
-
-function stateWith(overrides: Partial<SetupState>): SetupState {
- return {
- ...createDefaultSetupState(),
- projectPath: { kind: "resolved", inPlace: true, path: "/tmp/project" },
- deploymentPending: true,
- ...overrides,
- };
-}
-
-describe("reconcileHostFrameworkPreset box", () => {
- it("reconciles the preset when a web channel targets an already-linked project", async () => {
- const prompter = createPrompter();
- const deps = fakeDeps();
- const state = stateWith({
- channelSelection: ["web"],
- project: { kind: "linked", projectId: "prj_demo" },
- });
-
- await runHeadless([reconcileHostFrameworkPreset({ prompter, deps })], state, silentSink);
-
- expect(deps.syncHostFrameworkPreset).toHaveBeenCalledWith(
- prompter,
- "/tmp/project",
- expect.anything(),
- { signal: undefined },
- );
- });
-
- it("skips when no web channel is selected", async () => {
- const deps = fakeDeps();
- const state = stateWith({
- channelSelection: ["slack"],
- project: { kind: "linked", projectId: "prj_demo" },
- });
-
- await runHeadless(
- [reconcileHostFrameworkPreset({ prompter: createPrompter(), deps })],
- state,
- silentSink,
- );
-
- expect(deps.syncHostFrameworkPreset).not.toHaveBeenCalled();
- });
-
- it("skips when the project is not yet linked", async () => {
- const deps = fakeDeps();
- const state = stateWith({
- channelSelection: ["web"],
- project: { kind: "unresolved" },
- });
-
- await runHeadless(
- [reconcileHostFrameworkPreset({ prompter: createPrompter(), deps })],
- state,
- silentSink,
- );
-
- expect(deps.syncHostFrameworkPreset).not.toHaveBeenCalled();
- });
-
- it("skips when no deploy will follow (deploymentPending is false)", async () => {
- const deps = fakeDeps();
- const state = stateWith({
- channelSelection: ["web"],
- project: { kind: "linked", projectId: "prj_demo" },
- deploymentPending: false,
- });
-
- await runHeadless(
- [reconcileHostFrameworkPreset({ prompter: createPrompter(), deps })],
- state,
- silentSink,
- );
-
- expect(deps.syncHostFrameworkPreset).not.toHaveBeenCalled();
- });
-});
diff --git a/packages/eve/src/setup/boxes/reconcile-host-framework-preset.ts b/packages/eve/src/setup/boxes/reconcile-host-framework-preset.ts
deleted file mode 100644
index 2e3f691a7..000000000
--- a/packages/eve/src/setup/boxes/reconcile-host-framework-preset.ts
+++ /dev/null
@@ -1,66 +0,0 @@
-import { createPromptCommandOutput } from "#setup/cli/index.js";
-
-import { isProjectResolved } from "../project-resolution.js";
-import type { Prompter } from "../prompter.js";
-import { requireProjectPath, type SetupState } from "../state.js";
-import type { SetupBox } from "../step.js";
-import { syncHostFrameworkPreset } from "../vercel-project-framework.js";
-
-/** Injected for tests; defaults to the real framework-preset reconciliation. */
-export interface ReconcileHostFrameworkPresetDeps {
- syncHostFrameworkPreset: typeof syncHostFrameworkPreset;
-}
-
-export interface ReconcileHostFrameworkPresetOptions {
- /** Streams reconciliation progress and the applied-change note. */
- prompter: Prompter;
- deps?: ReconcileHostFrameworkPresetDeps;
-}
-
-/**
- * Aligns an already-linked Vercel project's Framework Preset with a newly-added
- * web (Next.js) channel before the deploy box runs. A project created as a
- * standalone agent keeps the `eve` preset, which would build the agent instead
- * of the host app; the command already deploys on the user's behalf, so this
- * corrects the preset directly (no confirmation) and notes the change.
- *
- * Runs only for an already-linked project — an unlinked directory links later
- * inside the deploy box, where a fresh `vercel link` detects the framework. All
- * effects live in {@link syncHostFrameworkPreset}, a no-op when the preset
- * already matches.
- */
-export function reconcileHostFrameworkPreset(
- options: ReconcileHostFrameworkPresetOptions,
-): SetupBox<SetupState, null, null> {
- const deps = options.deps ?? { syncHostFrameworkPreset };
-
- return {
- id: "reconcile-host-framework-preset",
-
- shouldRun(state) {
- // Only reconcile ahead of a deploy this run: a stale preset only bites the
- // deployment, and the deploy box gates on `deploymentPending` too, so a
- // no-op channel add must not touch the Vercel setting.
- return (
- state.deploymentPending &&
- state.channelSelection.includes("web") &&
- isProjectResolved(state.project)
- );
- },
-
- async gather(): Promise<null> {
- return null;
- },
-
- async perform({ state, signal }): Promise<null> {
- const projectRoot = requireProjectPath(state);
- const onOutput = createPromptCommandOutput(options.prompter.log);
- await deps.syncHostFrameworkPreset(options.prompter, projectRoot, onOutput, { signal });
- return null;
- },
-
- apply(state): SetupState {
- return state;
- },
- };
-}
diff --git a/packages/eve/src/setup/flows/deploy.test.ts b/packages/eve/src/setup/flows/deploy.test.ts
index ad97991e0..047cfcf80 100644
--- a/packages/eve/src/setup/flows/deploy.test.ts
+++ b/packages/eve/src/setup/flows/deploy.test.ts
@@ -29,6 +29,7 @@ function createDeployProjectDeps(probe: DeploymentInfo = DEPLOYED) {
async () => true,
),
detectDeployment: vi.fn<DeployProjectDeps["detectDeployment"]>(async () => probe),
+ syncHostFrameworkPreset: vi.fn<DeployProjectDeps["syncHostFrameworkPreset"]>(async () => {}),
};
}
diff --git a/packages/eve/src/setup/vercel-project-framework.ts b/packages/eve/src/setup/vercel-project-framework.ts
index 43f6d3a13..996bfad8b 100644
--- a/packages/eve/src/setup/vercel-project-framework.ts
+++ b/packages/eve/src/setup/vercel-project-framework.ts
@@ -1,4 +1,4 @@
-import { createPromptCommandOutput } from "#setup/cli/index.js";
+import { type ChannelSetupLog, createPromptCommandOutput } from "#setup/cli/index.js";
import { captureVercel } from "#setup/primitives/index.js";
import type { Dirent } from "node:fs";
import * as fs from "node:fs/promises";
@@ -243,7 +243,7 @@ function describeError(error: unknown): string {
* is a no-op; a Vercel API failure warns rather than aborting the deploy.
*/
export async function syncHostFrameworkPreset(
- prompter: Prompter,
+ prompter: { log: Pick<ChannelSetupLog, "info" | "warning"> },
projectRoot: string,
onOutput: ReturnType<typeof createPromptCommandOutput>,
options: VercelProjectOperationOptions,