Skip to content

armgit / eve

Public Imported from GitHub
0

The Open Framework for Building Agents

fix(eve): target workspace agent from TUI add (#3442)

OwenKephartab5b8e973f7c
diff --git a/.changeset/fix-workspace-tui-add.md b/.changeset/fix-workspace-tui-add.md
new file mode 100644
index 000000000..33e63df44
--- /dev/null
+++ b/.changeset/fix-workspace-tui-add.md
@@ -0,0 +1,5 @@
+---
+"eve": patch
+---
+
+Install integrations selected through the development TUI's `/add` command into the active workspace agent while keeping shared environment, Vercel, dependency, and deployment effects at the workspace root.
diff --git a/packages/eve/src/cli/commands/integration-setup.test.ts b/packages/eve/src/cli/commands/integration-setup.test.ts
index bb9b98274..e57b4c2da 100644
--- a/packages/eve/src/cli/commands/integration-setup.test.ts
+++ b/packages/eve/src/cli/commands/integration-setup.test.ts
@@ -1,5 +1,6 @@
import { afterEach, describe, expect, it, vi } from "vitest";
+import type { EveProjectContext } from "#internal/project-context.js";
import { createFakePrompter } from "#internal/testing/fake-prompter.js";
import { InteractionRequired, select } from "#setup/ask.js";
import { ensureVercelProject } from "#setup/flows/ensure-vercel-project.js";
@@ -8,7 +9,14 @@ import { runIntegrationSetup } from "#setup/integrations/runner.js";
import { runIntegrationSetupCommand } from "./integration-setup.js";
import type { RegistryCommandLogger } from "./registry.js";
-const { isEveProject } = vi.hoisted(() => ({ isEveProject: vi.fn(async () => true) }));
+const { isEveProject, resolveEveProjectContext } = vi.hoisted(() => ({
+ isEveProject: vi.fn(async () => true),
+ resolveEveProjectContext: vi.fn(async (appRoot: string): Promise<EveProjectContext> => ({
+ appRoot,
+ environmentRoot: appRoot,
+ kind: "standalone",
+ })),
+}));
class SetupProcess {
connected = true;
@@ -27,6 +35,7 @@ vi.mock("#setup/scaffold/index.js", async (importOriginal) => ({
isEveProject,
}));
vi.mock("#setup/integrations/runner.js", () => ({ runIntegrationSetup: vi.fn() }));
+vi.mock("#internal/project-context.js", () => ({ resolveEveProjectContext }));
vi.mock("#setup/flows/ensure-vercel-project.js", () => ({ ensureVercelProject: vi.fn() }));
function logger(): RegistryCommandLogger & { errors: string[] } {
@@ -36,6 +45,7 @@ function logger(): RegistryCommandLogger & { errors: string[] } {
afterEach(() => {
process.exitCode = undefined;
+ vi.unstubAllEnvs();
vi.clearAllMocks();
});
@@ -78,6 +88,33 @@ describe("runIntegrationSetupCommand", () => {
expect(output.errors).toEqual([]);
});
+ it("rediscovers the shared project root from a workspace agent", async () => {
+ resolveEveProjectContext.mockResolvedValueOnce({
+ environmentRoot: "/workspace",
+ kind: "workspace-member",
+ member: { appRoot: "/workspace/agents/support", name: "support" },
+ workspace: {
+ root: "/workspace",
+ members: [{ appRoot: "/workspace/agents/support", name: "support" }],
+ },
+ });
+ vi.mocked(runIntegrationSetup).mockResolvedValue({
+ kind: "done",
+ completion: { facts: [] },
+ });
+
+ await runIntegrationSetupCommand(logger(), "/workspace/agents/support", "slack");
+
+ expect(runIntegrationSetup).toHaveBeenCalledWith(
+ "slack",
+ expect.objectContaining({
+ appRoot: "/workspace/agents/support",
+ projectRoot: "/workspace",
+ }),
+ undefined,
+ );
+ });
+
it("passes force to the integration runner", async () => {
vi.mocked(runIntegrationSetup).mockResolvedValue({
kind: "done",
diff --git a/packages/eve/src/cli/commands/integration-setup.ts b/packages/eve/src/cli/commands/integration-setup.ts
index dd78dcd80..12cab9cd4 100644
--- a/packages/eve/src/cli/commands/integration-setup.ts
+++ b/packages/eve/src/cli/commands/integration-setup.ts
@@ -7,6 +7,7 @@ import {
withPolicy,
} from "#setup/ask.js";
import { ensureVercelProject } from "#setup/flows/ensure-vercel-project.js";
+import { resolveEveProjectContext } from "#internal/project-context.js";
import { createHeadlessPrompter } from "#setup/headless.js";
import { SetupPrerequisiteRequired } from "#setup/integrations/shared/prerequisite.js";
import { createPrompter, type Prompter } from "#setup/prompter.js";
@@ -50,6 +51,7 @@ export async function runIntegrationSetupCommand(
});
try {
const nonInteractive = options.nonInteractive === true;
+ const projectRoot = (await resolveEveProjectContext(appRoot)).environmentRoot;
const prompter =
client?.prompter ??
dependencies.createPrompter?.() ??
@@ -61,6 +63,7 @@ export async function runIntegrationSetupCommand(
kind,
{
appRoot,
+ projectRoot,
prompter,
asker,
force: options.force,
@@ -68,7 +71,7 @@ export async function runIntegrationSetupCommand(
? undefined
: () =>
ensureVercelProject({
- appRoot,
+ appRoot: projectRoot,
prompter,
signal: client?.signal ?? options.signal,
}),
diff --git a/packages/eve/src/cli/commands/registry.test.ts b/packages/eve/src/cli/commands/registry.test.ts
index 40e4b2b35..22a8be5de 100644
--- a/packages/eve/src/cli/commands/registry.test.ts
+++ b/packages/eve/src/cli/commands/registry.test.ts
@@ -82,6 +82,11 @@ describe("registry commands", () => {
vi.fn(async () => new Response(JSON.stringify({ items: [] }))),
);
isEveProject.mockResolvedValue(true);
+ resolveEveProjectContext.mockImplementation(async (appRoot: string) => ({
+ appRoot,
+ environmentRoot: appRoot,
+ kind: "standalone",
+ }));
getRegistryItems.mockResolvedValue([]);
readFile.mockResolvedValue(
JSON.stringify({
@@ -144,7 +149,7 @@ describe("registry commands", () => {
it("reads registry configuration from a workspace package while targeting its agent", async () => {
const logger = createLogger();
const appRoot = "/project/agents/support";
- resolveEveProjectContext.mockResolvedValueOnce({
+ resolveEveProjectContext.mockResolvedValue({
environmentRoot: "/project",
kind: "workspace-member",
member: { appRoot, name: "support" },
@@ -153,9 +158,26 @@ describe("registry commands", () => {
members: [{ appRoot, name: "support" }],
},
});
- getRegistryItems.mockResolvedValue([{ name: "channel/teams", type: "registry:item" }]);
+ const runSetupCommand = vi.fn(async () => ({ kind: "completed" as const, facts: [] }));
+ getRegistryItems.mockResolvedValue([
+ {
+ name: "channel/teams",
+ type: "registry:item",
+ meta: {
+ eve: {
+ setup: [{ package: "eve", bin: "eve", args: ["integration", "setup", "teams"] }],
+ },
+ },
+ },
+ ]);
- await runAddCommand(logger, appRoot, "channel/teams", {});
+ await runAddCommand(
+ logger,
+ appRoot,
+ "channel/teams",
+ { yes: true },
+ { loadSetupCommandRunner: async () => runSetupCommand },
+ );
expect(readFile).toHaveBeenCalledWith("/project/package.json", "utf8");
expect(addRegistryItems).toHaveBeenCalledWith(["https://eve.dev/r/channel/teams.json"], {
@@ -164,6 +186,12 @@ describe("registry commands", () => {
overwrite: undefined,
silent: undefined,
});
+ expect(runSetupCommand).toHaveBeenCalledWith(
+ appRoot,
+ expect.any(Object),
+ "channel/teams",
+ expect.objectContaining({ prompter: expect.any(Object) }),
+ );
});
it("prepares declared pnpm build policy before installing", async () => {
@@ -413,7 +441,7 @@ describe("registry commands", () => {
it("rejects Web Chat before it can write into an agent workspace member", async () => {
const logger = createLogger();
const appRoot = "/project/agents/support";
- resolveEveProjectContext.mockResolvedValueOnce({
+ resolveEveProjectContext.mockResolvedValue({
environmentRoot: "/project",
kind: "workspace-member",
member: { appRoot, name: "support" },
diff --git a/packages/eve/src/cli/dev/tui/prompt-command-handler.test.ts b/packages/eve/src/cli/dev/tui/prompt-command-handler.test.ts
index b5a08ca85..a6d3b6400 100644
--- a/packages/eve/src/cli/dev/tui/prompt-command-handler.test.ts
+++ b/packages/eve/src/cli/dev/tui/prompt-command-handler.test.ts
@@ -29,6 +29,13 @@ const REMOTE_TARGET = {
serverUrl: "https://example.com/",
workspaceRoot: APP_ROOT,
} as const;
+const WORKSPACE_AGENT_ROOT = "/tmp/weather-workspace/agents/support";
+const WORKSPACE_TARGET = {
+ kind: "local",
+ serverUrl: "http://localhost:3000",
+ workspaceRoot: "/tmp/weather-workspace",
+ agentRoot: WORKSPACE_AGENT_ROOT,
+} as const;
function context(renderer: Partial<AgentTUIRenderer> = {}): PromptCommandHandlerContext {
return {
@@ -213,6 +220,36 @@ describe("createPromptCommandHandler", () => {
}
});
+ it("installs /add items into the selected workspace agent", async () => {
+ const runTuiSetupCommand = vi.fn(async () => ({
+ message: "Added Slack",
+ preserveFlowDiagnostics: true,
+ }));
+ vi.doMock("./setup-commands.js", () => ({
+ SETUP_FLOW_CONFIG: { add: { title: "Add to your agent", indicator: "pulse" } },
+ runTuiSetupCommand,
+ }));
+
+ try {
+ const handler = createPromptCommandHandler({ target: WORKSPACE_TARGET });
+ await handler.handle(
+ { type: "extension", name: "add", argument: "channel/slack" },
+ context({ setupFlow: setupFlowRenderer() }),
+ );
+
+ expect(runTuiSetupCommand).toHaveBeenCalledWith(
+ expect.objectContaining({
+ agentRoot: WORKSPACE_AGENT_ROOT,
+ appRoot: WORKSPACE_TARGET.workspaceRoot,
+ command: "add",
+ }),
+ );
+ } finally {
+ vi.doUnmock("./setup-commands.js");
+ vi.resetModules();
+ }
+ });
+
it.each([false, true])("holds login open through runtime refresh (failure: %s)", async (fail) => {
vi.doMock("./setup-commands.js", () => ({
SETUP_FLOW_CONFIG: { login: { title: "Connect a model", indicator: "pulse" } },
diff --git a/packages/eve/src/cli/dev/tui/setup-commands.test.ts b/packages/eve/src/cli/dev/tui/setup-commands.test.ts
index 8f258e54f..a0d17e9c1 100644
--- a/packages/eve/src/cli/dev/tui/setup-commands.test.ts
+++ b/packages/eve/src/cli/dev/tui/setup-commands.test.ts
@@ -456,7 +456,25 @@ describe("runTuiSetupCommand", () => {
if (result.kind === "done" && result.result.deployed === "production") {
expect(outcome.effect).toEqual({ kind: "deployed" });
}
- expect(runRegistryFlow).toHaveBeenCalledWith(expect.objectContaining({ appRoot: APP_ROOT }));
+ expect(runRegistryFlow).toHaveBeenCalledWith(
+ expect.objectContaining({ appRoot: APP_ROOT, installRoot: undefined }),
+ );
+ });
+
+ it("keeps shared setup at the workspace root while installing into its agent", async () => {
+ const runRegistryFlow = vi.fn<TuiSetupFlows["runRegistryFlow"]>(async () => registryResult());
+ await run({
+ command: "add",
+ agentRoot: "/tmp/project/agents/support",
+ flows: fakeFlows({ runRegistryFlow }),
+ });
+
+ expect(runRegistryFlow).toHaveBeenCalledWith(
+ expect.objectContaining({
+ appRoot: APP_ROOT,
+ installRoot: "/tmp/project/agents/support",
+ }),
+ );
});
it("reports completed items and skipped failures together", async () => {
diff --git a/packages/eve/src/cli/dev/tui/setup-commands.ts b/packages/eve/src/cli/dev/tui/setup-commands.ts
index ecf5c29fc..2b2036cfb 100644
--- a/packages/eve/src/cli/dev/tui/setup-commands.ts
+++ b/packages/eve/src/cli/dev/tui/setup-commands.ts
@@ -321,6 +321,7 @@ async function executeSetupCommand(
case "add": {
const flow = await flows.runRegistryFlow({
appRoot,
+ installRoot: input.agentRoot,
prompter,
signal,
initialAddress: input.initialRegistryAddress,
diff --git a/packages/eve/src/self-modification/setup.ts b/packages/eve/src/self-modification/setup.ts
index 98d576dca..d51c91ae3 100644
--- a/packages/eve/src/self-modification/setup.ts
+++ b/packages/eve/src/self-modification/setup.ts
@@ -141,6 +141,7 @@ export function parseGitHubRemote(remote: string): { owner: string; repo: string
export function defaultSelfModificationSetupOperations(
appRoot: string,
deps: SelfModificationSetupDependencies = defaultDependencies,
+ projectRoot: string = appRoot,
): SelfModificationSetupOperations {
const configPath = join(appRoot, SELF_MODIFICATION_CONFIG_PATH);
return {
@@ -181,7 +182,7 @@ export function defaultSelfModificationSetupOperations(
},
writeConfig: (source) => writeFile(configPath, source, "utf8"),
async findOrCreateConnector(name, project) {
- const connectors = await listGitHubConnectors(appRoot, project, deps.captureVercel);
+ const connectors = await listGitHubConnectors(projectRoot, project, deps.captureVercel);
const expected = `github/${name}`;
const existing = connectors.find((connector) => connector.uid === expected);
if (existing !== undefined) {
@@ -191,7 +192,7 @@ export function defaultSelfModificationSetupOperations(
}
const created = await deps.runVercelCaptureStdout(
["connect", "create", "github", "--name", name, "-F", "json", "--scope", project.orgId],
- { cwd: appRoot },
+ { cwd: projectRoot },
);
const connector = created.ok ? parseCreatedConnector(created.stdout) : undefined;
if (connector === undefined || !connector.startsWith("github/"))
@@ -212,7 +213,7 @@ export function defaultSelfModificationSetupOperations(
"--scope",
project.orgId,
],
- { cwd: appRoot },
+ { cwd: projectRoot },
);
if (!result.ok)
throw new Error(
diff --git a/packages/eve/src/setup/flows/registry.test.ts b/packages/eve/src/setup/flows/registry.test.ts
index 44dfcd516..a40fd3877 100644
--- a/packages/eve/src/setup/flows/registry.test.ts
+++ b/packages/eve/src/setup/flows/registry.test.ts
@@ -67,6 +67,25 @@ describe("runRegistryFlow", () => {
expect.any(Object),
);
});
+ it("installs into a workspace agent while keeping project effects at the workspace root", async () => {
+ const flow = deps();
+ const fake = createFakePrompter();
+ await runRegistryFlow({
+ appRoot: "/workspace",
+ installRoot: "/workspace/agents/support",
+ initialAddress: "connection/linear",
+ prompter: fake.prompter,
+ deps: flow,
+ });
+
+ expect(flow.installRegistryItem).toHaveBeenCalledWith(
+ "/workspace/agents/support",
+ "connection/linear",
+ expect.any(Object),
+ );
+ expect(flow.detectDeployment).not.toHaveBeenCalled();
+ });
+
it("searches one catalog and installs the chosen item without a review", async () => {
const flow = deps();
const fake = createFakePrompter({
diff --git a/packages/eve/src/setup/flows/registry.ts b/packages/eve/src/setup/flows/registry.ts
index b581a13e6..706cbc26e 100644
--- a/packages/eve/src/setup/flows/registry.ts
+++ b/packages/eve/src/setup/flows/registry.ts
@@ -39,7 +39,10 @@ function hasSettledOutcomes(
/** Searches the catalog and installs one selected item with its required setup. */
export async function runRegistryFlow(input: {
+ /** Project root for registry configuration, Vercel state, and deployment. */
appRoot: string;
+ /** Selected agent project where registry payloads and setup are applied. */
+ installRoot?: string;
prompter: Prompter;
signal?: AbortSignal;
/** Registry item supplied by `/add <item>`, installed directly. */
@@ -87,6 +90,7 @@ export async function runRegistryFlow(input: {
const installRegistryItem =
input.deps?.installRegistryItem ??
(await import("#cli/commands/registry.js")).installRegistryItem;
+ const installRoot = input.installRoot ?? input.appRoot;
const detectDeployment =
input.deps?.detectDeployment ??
(await import("#setup/project-resolution.js")).detectDeployment;
@@ -99,7 +103,7 @@ export async function runRegistryFlow(input: {
input.onItemStart?.(item, index, items.length);
try {
const install = (signal = input.signal) =>
- installRegistryItem(input.appRoot, item.address, {
+ installRegistryItem(installRoot, item.address, {
silent: true,
prompter: input.prompter,
signal,
diff --git a/packages/eve/src/setup/integrations/discord/setup.ts b/packages/eve/src/setup/integrations/discord/setup.ts
index fbf193882..e3b8ee544 100644
--- a/packages/eve/src/setup/integrations/discord/setup.ts
+++ b/packages/eve/src/setup/integrations/discord/setup.ts
@@ -123,7 +123,7 @@ export async function applyDiscordSetup(
botToken: plan.botToken,
log: context.presenter.log,
project: plan.project,
- projectRoot: context.appRoot,
+ projectRoot: context.projectRoot,
slug: plan.slug,
signal: context.signal,
});
diff --git a/packages/eve/src/setup/integrations/file-memory/setup.ts b/packages/eve/src/setup/integrations/file-memory/setup.ts
index 3e3ededa4..9f196439a 100644
--- a/packages/eve/src/setup/integrations/file-memory/setup.ts
+++ b/packages/eve/src/setup/integrations/file-memory/setup.ts
@@ -26,7 +26,7 @@ export async function prepareFileMemorySetup(
): Promise<FileMemoryBlobPlan> {
const project = await context.resolveVercelProject("file memory");
return await deps.prepareBlob({
- appRoot: context.appRoot,
+ appRoot: context.projectRoot,
project,
signal: context.signal,
});
@@ -50,7 +50,7 @@ export async function applyFileMemorySetup(
if (plan.regionWarning !== undefined) context.presenter.log.warning(plan.regionWarning);
const result = await deps.applyBlob({
- appRoot: context.appRoot,
+ appRoot: context.projectRoot,
log: context.presenter.log,
plan,
signal: context.signal,
diff --git a/packages/eve/src/setup/integrations/github/setup.ts b/packages/eve/src/setup/integrations/github/setup.ts
index a90fe2537..cb3ce6cf4 100644
--- a/packages/eve/src/setup/integrations/github/setup.ts
+++ b/packages/eve/src/setup/integrations/github/setup.ts
@@ -121,7 +121,7 @@ export async function applyGitHubSetup(
log: context.presenter.log,
events: plan.events,
project: plan.project,
- projectRoot: context.appRoot,
+ projectRoot: context.projectRoot,
slug: plan.slug,
signal: context.signal,
});
diff --git a/packages/eve/src/setup/integrations/linear/setup.ts b/packages/eve/src/setup/integrations/linear/setup.ts
index 5e3e6d452..4d4f93c30 100644
--- a/packages/eve/src/setup/integrations/linear/setup.ts
+++ b/packages/eve/src/setup/integrations/linear/setup.ts
@@ -77,7 +77,7 @@ export async function prepareLinearSetup(
);
const existing = await deps.findConnector({
project,
- projectRoot: context.appRoot,
+ projectRoot: context.projectRoot,
slug,
signal: context.signal,
});
@@ -121,14 +121,14 @@ export async function applyLinearSetup(
connector: plan.connector.connector,
log: context.presenter.log,
project: plan.project,
- projectRoot: context.appRoot,
+ projectRoot: context.projectRoot,
signal: context.signal,
}),
plan.connector.connector)
: await deps.provisionConnector({
log: context.presenter.log,
project: plan.project,
- projectRoot: context.appRoot,
+ projectRoot: context.projectRoot,
slug: plan.connector.slug,
signal: context.signal,
});
diff --git a/packages/eve/src/setup/integrations/linq/setup.ts b/packages/eve/src/setup/integrations/linq/setup.ts
index a09d592a5..0f369e516 100644
--- a/packages/eve/src/setup/integrations/linq/setup.ts
+++ b/packages/eve/src/setup/integrations/linq/setup.ts
@@ -176,7 +176,7 @@ export async function applyLinqSetup(plan: LinqSetupPlan, context: SetupApplyCon
const connectorInput: Parameters<typeof provisionLinqConnector>[0] = {
log: context.presenter.log,
project: plan.project!,
- projectRoot: context.appRoot,
+ projectRoot: context.projectRoot,
slug: plan.connectorSlug!,
signal: context.signal,
};
@@ -190,7 +190,7 @@ export async function applyLinqSetup(plan: LinqSetupPlan, context: SetupApplyCon
context.presenter.note(phoneNumber, "Text your agent", { tone: "success" });
}
} else {
- await appendEnv(join(context.appRoot, ".env.local"), {
+ await appendEnv(join(context.projectRoot, ".env.local"), {
LINQ_API_KEY: plan.apiKey!,
LINQ_WEBHOOK_SECRET: plan.signingSecret!,
});
diff --git a/packages/eve/src/setup/integrations/photon/setup-flow.ts b/packages/eve/src/setup/integrations/photon/setup-flow.ts
index 39fdafbde..51f7d1595 100644
--- a/packages/eve/src/setup/integrations/photon/setup-flow.ts
+++ b/packages/eve/src/setup/integrations/photon/setup-flow.ts
@@ -229,7 +229,7 @@ export async function applyPhotonSetup(
credentials: managedProject,
log: context.presenter.log,
project: plan.vercelProject!,
- projectRoot: context.appRoot,
+ projectRoot: context.projectRoot,
slug,
signal: context.signal,
});
@@ -237,7 +237,7 @@ export async function applyPhotonSetup(
force: context.force,
});
} else {
- await deps.appendEnv(join(context.appRoot, ".env.local"), {
+ await deps.appendEnv(join(context.projectRoot, ".env.local"), {
IMESSAGE_PROJECT_ID: managedProject.projectId,
IMESSAGE_PROJECT_SECRET: managedProject.projectSecret,
});
diff --git a/packages/eve/src/setup/integrations/runner.ts b/packages/eve/src/setup/integrations/runner.ts
index 02c803f3e..99eca0b48 100644
--- a/packages/eve/src/setup/integrations/runner.ts
+++ b/packages/eve/src/setup/integrations/runner.ts
@@ -18,7 +18,10 @@ import type { IntegrationSetupResult, SetupExternalAction } from "./types.js";
/** Inputs shared by every registry-owned integration setup flow. */
export interface RunIntegrationSetupOptions {
+ /** Selected agent project where authored files are changed. */
appRoot: string;
+ /** Project root for shared dependencies, Vercel links, and environment files. */
+ projectRoot?: string;
prompter: Prompter;
/** Defaults to the interactive adapter; agent drivers inject an answer-backed asker. */
asker?: Asker;
@@ -52,11 +55,12 @@ export async function runIntegrationSetup(
deps: IntegrationSetupRunnerDeps = defaultDeps,
): Promise<IntegrationSetupResult> {
const integration = setupIntegration(kind);
+ const projectRoot = options.projectRoot ?? options.appRoot;
options.prompter.intro(`Set up ${integration.label}`, integration.hint);
options.prompter.log.message("Checking Vercel setup...");
const [deployment, authStatus] = await Promise.all([
- deps.detectDeployment(options.appRoot, { signal: options.signal }),
- deps.getVercelAuthStatus(options.appRoot, { signal: options.signal }),
+ deps.detectDeployment(projectRoot, { signal: options.signal }),
+ deps.getVercelAuthStatus(projectRoot, { signal: options.signal }),
]);
const project = projectResolutionFromDeployment(deployment);
const environment = integrationSetupEnvironment(authStatus, project);
@@ -67,6 +71,7 @@ export async function runIntegrationSetup(
return integration.run(
createSetupContexts({
appRoot: options.appRoot,
+ projectRoot,
asker: options.asker ?? interactiveAsker(options.prompter),
environment,
prompter: options.prompter,
@@ -74,7 +79,7 @@ export async function runIntegrationSetup(
options.resolveVercelProject ??
((integration) =>
resolveIntegrationVercelProject({
- appRoot: options.appRoot,
+ appRoot: projectRoot,
integration,
signal: options.signal,
})),
diff --git a/packages/eve/src/setup/integrations/self-modification/setup.ts b/packages/eve/src/setup/integrations/self-modification/setup.ts
index bd1675cf7..ad82633b8 100644
--- a/packages/eve/src/setup/integrations/self-modification/setup.ts
+++ b/packages/eve/src/setup/integrations/self-modification/setup.ts
@@ -38,6 +38,8 @@ export async function prepareSelfModificationSetup(
context: SetupPrepareContext,
operations: SelfModificationSetupOperations = defaultSelfModificationSetupOperations(
context.appRoot,
+ undefined,
+ context.projectRoot,
),
): Promise<SelfModificationSetupPlan> {
const existing = await operations.readConfig();
@@ -148,6 +150,8 @@ export async function applySelfModificationSetup(
context: SetupApplyContext,
operations: SelfModificationSetupOperations = defaultSelfModificationSetupOperations(
context.appRoot,
+ undefined,
+ context.projectRoot,
),
) {
if (plan.kind === "authored") {
@@ -184,6 +188,8 @@ export async function prepareLocalSelfModificationSetup(
context: SetupPrepareContext,
operations: SelfModificationSetupOperations = defaultSelfModificationSetupOperations(
context.appRoot,
+ undefined,
+ context.projectRoot,
),
): Promise<SelfModificationSetupPlan> {
const existing = await operations.readConfig();
diff --git a/packages/eve/src/setup/integrations/shared/ui.ts b/packages/eve/src/setup/integrations/shared/ui.ts
index 745bca10a..700357036 100644
--- a/packages/eve/src/setup/integrations/shared/ui.ts
+++ b/packages/eve/src/setup/integrations/shared/ui.ts
@@ -33,6 +33,7 @@ export function createSetupPresenter(
export function createSetupContexts(input: {
appRoot: string;
+ projectRoot?: string;
asker: Asker;
environment: SetupPrepareContext["environment"];
prompter: Prompter;
@@ -46,7 +47,11 @@ export function createSetupContexts(input: {
}) => SetupExternalAction;
}): { prepare: SetupPrepareContext; apply: SetupApplyContext } {
const presenter = createSetupPresenter(input.prompter, input.beginExternalAction);
- const apply: SetupApplyContext = { appRoot: input.appRoot, presenter };
+ const apply: SetupApplyContext = {
+ appRoot: input.appRoot,
+ projectRoot: input.projectRoot ?? input.appRoot,
+ presenter,
+ };
if (input.signal !== undefined) apply.signal = input.signal;
if (input.force !== undefined) apply.force = input.force;
return {
diff --git a/packages/eve/src/setup/integrations/shopify/setup.ts b/packages/eve/src/setup/integrations/shopify/setup.ts
index 4c9a2db90..04695e86a 100644
--- a/packages/eve/src/setup/integrations/shopify/setup.ts
+++ b/packages/eve/src/setup/integrations/shopify/setup.ts
@@ -64,7 +64,7 @@ export async function applyShopifySetup(
deps: ShopifySetupDeps = defaultDeps,
) {
context.presenter.log.message("Scaffolding Shopify UCP channel and storefront environment...");
- await deps.appendEnv(join(context.appRoot, ".env.local"), {
+ await deps.appendEnv(join(context.projectRoot, ".env.local"), {
SHOPIFY_STORE_DOMAIN: plan.storeDomain,
});
await deps.writeTextFile(
diff --git a/packages/eve/src/setup/integrations/slack/setup.ts b/packages/eve/src/setup/integrations/slack/setup.ts
index 219b8e1b9..22628731d 100644
--- a/packages/eve/src/setup/integrations/slack/setup.ts
+++ b/packages/eve/src/setup/integrations/slack/setup.ts
@@ -159,7 +159,7 @@ export async function prepareSlackSetup(
if (project.projectId.length === 0) throw new Error(SLACK_REQUIRES_VERCEL);
const lookup = await deps.inspectConnectors(
context.presenter.log,
- context.appRoot,
+ context.projectRoot,
slug,
context.signal,
);
@@ -178,6 +178,7 @@ export async function applySlackSetup(
if (plan.credentials === "environment") {
const result = await deps.ensureChannel({
projectRoot: context.appRoot,
+ environmentRoot: context.projectRoot,
kind: "slack",
slackConnectorSlug: plan.slug,
slackCredentials: "environment",
@@ -194,7 +195,7 @@ export async function applySlackSetup(
}
const result = await deps.provisionSlackbot(
context.presenter.log,
- context.appRoot,
+ context.projectRoot,
plan.slug,
undefined,
{
@@ -220,7 +221,7 @@ export async function applySlackSetup(
if (channel.action === "skipped") {
const ready = await deps.reconcileSlackUid(
context.presenter.log,
- context.appRoot,
+ context.projectRoot,
result,
`slack/${plan.slug}`,
);
@@ -230,7 +231,7 @@ export async function applySlackSetup(
await installScaffoldDependencies({
changed: channel.packageJsonUpdated.length > 0,
log: context.presenter.log,
- projectPath: context.appRoot,
+ projectPath: context.projectRoot,
signal: context.signal,
});
return {
diff --git a/packages/eve/src/setup/integrations/teams/setup.ts b/packages/eve/src/setup/integrations/teams/setup.ts
index 7977e9f7f..9c59ac5bc 100644
--- a/packages/eve/src/setup/integrations/teams/setup.ts
+++ b/packages/eve/src/setup/integrations/teams/setup.ts
@@ -63,7 +63,7 @@ export async function applyTeamsSetup(
const connector = await deps.provisionConnector({
...plan,
log: context.presenter.log,
- projectRoot: context.appRoot,
+ projectRoot: context.projectRoot,
signal: context.signal,
deps,
});
diff --git a/packages/eve/src/setup/integrations/types.ts b/packages/eve/src/setup/integrations/types.ts
index 64c38f310..f41c06fcc 100644
--- a/packages/eve/src/setup/integrations/types.ts
+++ b/packages/eve/src/setup/integrations/types.ts
@@ -20,7 +20,10 @@ export type SetupPresenter = Pick<Prompter, "log" | "note"> & {
};
export interface SetupPrepareContext {
+ /** Selected agent project where authored files are changed. */
readonly appRoot: string;
+ /** Project root for shared dependencies, Vercel links, and environment files. */
+ readonly projectRoot: string;
readonly asker: Asker;
readonly environment: IntegrationSetupEnvironment;
readonly presenter: SetupPresenter;
@@ -30,7 +33,10 @@ export interface SetupPrepareContext {
}
export interface SetupApplyContext {
+ /** Selected agent project where authored files are changed. */
readonly appRoot: string;
+ /** Project root for shared dependencies, Vercel links, and environment files. */
+ readonly projectRoot: string;
readonly presenter: SetupPresenter;
signal?: AbortSignal;
force?: boolean;
diff --git a/packages/eve/src/setup/scaffold/index.integration.test.ts b/packages/eve/src/setup/scaffold/index.integration.test.ts
index 148cbbe2e..f5a93f56b 100644
--- a/packages/eve/src/setup/scaffold/index.integration.test.ts
+++ b/packages/eve/src/setup/scaffold/index.integration.test.ts
@@ -117,6 +117,30 @@ describe("ensureChannel", () => {
]);
});
+ test("writes a workspace agent's portable Slack environment example at the shared root", async () => {
+ const environmentRoot = await createTempDir();
+ const projectRoot = join(environmentRoot, "agents", "support");
+ await mkdir(join(projectRoot, "agent"), { recursive: true });
+ await writeFile(join(projectRoot, "package.json"), "{}\n", "utf8");
+
+ await ensureChannel({
+ projectRoot,
+ environmentRoot,
+ kind: "slack",
+ slackCredentials: "environment",
+ });
+
+ await expect(readFile(join(projectRoot, "agent/channels/slack.ts"), "utf8")).resolves.toContain(
+ "slackChannel",
+ );
+ await expect(readFile(join(environmentRoot, ".env.example"), "utf8")).resolves.toBe(
+ "\nSLACK_BOT_TOKEN=\nSLACK_SIGNING_SECRET=\n",
+ );
+ await expect(readFile(join(projectRoot, ".env.example"), "utf8")).rejects.toMatchObject({
+ code: "ENOENT",
+ });
+ });
+
test("rolls back the environment example when portable Slack scaffolding fails", async () => {
const projectRoot = await createTempDir();
await mkdir(join(projectRoot, "agent/channels/slack.ts"), { recursive: true });
diff --git a/packages/eve/src/setup/scaffold/update/channels.ts b/packages/eve/src/setup/scaffold/update/channels.ts
index be459127d..55d16faf5 100644
--- a/packages/eve/src/setup/scaffold/update/channels.ts
+++ b/packages/eve/src/setup/scaffold/update/channels.ts
@@ -427,6 +427,8 @@ async function findCompetingNextConfigFiles(projectRoot: string): Promise<string
export interface EnsureChannelOptions {
projectRoot: string;
+ /** Root for environment files shared by workspace agents. */
+ environmentRoot?: string;
kind: ChannelKind;
/** Manager that owns generated project configuration. Defaults to pnpm. */
packageManager?: PackageManagerKind;
@@ -613,7 +615,7 @@ async function ensureSlackChannel(
template = buildSlackConnectTemplate(connectorUid);
} else {
template = SLACK_ENV_TEMPLATE;
- const envExamplePath = join(options.projectRoot, ".env.example");
+ const envExamplePath = join(options.environmentRoot ?? options.projectRoot, ".env.example");
const envExampleExisted = await pathExists(envExamplePath);
envExampleRollback = {
path: envExamplePath,