The Open Framework for Building Agents
feat(eve): consolidate Vercel auth into /vc:login with team-scope fallback (#261)
Rui1345f61aa193
diff --git a/.changeset/remote-auth-owner-id.md b/.changeset/remote-auth-owner-id.mdindex 4b57adae7..674fdfeec 100644--- a/.changeset/remote-auth-owner-id.md+++ b/.changeset/remote-auth-owner-id.md@@ -2,4 +2,4 @@"eve": patch----Fixed `/vc:auth` rejecting a freshly selected Vercel project with "The local Vercel OIDC token does not match the resolved deployment: owner_id." The verified deployment now takes its owner id from Vercel's response instead of the team slug used to scope the lookup, so it matches the OIDC token's `owner_id` claim.+Fixed remote `/vc:login` rejecting a freshly resolved Vercel project with "The local Vercel OIDC token does not match the resolved deployment: owner_id." The verified deployment now takes its owner id from Vercel's response instead of the team slug used to scope the lookup, so it matches the OIDC token's `owner_id` claim.diff --git a/.changeset/remote-auth-resolve-from-url.md b/.changeset/remote-auth-resolve-from-url.mdindex e0f1ae7de..28ab1db36 100644--- a/.changeset/remote-auth-resolve-from-url.md+++ b/.changeset/remote-auth-resolve-from-url.md@@ -2,4 +2,4 @@"eve": patch----`/vc:auth` now resolves the target Vercel project and owning team directly from the deployment URL instead of prompting you to pick a team and project. You can authenticate any deployment you can access — including custom domains and aliases — without a picker, and when access is denied (for example an expired team SSO session) it re-authenticates and retries.+In remote sessions, `/vc:login` resolves the target Vercel project and owning team from the deployment URL. When the target requires authentication and Vercel cannot resolve its host in the active scope, the flow asks you to select another team, then reruns the lookup in that scope. When access is denied, for example because a team SSO session expired, it re-authenticates and retries.diff --git a/.changeset/remote-tui-oidc.md b/.changeset/remote-tui-oidc.mdindex 84697d287..22a27b72a 100644--- a/.changeset/remote-tui-oidc.md+++ b/.changeset/remote-tui-oidc.md@@ -2,4 +2,4 @@"eve": patch----Remote `eve dev --url` sessions now show deployment and authentication state, try refreshed project-scoped OIDC credentials at startup, and open a cancellable `/vc:auth` recovery flow when access is rejected. The flow can update the target project's Trusted Sources after confirmation.+Remote `eve dev --url` sessions now show deployment and authentication state, try refreshed project-scoped OIDC credentials at startup, and open a cancellable `/vc:login` recovery flow when access is rejected. The flow can update the target project's Trusted Sources after confirmation.diff --git a/.changeset/vc-commands-rename.md b/.changeset/vc-commands-rename.mdindex 817f02a36..29170677b 100644--- a/.changeset/vc-commands-rename.md+++ b/.changeset/vc-commands-rename.md@@ -2,4 +2,4 @@"eve": patch----The dev TUI's `/vc` and `/login` commands are now `/vc:install` and `/vc:login`, matching `/vc:auth`, and both are available in remote (`eve dev --url`) sessions. You can install the Vercel CLI or log in while connected to a remote — the prerequisites `/vc:auth` may need — instead of only in a local session.+The dev TUI's `/vc` and `/login` commands are now `/vc:install` and `/vc:login`. `/vc:login` is the single Vercel authentication command: it logs in locally and, in remote (`eve dev --url`) sessions, recovers access with Vercel OIDC.diff --git a/docs/guides/dev-tui.md b/docs/guides/dev-tui.mdindex 0312bb7b4..e07663dd0 100644--- a/docs/guides/dev-tui.md+++ b/docs/guides/dev-tui.md@@ -30,20 +30,19 @@ Errors render compactly with docs links highlighted. A code bug escaping your ag## Slash commands-Each command echoes as an invocation line, asks through a bordered panel that takes the input area's place (one question at a time, separate from the chat transcript), and finishes with a one-line `⎿` result. Loading states stay on the ephemeral status line instead of piling into the transcript; model, channel, and the Vercel CLI commands (`/vc:install`, `/vc:login`, `/vc:auth`) use the same green square pulse as the build phase, while `/deploy` keeps a spinner. Setup menus render the selected option with a filled arrow and an inverse label padded by one space on each side. Text prompts use a blinking block cursor over the character at the caret. The selected label is blue normally and yellow for warning rows.--| Command | Does |-| ------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |-| `/model` | Opens a configure menu that loops until Done (or Esc). See [Configure the model and provider](#configure-the-model-and-provider). |-| `/channels` | Shows the agent's channel list and adds the one you pick. See [Add a channel](#add-a-channel). |-| `/deploy` | Ships the agent to Vercel production, linking the directory first when it is unlinked. |-| `/vc:install` | Installs the Vercel CLI. Available locally and on a remote session. |-| `/vc:login` | Logs the Vercel CLI into an account. Available locally and on a remote session. |-| `/vc:auth` | Resolves the remote's Vercel project from its deployment URL, refreshes its OIDC token, and confirms any required Trusted Sources rule. Remote only. |-| `/loglevel` | Switches which logs the transcript shows. See [Control what logs show](#control-what-logs-show). |-| `/new` | Starts a fresh session. |-| `/exit` | Quits the TUI. |-| `/help` | Lists the commands available for the current local or remote session. |+Each command echoes as an invocation line, asks through a bordered panel that takes the input area's place (one question at a time, separate from the chat transcript), and finishes with a one-line `⎿` result. Loading states stay on the ephemeral status line instead of piling into the transcript; model, channel, and the Vercel CLI commands (`/vc:install`, `/vc:login`) use the same green square pulse as the build phase, while `/deploy` keeps a spinner. Setup menus render the selected option with a filled arrow and an inverse label padded by one space on each side. Text prompts use a blinking block cursor over the character at the caret. The selected label is blue normally and yellow for warning rows.++| Command | Does |+| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |+| `/model` | Opens a configure menu that loops until Done (or Esc). See [Configure the model and provider](#configure-the-model-and-provider). |+| `/channels` | Shows the agent's channel list and adds the one you pick. See [Add a channel](#add-a-channel). |+| `/deploy` | Ships the agent to Vercel production, linking the directory first when it is unlinked. |+| `/vc:install` | Installs the Vercel CLI. Available locally and on a remote session. |+| `/vc:login` | Logs in to Vercel locally. On a remote session, resolves the deployment's project, refreshes its OIDC token, and confirms any required Trusted Sources rule. |+| `/loglevel` | Switches which logs the transcript shows. See [Control what logs show](#control-what-logs-show). |+| `/new` | Starts a fresh session. |+| `/exit` | Quits the TUI. |+| `/help` | Lists the commands available for the current local or remote session. |`/model`, `/channels`, and `/deploy` manage the project and are available only when `eve dev` runs the server locally, not when connected to a remote server with `--url`.@@ -124,11 +123,11 @@ eve dev https://<your-app>The bare URL is shorthand for `--url`; it cannot be combined with `--host`, `--port`, or `--no-ui`.-At startup the TUI gets the expected Vercel owner and project from `VERCEL_ORG_ID` and `VERCEL_PROJECT_ID` when both are set, or from the current directory's Vercel link otherwise. It asks Vercel to prove that the remote origin belongs to that project. Only that proof allows the client to request a project-scoped OIDC token—refreshing an expired development token when refresh credentials exist—or attach an automation-bypass secret; an unverified URL is probed anonymously. The TUI then requests `/eve/v1/info`, with a ten-second timeout. A successful response marks the remote ready. An eve OIDC challenge, Vercel Deployment Protection challenge, or `TRUSTED_SOURCES_ENVIRONMENT_MISMATCH` opens `/vc:auth` automatically; ordinary network failures and server errors remain remote-availability errors and do not start an authentication flow. Esc or Ctrl-C cancels the authentication flow.+At startup the TUI asks Vercel to resolve the remote origin under the active scope. A resolved response is the authority for a project-scoped OIDC token—refreshing an expired development token when refresh credentials exist—or an automation-bypass secret. An unresolved host is probed anonymously. The TUI then requests `/eve/v1/info`, with a ten-second timeout. A successful response marks the remote ready. An eve OIDC challenge, Vercel Deployment Protection challenge, or `TRUSTED_SOURCES_ENVIRONMENT_MISMATCH` opens `/vc:login` automatically; ordinary network failures and server errors remain remote-availability errors and do not start an authentication flow. Esc or Ctrl-C cancels the authentication flow.-`/vc:auth` can use the directory's current Vercel project or show your Vercel teams and their existing projects. If the CLI is logged out, the same panel runs the browser login first. The flow verifies that the selected project owns the remote deployment, asks before adding any required Trusted Sources rule, and requests a project-scoped token through `@vercel/oidc`. It does not relink the directory or modify `.env.local`. Finally, it retries `/eve/v1/info` to prove the credential works. A failure reports any login or Trusted Sources update that completed before it stopped.+In a remote session, `/vc:login` first resolves the deployment's Vercel project from its URL. If the active Vercel scope cannot resolve it, the flow asks for another team and reruns the lookup in that team's scope. If the CLI is logged out, the same panel runs the browser login first. The flow asks before adding any required Trusted Sources rule and requests a project-scoped token through `@vercel/oidc`. It does not relink the directory or modify `.env.local`. Finally, it retries `/eve/v1/info` to prove the credential works. A failure reports any login or Trusted Sources update that completed before it stopped.-The project-scoped token represents the selected project's Development environment. Vercel already allows a project's Development environment to call its own Preview deployments by default. For a Production or custom-environment target, `/vc:auth` shows the exact Development-to-target rule before changing that project's Trusted Sources. Eve preserves existing entries. When it creates an explicit rule, it also carries Vercel's default self-access rows forward because saved rules replace those defaults. See Vercel's [Trusted Sources guide](https://vercel.com/docs/deployment-protection/methods-to-bypass-deployment-protection/trusted-sources), [error reference](https://vercel.com/docs/errors/trusted_sources_environment_mismatch), and [OIDC token anatomy](https://vercel.com/docs/oidc/reference#oidc-token-anatomy).+The project-scoped token represents the resolved project's Development environment. Vercel already allows a project's Development environment to call its own Preview deployments by default. For a Production or custom-environment target, `/vc:login` shows the exact Development-to-target rule before changing that project's Trusted Sources. Eve preserves existing entries. When it creates an explicit rule, it also carries Vercel's default self-access rows forward because saved rules replace those defaults. See Vercel's [Trusted Sources guide](https://vercel.com/docs/deployment-protection/methods-to-bypass-deployment-protection/trusted-sources), [error reference](https://vercel.com/docs/errors/trusted_sources_environment_mismatch), and [OIDC token anatomy](https://vercel.com/docs/oidc/reference#oidc-token-anatomy).`VERCEL_AUTOMATION_BYPASS_SECRET` remains available for a Protection Bypass for Automation token. See [Deployment](./deployment) for the smoke-test flow.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.tsindex 81e8536f0..1e0696d84 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@@ -164,6 +164,7 @@ describe("createPromptCommandHandler", () => {it("reports a login that completed before remote authentication was cancelled", async () => {const setupFlow = setupFlowRenderer();+ const runLoginFlow = vi.fn(async () => ({ kind: "cancelled" as const }));const remoteConnection: RemoteConnectionController = {current: () => ({target: REMOTE_TARGET,@@ -185,28 +186,31 @@ describe("createPromptCommandHandler", () => {};const handler = createPromptCommandHandler({target: REMOTE_TARGET,+ flows: { runLoginFlow },});await expect(handler.handle(- { type: "extension", name: "vc:auth", argument: "" },+ { type: "extension", name: "vc:login", argument: "" },{...context({ setupFlow }),remoteConnection,},),).resolves.toEqual({- message: "/vc:auth cancelled after logging in to Vercel.",+ message: "/vc:login cancelled after logging in to Vercel.",});+ expect(runLoginFlow).not.toHaveBeenCalled();expect(setupFlow.begin).toHaveBeenCalledWith("Authenticate via Vercel OIDC", "pulse");expect(setupFlow.end).toHaveBeenCalledWith({ preserveDiagnostics: true });});- it("reports mutations that completed before /vc:auth was interrupted", async () => {+ it("reports mutations that completed before remote /vc:login was interrupted", async () => {const setupFlow = {...setupFlowRenderer(),waitForInterrupt: () => ({ promise: Promise.resolve(), dispose: vi.fn() }),} satisfies SetupFlowRenderer;+ const runLoginFlow = vi.fn(async () => ({ kind: "cancelled" as const }));const remoteConnection: RemoteConnectionController = {current: () => ({target: REMOTE_TARGET,@@ -235,17 +239,19 @@ describe("createPromptCommandHandler", () => {};const handler = createPromptCommandHandler({target: REMOTE_TARGET,+ flows: { runLoginFlow },});await expect(handler.handle(- { type: "extension", name: "vc:auth", argument: "" },+ { type: "extension", name: "vc:login", argument: "" },{ ...context({ setupFlow }), remoteConnection },),).resolves.toEqual({message:- "/vc:auth interrupted. Completed before interruption: updated Trusted Sources for remote-agent.",+ "/vc:login interrupted. Completed before interruption: updated Trusted Sources for remote-agent.",});+ expect(runLoginFlow).not.toHaveBeenCalled();});it("folds setup-module load failures at the command adapter boundary", async () => {diff --git a/packages/eve/src/cli/dev/tui/prompt-command-handler.ts b/packages/eve/src/cli/dev/tui/prompt-command-handler.tsindex becc7977f..bff856897 100644--- a/packages/eve/src/cli/dev/tui/prompt-command-handler.ts+++ b/packages/eve/src/cli/dev/tui/prompt-command-handler.ts@@ -36,8 +36,7 @@ export function createPromptCommandHandler(const { target } = options;// Local-only commands invoked on a remote target are rejected here; the// allowlist is derived from each command's `targets` so dispatch can't- // drift from discovery. (vc:auth's remote-only direction is enforced in- // its own branch below.)+ // drift from discovery.if (target.kind === "remote" && !isPromptCommandAvailableFor(command.name, "remote")) {return {message: `/${command.name} needs eve dev running the local server (it is not available with --url).`,@@ -84,15 +83,15 @@ export function createPromptCommandHandler(return { message: `/${command.name} is not supported by this renderer.` };}- if (command.name === "vc:auth") {- if (target.kind !== "remote" || context.remoteConnection === undefined) {- return { message: "/vc:auth is not available in this session." };+ if (command.name === "vc:login" && target.kind === "remote") {+ if (context.remoteConnection === undefined) {+ return { message: "/vc:login is not available in this session." };}let runRemoteAuthCommand: (typeof import("./remote-auth-command.js"))["runRemoteAuthCommand"];try {({ runRemoteAuthCommand } = await import("./remote-auth-command.js"));} catch (error) {- return { message: `/vc:auth failed: ${toErrorMessage(error)}` };+ return { message: `/vc:login failed: ${toErrorMessage(error)}` };}const message = await runRemoteAuthCommand({connection: context.remoteConnection,@@ -102,10 +101,8 @@ export function createPromptCommandHandler(return { message };}- // Availability is the `targets` allowlist checked above; the remaining- // setup commands run against `workspaceRoot`, which both a local and a- // remote target carry (`/vc:install` and `/vc:login` only need a working- // directory, not the local dev server).+ // The remaining setup commands run against the local workspace, except+ // `/vc:install`, which needs only a working directory on a remote session.let setupCommands: typeof import("./setup-commands.js");try {setupCommands = await import("./setup-commands.js");diff --git a/packages/eve/src/cli/dev/tui/prompt-commands.test.ts b/packages/eve/src/cli/dev/tui/prompt-commands.test.tsindex 72eb53b7a..e41553e80 100644--- a/packages/eve/src/cli/dev/tui/prompt-commands.test.ts+++ b/packages/eve/src/cli/dev/tui/prompt-commands.test.ts@@ -45,11 +45,6 @@ describe("parsePromptCommand", () => {name: "vc:login",argument: "",});- expect(parsePromptCommand("/vc:auth")).toEqual({- type: "extension",- name: "vc:auth",- argument: "",- });expect(parsePromptCommand("/channels")).toEqual({type: "extension",name: "channels",@@ -85,6 +80,7 @@ describe("parsePromptCommand", () => {expect(parsePromptCommand("/vercel")).toBeNull();expect(parsePromptCommand("/vc")).toBeNull();expect(parsePromptCommand("/login")).toBeNull();+ expect(parsePromptCommand("/vc:auth")).toBeNull();expect(parsePromptCommand("/channels extra")).toBeNull();expect(parsePromptCommand("tell me about /channels")).toBeNull();expect(parsePromptCommand("/")).toBeNull();@@ -104,29 +100,26 @@ describe("promptCommandsFor", () => {expect(names).not.toContain("vc:auth");});- it("exposes remote OIDC auth and the Vercel CLI commands for remote sessions", () => {+ it("exposes the Vercel CLI commands for remote sessions", () => {const names = promptCommandsFor("remote").map((command) => command.name);expect(names).toContain("vc:install");expect(names).toContain("vc:login");- expect(names).toContain("vc:auth");+ expect(names).not.toContain("vc:auth");expect(names).not.toContain("model");expect(names).not.toContain("channels");expect(names).not.toContain("deploy");});- it("filters discovery without weakening global recognition", () => {+ it("filters discovery and rejects the obsolete remote auth command", () => {const remote = promptCommandsFor("remote");- expect(parsePromptCommand("/vc:auth")).toEqual({- type: "extension",- name: "vc:auth",- argument: "",- });+ expect(parsePromptCommand("/vc:auth")).toBeNull();expect(parsePromptCommand("/model")).toEqual({type: "extension",name: "model",argument: "",});- expect(formatPromptCommandHelp(remote)).toContain("/vc:auth");+ expect(formatPromptCommandHelp(remote)).toContain("/vc:login");+ expect(formatPromptCommandHelp(remote)).not.toContain("/vc:auth");expect(formatPromptCommandHelp(remote)).not.toContain("/model");});});diff --git a/packages/eve/src/cli/dev/tui/prompt-commands.ts b/packages/eve/src/cli/dev/tui/prompt-commands.tsindex 987031c5d..0839d69f9 100644--- a/packages/eve/src/cli/dev/tui/prompt-commands.ts+++ b/packages/eve/src/cli/dev/tui/prompt-commands.ts@@ -5,8 +5,6 @@ export type PromptCommandExtensionName =| "vc:install"| "vc:login";-type PromptCommandName = PromptCommandExtensionName | "vc:auth";-type PromptCommandTarget = "local" | "remote";/** The slash commands the prompt accepts. */@@ -15,7 +13,7 @@ export type PromptCommand =| { type: "exit" }| { type: "help" }| { type: "loglevel"; argument: string }- | { type: "extension"; name: PromptCommandName; argument: string };+ | { type: "extension"; name: PromptCommandExtensionName; argument: string };/*** Metadata for one slash command. The registry describes commands — their@@ -75,19 +73,11 @@ const PROMPT_COMMAND_DEFINITIONS = [{name: "vc:login",aliases: [],- description: "Log in to Vercel",+ description: "Authenticate with Vercel",takesArgument: false,build: () => ({ type: "extension", name: "vc:login", argument: "" }),targets: ["local", "remote"],},- {- name: "vc:auth",- aliases: [],- description: "Authenticate this remote via Vercel OIDC",- takesArgument: false,- build: () => ({ type: "extension", name: "vc:auth", argument: "" }),- targets: ["remote"],- },{name: "model",aliases: [],@@ -142,7 +132,7 @@ export function promptCommandsFor(target: PromptCommandTarget): readonly PromptC/** Whether a command runs against this target — the one authority dispatch shares with discovery. */export function isPromptCommandAvailableFor(- name: PromptCommandName,+ name: PromptCommandExtensionName,target: PromptCommandTarget,): boolean {const definition = PROMPT_COMMAND_DEFINITIONS.find((entry) => entry.name === name);diff --git a/packages/eve/src/cli/dev/tui/remote-auth-command.ts b/packages/eve/src/cli/dev/tui/remote-auth-command.tsindex 50a117bd5..a1fb8506d 100644--- a/packages/eve/src/cli/dev/tui/remote-auth-command.ts+++ b/packages/eve/src/cli/dev/tui/remote-auth-command.ts@@ -66,7 +66,7 @@ function mutedRenderer(};}-/** Runs `/vc:auth` through one TUI panel, connection operation, and auth flow. */+/** Runs remote `/vc:login` through one TUI panel, connection operation, and auth flow. */export async function runRemoteAuthCommand(input: RemoteAuthCommandInput): Promise<string> {// The pulsing square, matching /vc:install and /vc:login (and model/channels).input.renderer.begin("Authenticate via Vercel OIDC", "pulse");@@ -109,12 +109,12 @@ export async function runRemoteAuthCommand(input: RemoteAuthCommandInput): Promiif (interrupted) {const completed = describeRemoteAuthCompletedMutations(outcome.completedMutations);return completed.length === 0- ? "/vc:auth interrupted."- : `/vc:auth interrupted. Completed before interruption: ${completed.join(", ")}.`;+ ? "/vc:login interrupted."+ : `/vc:login interrupted. Completed before interruption: ${completed.join(", ")}.`;}return outcome.completedMutations.some((mutation) => mutation.kind === "vercel-login")- ? "/vc:auth cancelled after logging in to Vercel."- : "/vc:auth cancelled.";+ ? "/vc:login cancelled after logging in to Vercel."+ : "/vc:login cancelled.";}case "failed":return outcome.message;diff --git a/packages/eve/src/cli/dev/tui/remote-auth-result.ts b/packages/eve/src/cli/dev/tui/remote-auth-result.tsindex d03764a79..c726233b6 100644--- a/packages/eve/src/cli/dev/tui/remote-auth-result.ts+++ b/packages/eve/src/cli/dev/tui/remote-auth-result.ts@@ -55,7 +55,7 @@ export function formatRemoteAuthChallengeMessage(serverUrl: string): string {`Vercel Deployment Protection blocked the request to ${serverUrl}.`,"","To access the deployment from `eve dev`, do one of:",- " • Run `/vc:auth` to select a Vercel project and refresh its OIDC token.",+ " • Run `/vc:login` to authenticate this remote via Vercel OIDC."," • Set VERCEL_AUTOMATION_BYPASS_SECRET to a Protection Bypass for"," Automation token (Project Settings → Deployment Protection)."," • Disable Deployment Protection on the target deployment.",diff --git a/packages/eve/src/cli/dev/tui/remote-auth.test.ts b/packages/eve/src/cli/dev/tui/remote-auth.test.tsindex ef1da1d10..358079803 100644--- a/packages/eve/src/cli/dev/tui/remote-auth.test.ts+++ b/packages/eve/src/cli/dev/tui/remote-auth.test.ts@@ -1,4 +1,5 @@import { afterEach, describe, expect, it, vi } from "vitest";+import pc from "picocolors";import { createFakePrompter } from "#internal/testing/fake-prompter.js";import { resolveTestVercelTarget } from "#internal/testing/verified-vercel-target.js";@@ -11,6 +12,8 @@ const HOST = "vpoke.playground-vercel.tools";const SERVER_URL = `https://${HOST}/`;const OWNER_ID = "team_acme";const PROJECT_ID = "prj_remote";+const SELECTED_TEAM = "labs";+const SELECTED_PROJECT_ID = "prj_e0";const TARGET = await resolveTestVercelTarget({host: HOST,@@ -18,6 +21,12 @@ const TARGET = await resolveTestVercelTarget({ownerId: OWNER_ID,projectName: "remote-agent",});+const SELECTED_TARGET = await resolveTestVercelTarget({+ host: HOST,+ projectId: SELECTED_PROJECT_ID,+ ownerId: "team_labs",+ projectName: "e0",+});const TRUSTED_SOURCE_GRANT = {ownerId: OWNER_ID,projectId: PROJECT_ID,@@ -60,7 +69,6 @@ function createHarness(options: HarnessOptions = {}) {? undefined: (options.token?.value ?? oidcToken(OWNER_ID, PROJECT_ID));- // No `select` is expected: the flow resolves from the URL with no picker.const { prompter } = createFakePrompter({single: () => {throw new Error("unexpected select prompt");@@ -72,6 +80,10 @@ function createHarness(options: HarnessOptions = {}) {operations.push("login");return logins[Math.min(loginCall++, logins.length - 1)]!;}),+ pickTeam: vi.fn<RemoteAuthFlowDeps["pickTeam"]>(async () => {+ operations.push("team");+ return SELECTED_TEAM;+ }),resolveVercelDeployment: vi.fn<RemoteAuthFlowDeps["resolveVercelDeployment"]>(async () => {operations.push("deployment");return deployments[Math.min(deploymentCall++, deployments.length - 1)]!;@@ -136,6 +148,71 @@ describe("runRemoteAuthFlow", () => {expect(harness.operations).toEqual(["login", "deployment", "token"]);});+ it("selects a team when the unscoped deployment lookup misses", async () => {+ const { prompter } = createFakePrompter({+ single: () => {+ throw new Error("unexpected select prompt");+ },+ });+ let deploymentCall = 0;+ const resolveVercelDeployment = vi.fn<RemoteAuthFlowDeps["resolveVercelDeployment"]>(async () =>+ deploymentCall++ === 0+ ? { kind: "not-found" }+ : { kind: "resolved", target: SELECTED_TARGET },+ );+ const resolveOidcToken = vi.fn<RemoteAuthFlowDeps["resolveOidcToken"]>(async () => ({+ kind: "resolved",+ token: oidcToken("team_labs", SELECTED_PROJECT_ID),+ }));+ const pickTeam = vi.fn<RemoteAuthFlowDeps["pickTeam"]>(async () => SELECTED_TEAM);++ await expect(+ runRemoteAuthFlow({+ workspaceRoot: WORKSPACE_ROOT,+ serverUrl: SERVER_URL,+ prompter,+ deps: {+ runLoginFlow: vi.fn<RemoteAuthFlowDeps["runLoginFlow"]>(async () => ({+ kind: "already",+ })),+ pickTeam,+ resolveVercelDeployment,+ resolveOidcToken,+ },+ }),+ ).resolves.toMatchObject({+ kind: "prepared",+ target: SELECTED_TARGET,+ });+ expect(resolveVercelDeployment).toHaveBeenNthCalledWith(1, {+ workspaceRoot: WORKSPACE_ROOT,+ host: HOST,+ signal: undefined,+ });+ expect(resolveVercelDeployment).toHaveBeenNthCalledWith(2, {+ workspaceRoot: WORKSPACE_ROOT,+ host: HOST,+ signal: undefined,+ scope: SELECTED_TEAM,+ });+ expect(pickTeam).toHaveBeenCalledWith(+ prompter,+ WORKSPACE_ROOT,+ undefined,+ expect.objectContaining({ signal: undefined, selectMessage: expect.any(Function) }),+ );+ const selectMessage = pickTeam.mock.calls[0]?.[3]?.selectMessage;+ expect(selectMessage?.("Current Team")).toBe(+ `${pc.blue(HOST)} is not accessible via current team (${pc.bold("Current Team")})\n` ++ "You can try selecting another team:",+ );+ expect(resolveOidcToken).toHaveBeenCalledWith({+ ownerId: "team_labs",+ projectId: SELECTED_PROJECT_ID,+ forceRefresh: true,+ });+ });+it("re-authenticates and resolves again when access is initially forbidden", async () => {const harness = createHarness({logins: [{ kind: "already" }, { kind: "logged-in" }],@@ -231,7 +308,7 @@ describe("runRemoteAuthFlow", () => {{name: "deployment not found",options: { deployments: [{ kind: "not-found" }] },- message: "did not resolve",+ message: "selected Vercel team",},{name: "access still forbidden after re-auth",@@ -296,7 +373,7 @@ describe("formatRemoteAuthChallengeMessage", () => {const message = formatRemoteAuthChallengeMessage("https://example.vercel.app");expect(message).toContain("https://example.vercel.app");- expect(message).toContain("/vc:auth");+ expect(message).toContain("/vc:login");expect(message).toContain("VERCEL_AUTOMATION_BYPASS_SECRET");expect(message).toContain("Disable Deployment Protection");expect(message).toContain("https://vercel.com/docs/deployment-protection");diff --git a/packages/eve/src/cli/dev/tui/remote-auth.ts b/packages/eve/src/cli/dev/tui/remote-auth.tsindex de3ff1e61..3186dbdd3 100644--- a/packages/eve/src/cli/dev/tui/remote-auth.ts+++ b/packages/eve/src/cli/dev/tui/remote-auth.ts@@ -2,6 +2,7 @@ import { resolveDevelopmentOidcToken } from "#services/dev-client/request-headerimport { formatDevelopmentOidcTokenFailure } from "#services/dev-client/vercel-auth-error.js";import { runLoginFlow, type LoginFlowResult } from "#setup/flows/login.js";import type { Prompter } from "#setup/prompter.js";+import { pickTeam } from "#setup/vercel-project.js";import {resolveVercelDeployment,type VercelDeploymentResolutionFailure,@@ -19,11 +20,14 @@ import {type RemoteAuthPreparation,} from "./remote-auth-result.js";import { toErrorMessage } from "#shared/errors.js";+import pc from "picocolors";/** Injectable entry point for the remote authentication flow. */export type RemoteAuthFlow = typeof runRemoteAuthFlow;+export interface RemoteAuthFlowDeps {readonly runLoginFlow: typeof runLoginFlow;+ readonly pickTeam: typeof pickTeam;readonly resolveVercelDeployment: typeof resolveVercelDeployment;readonly resolveOidcToken: typeof resolveDevelopmentOidcToken;readonly prepareVercelTrustedSourceAccess: typeof prepareVercelTrustedSourceAccess;@@ -32,6 +36,7 @@ export interface RemoteAuthFlowDeps {const defaultDeps: RemoteAuthFlowDeps = {runLoginFlow,+ pickTeam,resolveVercelDeployment,resolveOidcToken: resolveDevelopmentOidcToken,prepareVercelTrustedSourceAccess,@@ -64,13 +69,13 @@ function loginFailure(result: LoginFlowResult): RemoteAuthPreparation | undefinereturn cancelled();case "cli-missing":return failed(- "The Vercel CLI is not installed. Install it with `npm i -g vercel@latest`, then retry /vc:auth.",+ "The Vercel CLI is not installed. Install it with `npm i -g vercel@latest`, then retry /vc:login.",);case "failed":- return failed("Vercel login did not complete. Retry /vc:auth.");+ return failed("Vercel login did not complete. Retry /vc:login.");case "unavailable":return failed(- "Vercel could not verify your account. Check your connection, then retry /vc:auth.",+ "Vercel could not verify your account. Check your connection, then retry /vc:login.",);}}@@ -79,6 +84,21 @@ function deploymentFailureMessage(failure: VercelDeploymentResolutionFailure): sreturn failure.cause === "vercel" ? failure.failure.message : failure.message;}+async function selectVercelDeploymentScope(+ deps: Pick<RemoteAuthFlowDeps, "pickTeam">,+ workspaceRoot: string,+ host: string,+ prompter: Prompter,+ signal: AbortSignal | undefined,+): Promise<string> {+ return await deps.pickTeam(prompter, workspaceRoot, undefined, {+ signal,+ selectMessage: (currentTeam) =>+ `${pc.blue(host)} is not accessible via current team (${pc.bold(currentTeam)})\n` ++ "You can try selecting another team:",+ });+}+/*** Authenticates a remote by resolving its deployment URL to the owning Vercel* project, updating Trusted Sources when needed and keeping the resolved@@ -106,10 +126,8 @@ export async function runRemoteAuthFlow(input: {if (loginOutcome !== undefined) return loginOutcome;if (login.kind === "logged-in") completedMutations.push({ kind: "vercel-login" });- // A deployment hostname is globally unique, so Vercel resolves the project- // and owning team straight from the URL under the caller's own access — no- // team/project picker. If access is denied (for example an expired team SSO- // session), re-authenticate through the same dialogue and resolve once more.+ // Prefer direct host resolution. If the active Vercel scope cannot see the+ // deployment, the picker supplies an explicit team scope.let resolution = await deps.resolveVercelDeployment({ workspaceRoot, host, signal });if (resolution.kind === "forbidden") {const reauth = await deps.runLoginFlow({@@ -124,6 +142,26 @@ export async function runRemoteAuthFlow(input: {signal?.throwIfAborted();resolution = await deps.resolveVercelDeployment({ workspaceRoot, host, signal });}+ if (resolution.kind === "not-found") {+ try {+ const scope = await selectVercelDeploymentScope(+ deps,+ workspaceRoot,+ host,+ prompter,+ signal,+ );+ signal?.throwIfAborted();+ resolution = await deps.resolveVercelDeployment({ workspaceRoot, host, scope, signal });+ } catch (error) {+ if (error instanceof WizardCancelledError) return cancelled(completedMutations);+ signal?.throwIfAborted();+ return failed(+ `Could not select a Vercel team: ${toErrorMessage(error)}`,+ completedMutations,+ );+ }+ }let target: VerifiedVercelTarget;switch (resolution.kind) {@@ -134,12 +172,12 @@ export async function runRemoteAuthFlow(input: {return cancelled(completedMutations);case "forbidden":return failed(- `Could not access ${host}. Re-authenticate (for example to complete a team's SSO), then retry /vc:auth.`,+ `Could not access ${host}. Re-authenticate (for example to complete a team's SSO), then retry /vc:login.`,completedMutations,);case "not-found":return failed(- `Vercel did not resolve ${host} as a deployment you can access. If it belongs to a team that enforces SSO, re-authenticate and retry /vc:auth.`,+ `Vercel did not resolve ${host} for the selected Vercel team.`,completedMutations,);case "project-mismatch":diff --git a/packages/eve/src/cli/dev/tui/remote-connection.test.ts b/packages/eve/src/cli/dev/tui/remote-connection.test.tsindex 519aebb94..f2c73a7d0 100644--- a/packages/eve/src/cli/dev/tui/remote-connection.test.ts+++ b/packages/eve/src/cli/dev/tui/remote-connection.test.ts@@ -277,6 +277,27 @@ describe("createRemoteConnectionController", () => {expect(resolveOidcToken).toHaveBeenCalledWith(VERIFIED_TARGET.deployment);});+ it.each(["not-found", "forbidden"] as const)(+ "probes anonymously when Vercel resolves the host as %s",+ async (kind) => {+ const tokens: string[] = [];+ const resolveDeployment = vi.fn<(signal: AbortSignal) => Promise<VercelDeploymentResolution>>(+ async () => ({ kind }),+ );+ const harness = createHarness({+ resolveDeployment,+ info: async (credentials) => {+ tokens.push(await credentials.resolveToken());+ return INFO;+ },+ });++ await expect(harness.controller.check()).resolves.toEqual({ state: "ready", info: INFO });+ expect(harness.info).toHaveBeenCalledOnce();+ expect(tokens).toEqual([""]);+ },+ );+it("uses the authenticated token resolver for every request", async () => {let request = 0;const info = vi.fn(async (credentials: DevelopmentCredentialGate) => {@@ -409,7 +430,7 @@ describe("createRemoteConnectionController", () => {expect(tokens[2]).toBe("");});- it("clears ambient credentials before a later unverified check", async () => {+ it("clears ambient credentials before a later unresolved deployment check", async () => {const tokens: string[] = [];const resolveDeployment = vi.fn<(signal: AbortSignal) => Promise<VercelDeploymentResolution>>()@@ -427,9 +448,9 @@ describe("createRemoteConnectionController", () => {await expect(harness.controller.check()).resolves.toEqual({ state: "ready", info: INFO });await expect(harness.controller.check()).resolves.toEqual({ state: "ready", info: INFO });- expect(tokens[0]).toBe("ambient-token");- expect(tokens[1]).toBe("");+ expect(tokens).toEqual(["ambient-token", ""]);expect(harness.controller.current().deployment).toBeUndefined();+ await expect(harness.credentials.resolveToken()).resolves.toBe("");});it("does not publish a stale deployment lookup", async () => {diff --git a/packages/eve/src/cli/dev/tui/runner.test.ts b/packages/eve/src/cli/dev/tui/runner.test.tsindex 11fe11690..cde03bceb 100644--- a/packages/eve/src/cli/dev/tui/runner.test.ts+++ b/packages/eve/src/cli/dev/tui/runner.test.ts@@ -10,6 +10,7 @@ import {} from "#client/index.js";import { resolveTestVercelTarget } from "#internal/testing/verified-vercel-target.js";import { createDevelopmentCredentialGate } from "#services/dev-client/credential-gate.js";+import type { VercelDeploymentResolution } from "#setup/vercel-deployment.js";import {EveTUIRunner,@@ -24,6 +25,7 @@ import { createPromptCommandHandler } from "./prompt-command-handler.js";import { promptCommandsFor } from "./prompt-commands.js";import type { RemoteAuthFlow } from "./remote-auth.js";import type { RemoteAuthCompletedMutation } from "./remote-auth-result.js";+import type { RemoteConnectionControllerOptions } from "./remote-connection.js";import type { BootDetection, SetupIssue } from "./setup-issues.js";import type { SetupFlowRenderer } from "./setup-flow.js";import { createFakeSetupFlowRenderer } from "./test/fake-setup-flow-renderer.js";@@ -1169,11 +1171,28 @@ describe("EveTUIRunner remote authentication", () => {workspaceRoot: "/tmp/weather-agent",} as const;- function remoteOptions() {+ const unresolvedDeployment: VercelDeploymentResolution = {+ kind: "failed",+ failure: {+ cause: "vercel",+ failure: {+ code: null,+ message: "Vercel deployment lookup failed.",+ stderr: "",+ stdout: "",+ },+ },+ };++ function remoteOptions(+ resolveDeployment: NonNullable<+ RemoteConnectionControllerOptions["resolveDeployment"]+ > = async () => unresolvedDeployment,+ ) {return {target,credentials: createDevelopmentCredentialGate(target.serverUrl),- resolveDeployment: async () => ({ kind: "not-found" }) as const,+ resolveDeployment,resolveOidcToken: async () => ({kind: "resolution-failed" as const,message: "No ambient token in this test.",@@ -1203,6 +1222,7 @@ describe("EveTUIRunner remote authentication", () => {client: Client;flow: RemoteAuthFlow;renderer?: Partial<AgentTUIRenderer>;+ resolveDeployment?: NonNullable<RemoteConnectionControllerOptions["resolveDeployment"]>;}): Promise<void> {await new EveTUIRunner({session: input.client.session(),@@ -1214,11 +1234,44 @@ describe("EveTUIRunner remote authentication", () => {target,remoteAuthFlow: input.flow,}),- remote: remoteOptions(),+ remote: remoteOptions(input.resolveDeployment),}).run();}- it("runs /vc:auth once at startup after the exact remote auth challenge", async () => {+ it("runs /vc:login after an unresolved host returns an authentication challenge", async () => {+ const client = stubClient();+ const order: string[] = [];+ let infoCalls = 0;+ vi.spyOn(client, "info").mockImplementation(async () => {+ order.push("info");+ if (++infoCalls === 1) throw unauthorized();+ return AGENT_INFO;+ });+ const flow = vi.fn<RemoteAuthFlow>(async () => {+ order.push("login");+ return {+ kind: "prepared",+ target: REMOTE_VERIFIED_TARGET,+ resolveToken: async () => "fresh-token",+ completedMutations: [],+ };+ });+ const commandInvocations: Array<{ text: string; status: "failed" | undefined }> = [];++ await runRemoteAuth({+ client,+ flow,+ resolveDeployment: async () => ({ kind: "not-found" }),+ renderer: {+ renderCommandInvocation: (text, status) => commandInvocations.push({ text, status }),+ },+ });++ expect(order).toEqual(["info", "login", "info"]);+ expect(commandInvocations).toEqual([{ text: "/vc:login", status: undefined }]);+ });++ it("runs /vc:login once at startup after the exact remote auth challenge", async () => {const client = stubClient();vi.spyOn(client, "info").mockRejectedValueOnce(unauthorized())@@ -1235,7 +1288,7 @@ describe("EveTUIRunner remote authentication", () => {});expect(flow).toHaveBeenCalledOnce();- expect(commandInvocations).toEqual([{ text: "/vc:auth", status: undefined }]);+ expect(commandInvocations).toEqual([{ text: "/vc:login", status: undefined }]);});it("requests Trusted Sources repair for an environment mismatch", async () => {@@ -1253,7 +1306,7 @@ describe("EveTUIRunner remote authentication", () => {expect(flow).toHaveBeenCalledWith(expect.objectContaining({ configureTrustedSources: true }));});- it("renders a failed automatic /vc:auth as one command result without the request id", async () => {+ it("renders a failed automatic /vc:login as one command result without the request id", async () => {const client = stubClient();vi.spyOn(client, "info").mockRejectedValueOnce(unauthorized())@@ -1279,7 +1332,7 @@ describe("EveTUIRunner remote authentication", () => {},});- expect(commandInvocations).toEqual([{ text: "/vc:auth", status: "failed" }]);+ expect(commandInvocations).toEqual([{ text: "/vc:login", status: "failed" }]);expect(commandResults).toEqual(["Authentication was refreshed, but vpoke.playground-vercel.tools is unavailable: " +"Your trusted sources OIDC token's environment is not permitted to access this deployment.\n\n" +diff --git a/packages/eve/src/cli/dev/tui/runner.ts b/packages/eve/src/cli/dev/tui/runner.tsindex b1e800311..ac7daf84b 100644--- a/packages/eve/src/cli/dev/tui/runner.ts+++ b/packages/eve/src/cli/dev/tui/runner.ts@@ -204,7 +204,7 @@ export type AgentTUIRenderer = {renderSetupWarning?(text: string): void;/** Clears the setup attention line once its issue is resolved. */clearSetupWarning?(): void;- /** Commits the startup `/vc:auth` invocation to the transcript. */+ /** Commits the startup `/vc:login` invocation to the transcript. */renderCommandInvocation?(text: string, status?: "failed"): void;renderCommandResult?(text: string): void;readonly setupFlow?: SetupFlowRenderer;@@ -612,7 +612,7 @@ export class EveTUIRunner {await this.#renderAgentHeader();if (this.#remoteConnection?.current().connection.state === "auth-required") {await this.#executeExtensionCommand(- { type: "extension", name: "vc:auth", argument: "" },+ { type: "extension", name: "vc:login", argument: "" },title,"startup",);diff --git a/packages/eve/src/cli/dev/tui/status-line.test.ts b/packages/eve/src/cli/dev/tui/status-line.test.tsindex b42bd75cb..8282ef1aa 100644--- a/packages/eve/src/cli/dev/tui/status-line.test.ts+++ b/packages/eve/src/cli/dev/tui/status-line.test.ts@@ -293,7 +293,8 @@ describe("buildStatusLine", () => {"\x1b[7m\x1b[33m ↗ vpoke.playground-vercel.tools \x1b[39m\x1b[27m",);expect(notConnected).not.toContain("\x1b[43m");- expect(notConnected).not.toContain("/vc:auth");+ expect(notConnected).not.toContain("/vc:login");+ expect(disconnected).not.toContain("/vc:login");expect(connectedLine).toContain("\x1b[7m\x1b[34m ↗ inbound (production) \x1b[39m\x1b[27m");const badges = `${disconnected}${notConnected}${connectedLine}`;expect(badges).not.toContain("\x1b[44m");diff --git a/packages/eve/src/cli/dev/tui/terminal-renderer.test.ts b/packages/eve/src/cli/dev/tui/terminal-renderer.test.tsindex 6ad0d22cf..4bfcf1668 100644--- a/packages/eve/src/cli/dev/tui/terminal-renderer.test.ts+++ b/packages/eve/src/cli/dev/tui/terminal-renderer.test.ts@@ -694,7 +694,7 @@ describe("TerminalRenderer (inline scrollback)", () => {it("marks a failed automatic command and keeps its multiline outcome in one result block", () => {const { screen, renderer } = makeRenderer();- renderer.renderCommandInvocation("/vc:auth", "failed");+ renderer.renderCommandInvocation("/vc:login", "failed");renderer.renderCommandResult("Authentication was refreshed, but example.vercel.app is unavailable: Access denied.\n\n" +"TRUSTED_SOURCES_ENVIRONMENT_MISMATCH",@@ -702,7 +702,7 @@ describe("TerminalRenderer (inline scrollback)", () => {renderer.shutdown();const snapshot = screen.snapshot();- expect(snapshot).toContain("▌ ⨯ /vc:auth");+ expect(snapshot).toContain("▌ ⨯ /vc:login");expect(snapshot).toContain("⎿ Authentication was refreshed");expect(snapshot).toContain("TRUSTED_SOURCES_ENVIRONMENT_MISMATCH");expect(snapshot).not.toContain("· Authentication was refreshed");@@ -2580,7 +2580,7 @@ describe("TerminalRenderer command typeahead", () => {const prompt = renderer.readPrompt();input.type("/");const snapshot = screen.snapshot();- expect(snapshot).toContain("Authenticate this remote via Vercel OIDC");+ expect(snapshot).toContain("Authenticate with Vercel");expect(snapshot).not.toContain("Configure the agent's model and provider");input.enter();await prompt;diff --git a/packages/eve/src/setup/vercel-deployment.test.ts b/packages/eve/src/setup/vercel-deployment.test.tsindex 17b67184e..212ba3aea 100644--- a/packages/eve/src/setup/vercel-deployment.test.ts+++ b/packages/eve/src/setup/vercel-deployment.test.ts@@ -72,6 +72,29 @@ describe("resolveVercelDeployment", () => {);});+ it("scopes the lookup to a selected team without requiring a project", async () => {+ const captureVercel = vi.fn<VercelDeploymentResolutionDeps["captureVercel"]>(async () => ({+ ok: true,+ stdout: JSON.stringify(STANDARD),+ }));++ await expect(+ resolveVercelDeployment({+ workspaceRoot: "/repo",+ host: "inbound.example.com",+ scope: "team_a",+ deps: { captureVercel },+ }),+ ).resolves.toMatchObject({+ kind: "resolved",+ target: { deployment: { ownerId: "team_a", projectId: "prj_target" } },+ });+ expect(captureVercel).toHaveBeenCalledWith(+ ["api", "/v13/deployments/inbound.example.com", "--scope", "team_a", "--raw"],+ expect.objectContaining({ cwd: "/repo" }),+ );+ });+it("derives the canonical owner id from the response, not the queried scope", async () => {const captureVercel = vi.fn<VercelDeploymentResolutionDeps["captureVercel"]>(async () => ({ok: true,diff --git a/packages/eve/src/setup/vercel-deployment.ts b/packages/eve/src/setup/vercel-deployment.tsindex c5c1f1386..fc9210169 100644--- a/packages/eve/src/setup/vercel-deployment.ts+++ b/packages/eve/src/setup/vercel-deployment.ts@@ -59,6 +59,18 @@ export interface VercelDeploymentResolutionDeps {readonly captureVercel: typeof captureVercel;}+type VercelDeploymentLookupScope =+ | {+ /** An explicit Vercel scope selected for this lookup. */+ readonly scope?: string;+ readonly source?: never;+ }+ | {+ /** A known project source, which also cross-checks the returned project id. */+ readonly scope?: never;+ readonly source: Pick<VercelProjectReference, "orgId" | "projectId">;+ };+const defaultDeps: VercelDeploymentResolutionDeps = { captureVercel };const DEPLOYMENT_LOOKUP_TIMEOUT_MS = 10_000;@@ -70,27 +82,27 @@ function environmentForDeployment(deployment: z.infer<typeof VercelDeploymentSch}/** Resolves a Vercel deployment URL to its project and target environment. */-export async function resolveVercelDeployment(input: {- readonly workspaceRoot: string;- readonly host: string;- readonly source?: Pick<VercelProjectReference, "orgId" | "projectId">;- readonly signal?: AbortSignal;- readonly deps?: Partial<VercelDeploymentResolutionDeps>;-}): Promise<VercelDeploymentResolution> {+export async function resolveVercelDeployment(+ input: {+ readonly workspaceRoot: string;+ readonly host: string;+ readonly signal?: AbortSignal;+ readonly deps?: Partial<VercelDeploymentResolutionDeps>;+ } & VercelDeploymentLookupScope,+): Promise<VercelDeploymentResolution> {const deps = { ...defaultDeps, ...input.deps };// A deployment hostname is globally unique, so Vercel resolves it under the- // caller's own access without a scope — including a team-owned deployment- // resolved from a personal default scope. An optional `source` (a known- // project link) scopes the lookup and is cross-checked below, but its absence- // is not fatal: the host alone yields the canonical owner and project.+ // caller's own access without a scope. A selected scope repeats that lookup+ // for one team; a known project source also cross-checks the returned project.const source = input.source;+ const scope = input.scope ?? source?.orgId;const result = normalizeVercelApiResult(await deps.captureVercel(["api",`/v13/deployments/${encodeURIComponent(input.host)}`,- ...(source !== undefined ? ["--scope", source.orgId] : []),+ ...(scope !== undefined ? ["--scope", scope] : []),"--raw",],{diff --git a/packages/eve/src/setup/vercel-project.test.ts b/packages/eve/src/setup/vercel-project.test.tsindex d61a146bf..bf3ed2e94 100644--- a/packages/eve/src/setup/vercel-project.test.ts+++ b/packages/eve/src/setup/vercel-project.test.ts@@ -707,6 +707,24 @@ describe("pickTeam selection", () => {expect(selectMessages).toEqual(["Select your team"]);});+ it("uses a current-team-aware heading when the caller supplies one", async () => {+ stubVercel({+ teams: [+ { name: "Current", slug: "current", current: true },+ { name: "Other", slug: "other", current: false },+ ],+ });+ const { prompter, selectMessages } = answeringPrompter({ selects: ["other"] });++ await expect(+ pickTeam(prompter, "/tmp/parent", undefined, {+ selectMessage: (currentTeam) => `Host is unavailable from ${currentTeam}.`,+ }),+ ).resolves.toBe("other");++ expect(selectMessages).toEqual(["Host is unavailable from Current."]);+ });+it("uses the current scope without prompting when only one team exists", async () => {stubVercel({ teams: [{ name: "Solo", slug: "solo", current: true }] });const { prompter } = answeringPrompter({});diff --git a/packages/eve/src/setup/vercel-project.ts b/packages/eve/src/setup/vercel-project.tsindex ca62aa97a..eabe71743 100644--- a/packages/eve/src/setup/vercel-project.ts+++ b/packages/eve/src/setup/vercel-project.ts@@ -41,6 +41,11 @@ export interface PickProjectOptions extends VercelProjectOperationOptions {allowCreateWhenEmpty?: boolean;}+export interface PickTeamOptions extends VercelProjectOperationOptions {+ /** Builds the team selector heading from the current team's display name. */+ selectMessage?: (currentTeam: string) => string;+}+export function unresolvedProject(): ProjectResolution {return { kind: "unresolved" };}@@ -354,7 +359,7 @@ export async function pickTeam(prompter: Prompter,projectRoot: string,presetTeam: string | undefined,- options: VercelProjectOperationOptions = {},+ options: PickTeamOptions = {},): Promise<string> {if (presetTeam !== undefined) {await validateTeam(prompter, projectRoot, presetTeam, options);@@ -366,15 +371,18 @@ export async function pickTeam(if (teams.length <= 1) {return teams.find((team) => team.current)?.slug ?? (await whoamiScope(projectRoot, options));}+ const currentTeam = teams.find((team) => team.current);return prompter.select({- message: "Select your team",+ message:+ options.selectMessage?.(currentTeam?.name ?? (await whoamiScope(projectRoot, options))) ??+ "Select your team",search: true,placeholder: "type to search teams",options: teams.map((team) => ({value: team.slug,label: team.current ? `${team.name} (current)` : team.name,})),- initialValue: teams.find((team) => team.current)?.slug,+ initialValue: currentTeam?.slug,});}