Skip to content

armgit / eve

Public Imported from GitHub
0

The Open Framework for Building Agents

feat(eve): guide coding agents through eve init instead of scaffolding (#64)

Rui3a64a8f826da
diff --git a/.changeset/init-agent-setup-guide.md b/.changeset/init-agent-setup-guide.md
new file mode 100644
index 000000000..9c4552152
--- /dev/null
+++ b/.changeset/init-agent-setup-guide.md
@@ -0,0 +1,5 @@
+---
+"eve": patch
+---
+
+`eve init` with no target, when run by a coding agent, now prints a setup guide — what to ask the user, then the scaffold command — instead of scaffolding the current directory. The guide routes both channels (Slack credentials) and connections (per-user OAuth) through Vercel Connect so credentials are provisioned rather than hand-managed. `eve init <name>` and `eve init .` are unchanged.
diff --git a/.changeset/init-repl-handoff.md b/.changeset/init-repl-handoff.md
new file mode 100644
index 000000000..85d85fcd1
--- /dev/null
+++ b/.changeset/init-repl-handoff.md
@@ -0,0 +1,5 @@
+---
+"eve": patch
+---
+
+`eve init` now offers to open an installed coding-agent REPL when its CLI is on `PATH`, while keeping `eve dev` as the default. It detects Claude Code, Codex, Cursor, Droid, Gemini CLI, opencode, and Pi. The selected REPL starts with a project-specific setup prompt and `eve dev --no-ui` verification guidance. Coding-agent and non-interactive launches, plus systems without any supported CLI, keep the existing development-server handoff.
diff --git a/docs/getting-started.mdx b/docs/getting-started.mdx
index 7b05f12f6..f09ee6070 100644
--- a/docs/getting-started.mdx
+++ b/docs/getting-started.mdx
@@ -38,10 +38,15 @@ The command:
- Creates a child directory using the current workspace or launcher package manager, and uses eve's default model
- Installs dependencies and initializes Git
-- Starts the development server and opens the interactive [terminal UI](./guides/dev-tui)
+- When a supported coding-agent REPL (Claude Code, Codex, Cursor, Droid, Gemini CLI, opencode, or Pi) is on `PATH`, asks whether to open an available REPL or start the development server; otherwise starts the server and opens the interactive [terminal UI](./guides/dev-tui)
Type a message and watch the model loop run. Pass `--channel-web-nextjs` to add the Web Chat application. Every app ships the built-in HTTP channel (`agent/channels/eve.ts`) regardless.
+When you choose one of those REPLs, eve starts it with a project-specific
+prompt that guides the setup. The prompt distinguishes `eve dev`, which starts
+eve's HMR server and the agent's terminal REPL, from `eve dev --no-ui`, which is
+the controllable background mode for verification.
+
`eve init` holds the terminal, so stop it with Ctrl+C to get your shell back before editing the generated agent. The command does not create a Vercel project or deploy.
To add eve to an existing project, run `eve init .` from a directory that already has a `package.json` and no `agent/` files yet. eve adds the missing `eve`, `ai`, and `zod` dependencies without touching anything else the project owns. The eve dependency and the Node engine come from the same release. eve pins `engines.node` to the lowest major that release supports (for example `24.x`). It keeps an existing range only when every version that range allows stays within that major; otherwise it replaces the range and prints a warning.
@@ -186,10 +191,10 @@ See [Sessions, runs and streaming](./concepts/sessions-runs-and-streaming) for t
If a coding agent (Claude Code, Cursor, and the like) is doing the setup, hand it this prompt:
-<CopyPrompt text="Set up an eve agent for the user. eve is a filesystem-first TypeScript framework for durable agents, published as the npm package eve. Read its docs: once eve is installed they are bundled in the package at node_modules/eve/docs; before eve is installed, read the published Introduction and Getting Started pages. If the project has no eve app, scaffold one with `npx eve@latest init <name>`; add `--channel-web-nextjs` only when the user wants Web Chat. The init command installs dependencies, initializes Git, and starts the dev server, so run it in a controllable process and stop it with Ctrl+C before editing. To add eve to an existing app, run `eve init .`, or install the dependencies by hand with `npm install eve@latest ai zod` (init adds ai and zod; the by-hand path needs all three). Make sure agent/agent.ts and agent/instructions.md exist, then add a first typed tool at agent/tools/get_weather.ts using defineTool from eve/tools with a Zod inputSchema and an inline execute. Start the dev server again, then exercise the HTTP API: create a session with POST /eve/v1/session, attach to GET /eve/v1/session/:id/stream, and send a follow-up with the returned continuationToken. Verify with the project's typecheck, adapt model and provider choices to the project, and do not commit unless the user asks.">
+<CopyPrompt text="Set up an eve agent for the user. eve is a filesystem-first TypeScript framework for durable agents, published as the npm package eve. Read its docs: once eve is installed they are bundled in the package at node_modules/eve/docs; before eve is installed, read the published Introduction and Getting Started pages. If the project has no eve app, scaffold one with `npx eve@latest init <name>`; add `--channel-web-nextjs` only when the user wants Web Chat. In a coding-agent launch, init installs dependencies and prints the project-specific dev command instead of starting the interactive terminal UI. A fresh project also initializes Git; an existing app keeps its repository and scripts. To add eve to an existing app, run `eve init .`, or install the dependencies by hand with `npm install eve@latest ai zod` (init adds ai and zod; the by-hand path needs all three). Make sure agent/agent.ts and agent/instructions.md exist, then add a first typed tool at agent/tools/get_weather.ts using defineTool from eve/tools with a Zod inputSchema and an inline execute. Start eve in a controllable background process with `npx eve dev --no-ui`, wait for the server URL, then exercise the HTTP API: create a session with POST /eve/v1/session, attach to GET /eve/v1/session/:id/stream, and send a follow-up with the returned continuationToken. Stop the dev process after verification. Verify with the project's typecheck, adapt model and provider choices to the project, and do not commit unless the user asks.">
Set up an eve agent: read the eve docs (bundled at node_modules/eve/docs once eve is
installed), scaffold with `npx eve@latest init <name>` (or `npm install eve@latest ai zod` in an existing app), add
- a typed tool at agent/tools/get_weather.ts, run it with `npm run dev`, then create a session, stream
+ a typed tool at agent/tools/get_weather.ts, run it with `npx eve dev --no-ui`, then create a session, stream
it, and send a follow-up.
</CopyPrompt>
diff --git a/docs/reference/cli.md b/docs/reference/cli.md
index 56513d7ee..5ece67d26 100644
--- a/docs/reference/cli.md
+++ b/docs/reference/cli.md
@@ -33,9 +33,9 @@ The optional `target` decides the mode:
- A name (`eve init my-agent`) scaffolds a fresh project in a new `my-agent/` directory.
- An existing directory, including `.` for the current one (`eve init .`), adds an agent to that project. The project needs a `package.json`, the `agent/` files must not exist yet, and the missing `eve`, `ai`, and `zod` dependencies are added without touching anything else.
-- Omitting the target scaffolds or updates the current directory, the same as `eve init .`.
+- Omitting the target scaffolds or updates the current directory, the same as `eve init .`. The exception is a coding agent (Claude Code, Cursor, and the like): running `eve init` with no target prints a setup guide instead of scaffolding, since a bare invocation means the agent has not chosen what to build yet.
-Either mode installs dependencies, initializes Git, and runs `eve dev` through the detected project package manager. Fresh projects inherit a parent workspace manager when one is present; otherwise they use the manager that launched `eve init`.
+Both scaffold modes install dependencies. A fresh project initializes Git; an existing project keeps its repository and scripts. On an interactive human terminal, when a supported coding-agent CLI (`claude`, `codex`, `cursor-agent`, `droid`, `gemini`, `opencode`, or `pi`) is on `PATH`, `eve init` offers the available REPLs and `eve dev` (the default). Each REPL receives a project-specific prompt that guides the user through building the agent. It also explains that bare `eve dev` starts HMR and the agent's terminal REPL, while `eve dev --no-ui` is the controllable verification path. Without any of those executables, human invocations run `eve dev` through the detected project package manager. Fresh projects inherit a parent workspace manager when one is present; otherwise they use the manager that launched `eve init`. Coding-agent invocations print the same project-specific handoff, and the agent can run that command with `--no-ui` for headless verification.
| Flag | Type | Default | Description |
| ---------------------- | ---- | ------- | -------------------------------------------------------------------------------------------------------------------------------------- |
diff --git a/packages/eve/scripts/copy-runtime-assets.mjs b/packages/eve/scripts/copy-runtime-assets.mjs
index cea2fc5b0..f03467230 100644
--- a/packages/eve/scripts/copy-runtime-assets.mjs
+++ b/packages/eve/scripts/copy-runtime-assets.mjs
@@ -1,18 +1,18 @@
-import { copyFile, mkdir } from "node:fs/promises";
+import { cp, mkdir } from "node:fs/promises";
import { dirname, join } from "node:path";
import { fileURLToPath, pathToFileURL } from "node:url";
const packageRoot = fileURLToPath(new URL("..", import.meta.url));
-const runtimeAssets = [
- "src/cli/commands/init-agent-handoff.md",
- "src/cli/commands/init-agent-instructions.md",
-];
+// The coding-agent setup and handoff prompts are composed at runtime from these
+// section files (see cli/commands/agent-instructions.ts), so they must ship in
+// the package next to the compiled module that reads them.
+const runtimeAssetDirs = ["src/cli/commands/agent-prompt"];
export async function copyRuntimeAssets() {
- for (const relativePath of runtimeAssets) {
+ for (const relativePath of runtimeAssetDirs) {
const destinationPath = join(packageRoot, "dist", relativePath);
await mkdir(dirname(destinationPath), { recursive: true });
- await copyFile(join(packageRoot, relativePath), destinationPath);
+ await cp(join(packageRoot, relativePath), destinationPath, { recursive: true });
}
}
diff --git a/packages/eve/src/cli/commands/agent-instructions.test.ts b/packages/eve/src/cli/commands/agent-instructions.test.ts
index 45c5280f6..e1da4ed12 100644
--- a/packages/eve/src/cli/commands/agent-instructions.test.ts
+++ b/packages/eve/src/cli/commands/agent-instructions.test.ts
@@ -1,36 +1,102 @@
+import { readdirSync } from "node:fs";
+
import { describe, expect, it } from "vitest";
-import { initAgentDevHandoff, initAgentInstructions } from "./agent-instructions.js";
+import {
+ HANDOFF_SECTIONS,
+ initAgentDevHandoff,
+ initAgentInstructions,
+ initAgentReplPrompt,
+ SETUP_SECTIONS,
+} from "./agent-instructions.js";
describe("initAgentInstructions", () => {
// This is the single home for the launching-agent instruction contract; the
// init and scenario tiers assert control flow, not this prose.
- it("tells the agent to collect intent one question at a time and reruns under the launcher", () => {
- const instructions = initAgentInstructions({ initCommand: "pnpm dlx eve init" });
+ it("collects intent one question at a time and scaffolds with a universal command", () => {
+ const instructions = initAgentInstructions();
expect(instructions).toContain("questions one at a time");
expect(instructions).toContain("What should the agent do?");
expect(instructions).toContain("ask the user to confirm it");
expect(instructions).toContain("Web Chat");
expect(instructions).toContain("--channel-web-nextjs");
- expect(instructions).toContain("pnpm dlx eve init <target>");
- // A direct binary run carries no launcher prefix.
- expect(initAgentInstructions({ initCommand: "eve init" })).toContain("eve init <target>");
+ // `npx` runs without a prior install and is package-manager agnostic, so the
+ // pre-scaffold guide renders the universal `npx eve dev` through the shared
+ // prompt renderer rather than a launcher-specific command.
+ expect(instructions).toContain("npx eve@latest init <name>");
+ expect(instructions).toContain("node_modules/eve/docs/");
+ expect(instructions).toContain("npx eve dev --no-ui");
+ expect(instructions).not.toContain("npm run dev");
+ expect(instructions).not.toContain("starts the dev server");
+ // The shared renderer resolves every placeholder, even in the pre-scaffold guide.
+ expect(instructions).not.toContain("{{");
+ });
+
+ it("routes both channels and connections through Vercel Connect", () => {
+ const instructions = initAgentInstructions();
+
+ // Channels: Slack credentials are provisioned by Connect, not hand-managed.
+ expect(instructions).toContain("eve channels add slack");
+ // Connections: per-user auth wires through Connect's eve helper.
+ expect(instructions).toContain("agent/connections/");
+ expect(instructions).toContain("@vercel/connect/eve");
+ // Both surfaces name the product, so neither path is left to hand-rolled tokens.
+ expect(instructions.match(/Vercel Connect/g)?.length ?? 0).toBeGreaterThanOrEqual(2);
});
});
describe("initAgentDevHandoff", () => {
- it("points at the bundled docs, applies the purpose, and hands the dev command to the user", () => {
+ it("composes the shared sections and keeps verification headless", () => {
const handoff = initAgentDevHandoff({
projectPath: "/tmp/triage-bot",
devCommand: "npm exec -- eve dev",
});
- expect(handoff).toContain("/tmp/triage-bot/node_modules/eve/docs/");
- expect(handoff).toContain("/tmp/triage-bot/agent/instructions.md");
- expect(handoff).toContain("purpose you collected");
- expect(handoff).toContain("Do not start `eve dev` because it is interactive");
- expect(handoff).toContain("cd /tmp/triage-bot");
- expect(handoff).toContain("npm exec -- eve dev");
+ // The intro names the scaffolded project; the shared sections then reference
+ // paths relative to it rather than interpolating the working directory.
+ expect(handoff).toContain("The project at `/tmp/triage-bot` is already scaffolded");
+ expect(handoff).toContain("node_modules/eve/docs/");
+ expect(handoff).toContain("agent/instructions.md");
+ expect(handoff).not.toContain("/tmp/triage-bot/");
+
+ // Shared guidance the leaner handoff used to omit now reaches it.
+ expect(handoff).toContain("What should the agent do?");
+ expect(handoff).toContain("Vercel Connect");
+ expect(handoff).toContain("@vercel/connect/eve");
+ expect(handoff).toContain("defineTool");
+
+ // The REPL-versus-headless distinction survives the merge.
+ expect(handoff).toContain("HMR development server");
+ expect(handoff).toContain("does not start or control this coding-agent session");
+ expect(handoff).toMatch(/controllable\s+background process/);
+ expect(handoff).toContain("npm exec -- eve dev --no-ui");
+ expect(handoff).toMatch(/give them the interactive\s+command/);
+ expect(handoff).not.toContain("{{");
+ });
+});
+
+describe("initAgentReplPrompt", () => {
+ it("uses the shared guidance without interpolating the project path into the launch argument", () => {
+ const prompt = initAgentReplPrompt({ devCommand: "pnpm exec eve dev" });
+
+ expect(prompt).toContain("The project at `.` is already scaffolded.");
+ expect(prompt).toContain("What should the agent do?");
+ expect(prompt).toContain("pnpm exec eve dev --no-ui");
+ expect(prompt).not.toContain("{{");
+ });
+});
+
+describe("agent-prompt sections", () => {
+ // Ties the composed section lists to the files on disk: renaming, removing, or
+ // adding a section file fails here unless every prompt that should use it is
+ // updated, so the lists cannot silently drift away from `agent-prompt/`.
+ it("references exactly the section files present in agent-prompt/", () => {
+ const onDisk = readdirSync(new URL("./agent-prompt/", import.meta.url))
+ .filter((name) => name.endsWith(".md"))
+ .sort();
+ const referenced = [...new Set([...SETUP_SECTIONS, ...HANDOFF_SECTIONS])].sort();
+
+ expect(referenced).toEqual(onDisk);
});
});
diff --git a/packages/eve/src/cli/commands/agent-instructions.ts b/packages/eve/src/cli/commands/agent-instructions.ts
index 3e46b1d43..cbe1627f0 100644
--- a/packages/eve/src/cli/commands/agent-instructions.ts
+++ b/packages/eve/src/cli/commands/agent-instructions.ts
@@ -1,18 +1,71 @@
import { readFileSync } from "node:fs";
-function readTemplate(fileName: string): string {
- return readFileSync(new URL(fileName, import.meta.url), "utf8").trim();
+// The two coding-agent prompts are one onboarding flow in two phases, composed
+// from the section files in `agent-prompt/`. The setup guide runs before
+// anything is scaffolded (a bare `eve init`); the handoff runs once a project
+// exists (after `eve init <name>`, or when seeding a REPL). They share the
+// `collect-intent`, `vercel-connect`, and `build-and-verify` sections verbatim,
+// so guidance authored once reaches both. `{{devCommand}}` is rendered per
+// caller; `{{workingDirectory}}` is post-scaffold only and lives in the handoff
+// intro. The shared sections use paths relative to the project directory so the
+// setup guide, which has no working directory yet, can reuse them unchanged.
+// Exported so `agent-instructions.test.ts` can assert these lists name exactly
+// the files in `agent-prompt/`, which is what keeps them from drifting.
+/** Ordered `agent-prompt/` sections composed into the pre-scaffold setup guide. */
+export const SETUP_SECTIONS = [
+ "intro-setup.md",
+ "collect-intent.md",
+ "vercel-connect.md",
+ "scaffold.md",
+ "build-and-verify.md",
+] as const;
+
+/** Ordered `agent-prompt/` sections composed into the post-scaffold handoff. */
+export const HANDOFF_SECTIONS = [
+ "intro-handoff.md",
+ "collect-intent.md",
+ "vercel-connect.md",
+ "build-and-verify.md",
+] as const;
+
+function compose(
+ sections: readonly string[],
+ options: { devCommand: string; workingDirectory?: string },
+): string {
+ const prompt = sections
+ .map((section) =>
+ readFileSync(new URL(`./agent-prompt/${section}`, import.meta.url), "utf8").trim(),
+ )
+ .join("\n\n")
+ .replaceAll("{{devCommand}}", () => options.devCommand);
+ const { workingDirectory } = options;
+ if (workingDirectory === undefined) {
+ return prompt;
+ }
+ return prompt.replaceAll("{{workingDirectory}}", () => workingDirectory);
}
-export function initAgentInstructions(options: { initCommand: string }): string {
- return readTemplate("./init-agent-instructions.md").replace(
- "{{initCommand}}",
- () => options.initCommand,
- );
+/**
+ * The pre-scaffold setup guide, shown when a coding agent runs a bare
+ * `eve init`. It scaffolds from scratch, so it renders with the universal
+ * `npx eve dev` rather than a launcher-specific command.
+ */
+export function initAgentInstructions(): string {
+ return compose(SETUP_SECTIONS, { devCommand: "npx eve dev" });
}
+/** The post-scaffold handoff printed after a coding agent runs `eve init <name>`. */
export function initAgentDevHandoff(options: { projectPath: string; devCommand: string }): string {
- return readTemplate("./init-agent-handoff.md")
- .replaceAll("{{projectPath}}", () => options.projectPath)
- .replace("{{devCommand}}", () => options.devCommand);
+ return compose(HANDOFF_SECTIONS, {
+ devCommand: options.devCommand,
+ workingDirectory: options.projectPath,
+ });
+}
+
+/** The initial prompt for a coding-agent REPL opened inside the scaffolded project. */
+export function initAgentReplPrompt(options: { devCommand: string }): string {
+ return compose(HANDOFF_SECTIONS, {
+ devCommand: options.devCommand,
+ workingDirectory: ".",
+ });
}
diff --git a/packages/eve/src/cli/commands/agent-prompt/build-and-verify.md b/packages/eve/src/cli/commands/agent-prompt/build-and-verify.md
new file mode 100644
index 000000000..4ac5449b4
--- /dev/null
+++ b/packages/eve/src/cli/commands/agent-prompt/build-and-verify.md
@@ -0,0 +1,33 @@
+## Build it out, then verify
+
+Work from the project directory. Once eve is installed, the full docs are bundled
+at `node_modules/eve/docs/` and match the installed version exactly. Read
+`README.md` there first, then the guide for what you're adding, such as
+`connections`, `channels/slack`, or `guides/auth-and-route-protection` for the
+Vercel Connect flow.
+
+- Put the purpose in `agent/instructions.md` (the always-on system prompt),
+ replacing the scaffold's placeholder with what the user said the agent should
+ do.
+- Add a first typed tool under `agent/tools/` with `defineTool` from `eve/tools`
+ and a Zod `inputSchema`.
+
+`{{devCommand}}` starts eve's HMR development server and opens the agent's
+terminal REPL. It does not start or control this coding-agent session, so don't
+use the bare command as a background verification process. Start eve without the
+terminal UI in a controllable background process instead:
+
+ {{devCommand}} --no-ui
+
+Wait for the server URL, then exercise the HTTP API: create a session with
+`POST /eve/v1/session`, attach to `GET /eve/v1/session/:id/stream`, and send a
+follow-up with the returned `continuationToken`. Stop the dev process after
+verification.
+
+When the user is ready to use their agent's REPL, give them the interactive
+command to run from the project directory:
+
+ {{devCommand}}
+
+Verify the project's typecheck passes, adapt the model and provider to the user's
+data and use case, and don't commit unless the user asks.
diff --git a/packages/eve/src/cli/commands/agent-prompt/collect-intent.md b/packages/eve/src/cli/commands/agent-prompt/collect-intent.md
new file mode 100644
index 000000000..9ac2e5e3e
--- /dev/null
+++ b/packages/eve/src/cli/commands/agent-prompt/collect-intent.md
@@ -0,0 +1,18 @@
+## Collect intent
+
+If the user's intent is not already clear, ask the questions one at a time, use
+the coding harness's prompt tools when available, and do not guess.
+
+1. What should the agent do? This becomes its always-on purpose.
+2. Where should it be reachable? Every agent ships the built-in HTTP channel. On
+ top of that:
+ - **Web Chat** (a Next.js app): add it at init with `--channel-web-nextjs`.
+ - **Slack** and other platforms: add after deploy with `eve channels add slack`.
+ Credentials run through **Vercel Connect**, which provisions the bot token
+ and verifies inbound webhooks, so there is no `SLACK_BOT_TOKEN` or signing
+ secret to manage.
+3. Which external systems does it need programmatic read/write access to, such as
+ Slack, Salesforce, Linear, GitHub, or your own API? Each becomes a connection
+ under `agent/connections/`. When a system needs every end-user to sign in, wire
+ its auth through **Vercel Connect** (`connect()` from `@vercel/connect/eve`),
+ which handles consent, encrypted token storage, and refresh.
diff --git a/packages/eve/src/cli/commands/agent-prompt/intro-handoff.md b/packages/eve/src/cli/commands/agent-prompt/intro-handoff.md
new file mode 100644
index 000000000..41308df0e
--- /dev/null
+++ b/packages/eve/src/cli/commands/agent-prompt/intro-handoff.md
@@ -0,0 +1,4 @@
+# Build this eve agent with the user
+
+The project at `{{workingDirectory}}` is already scaffolded. Work with the user to
+complete it, running the commands below from that directory.
diff --git a/packages/eve/src/cli/commands/agent-prompt/intro-setup.md b/packages/eve/src/cli/commands/agent-prompt/intro-setup.md
new file mode 100644
index 000000000..8c79e970f
--- /dev/null
+++ b/packages/eve/src/cli/commands/agent-prompt/intro-setup.md
@@ -0,0 +1,5 @@
+# Set up an eve agent
+
+eve is a filesystem-first framework for durable backend AI agents. The agent is a
+directory of files that eve compiles and runs: its instructions, tools,
+connections, and channels. Work through this with the user.
diff --git a/packages/eve/src/cli/commands/agent-prompt/scaffold.md b/packages/eve/src/cli/commands/agent-prompt/scaffold.md
new file mode 100644
index 000000000..9cad74780
--- /dev/null
+++ b/packages/eve/src/cli/commands/agent-prompt/scaffold.md
@@ -0,0 +1,19 @@
+## Scaffold
+
+First settle the target: a new project, or the agent added to an existing
+directory? For a new project, propose a name and ask the user to confirm it; for
+an existing one, ask for the directory.
+
+For a new project, run (append `--channel-web-nextjs` only if the user wants Web
+Chat):
+
+ npx eve@latest init <name>
+
+This creates the project, installs its dependencies, and initializes Git. Since a
+coding agent launched init, it prints a development handoff instead of starting
+the interactive terminal UI.
+
+For an existing app, run `npx eve@latest init .` from its directory. This adds the
+agent and missing dependencies while leaving the existing Git repository and app
+scripts alone. If init cannot be used, install by hand with
+`npm install eve@latest ai zod`; manual installation does not add package scripts.
diff --git a/packages/eve/src/cli/commands/agent-prompt/vercel-connect.md b/packages/eve/src/cli/commands/agent-prompt/vercel-connect.md
new file mode 100644
index 000000000..5fad0037a
--- /dev/null
+++ b/packages/eve/src/cli/commands/agent-prompt/vercel-connect.md
@@ -0,0 +1,3 @@
+Reach for Vercel Connect for both channels and connections rather than
+hand-managing tokens. It is the path to a working setup out of the box. See
+https://vercel.com/docs/connect.
diff --git a/packages/eve/src/cli/commands/init-agent-handoff.md b/packages/eve/src/cli/commands/init-agent-handoff.md
deleted file mode 100644
index d38be642a..000000000
--- a/packages/eve/src/cli/commands/init-agent-handoff.md
+++ /dev/null
@@ -1,12 +0,0 @@
-Before editing the scaffold, read the relevant guide in
-`{{projectPath}}/node_modules/eve/docs/`.
-
-Then open `{{projectPath}}/agent/instructions.md` and replace the placeholder
-with what the user said the agent should do (the purpose you collected). This
-is the agent's always-on system prompt.
-
-Do not start `eve dev` because it is interactive. Give the user this command to
-run when they are ready:
-
- cd {{projectPath}}
- {{devCommand}}
diff --git a/packages/eve/src/cli/commands/init-agent-instructions.md b/packages/eve/src/cli/commands/init-agent-instructions.md
deleted file mode 100644
index 3f0d6682c..000000000
--- a/packages/eve/src/cli/commands/init-agent-instructions.md
+++ /dev/null
@@ -1,16 +0,0 @@
-# Set up an eve agent
-
-Ask the user these questions one at a time. Use the coding harness's prompt
-tools when available. Do not guess.
-
-1. What should the agent do?
-2. Create a new project or add the agent to an existing directory?
- For a new project, propose a name and ask the user to confirm it. For an
- existing project, ask for the directory.
-3. For a new project, include Web Chat?
-
-Then run:
-
- {{initCommand}} <target>
-
-Add `--channel-web-nextjs` if the user wants Web Chat.
diff --git a/packages/eve/src/cli/commands/init-repl.integration.test.ts b/packages/eve/src/cli/commands/init-repl.integration.test.ts
new file mode 100644
index 000000000..ae38d0dde
--- /dev/null
+++ b/packages/eve/src/cli/commands/init-repl.integration.test.ts
@@ -0,0 +1,36 @@
+import { chmod, mkdtemp, rm, writeFile } from "node:fs/promises";
+import { tmpdir } from "node:os";
+import { join } from "node:path";
+
+import { afterEach, describe, expect, it, vi } from "vitest";
+
+import { isCodingAgentReplAvailable, resolveCodingAgentRepl } from "./init-repl.js";
+
+let temporaryDirectory: string | undefined;
+
+afterEach(async () => {
+ vi.unstubAllEnvs();
+ if (temporaryDirectory !== undefined) {
+ await rm(temporaryDirectory, { force: true, recursive: true });
+ temporaryDirectory = undefined;
+ }
+});
+
+describe("isCodingAgentReplAvailable", () => {
+ it("finds an executable coding-agent REPL on PATH", async () => {
+ temporaryDirectory = await mkdtemp(join(tmpdir(), "eve-init-repl-"));
+ const executableName = process.platform === "win32" ? "claude.EXE" : "claude";
+ const executablePath = join(temporaryDirectory, executableName);
+ await writeFile(executablePath, "", "utf8");
+ await chmod(executablePath, 0o755);
+ vi.stubEnv("PATH", temporaryDirectory);
+ if (process.platform === "win32") vi.stubEnv("PATHEXT", ".EXE");
+
+ await expect(isCodingAgentReplAvailable("claude")).resolves.toBe(true);
+ await expect(isCodingAgentReplAvailable("codex")).resolves.toBe(false);
+
+ // The resolver returns the full path so the spawn can run shell-free.
+ await expect(resolveCodingAgentRepl("claude")).resolves.toBe(executablePath);
+ await expect(resolveCodingAgentRepl("codex")).resolves.toBeNull();
+ });
+});
diff --git a/packages/eve/src/cli/commands/init-repl.test.ts b/packages/eve/src/cli/commands/init-repl.test.ts
new file mode 100644
index 000000000..13406a0c1
--- /dev/null
+++ b/packages/eve/src/cli/commands/init-repl.test.ts
@@ -0,0 +1,229 @@
+import { ChildProcess, spawn } from "node:child_process";
+
+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
+
+import { createFakePrompter, type FakePrompterConfig } from "#internal/testing/fake-prompter.js";
+
+import {
+ replSpawnPlan,
+ selectInitHandoff,
+ spawnCodingAgentRepl,
+ type CodingAgentRepl,
+ type InitReplDependencies,
+} from "./init-repl.js";
+
+vi.mock("node:child_process", async (importOriginal) => ({
+ ...(await importOriginal<typeof import("node:child_process")>()),
+ spawn: vi.fn(),
+}));
+
+const mockedSpawn = vi.mocked(spawn);
+
+beforeEach(() => {
+ vi.clearAllMocks();
+});
+
+afterEach(() => {
+ vi.unstubAllEnvs();
+});
+
+function dependencies(
+ input: {
+ available?: readonly string[];
+ interactive?: boolean;
+ onSelect?: FakePrompterConfig["single"];
+ } = {},
+): InitReplDependencies {
+ const fake = createFakePrompter({ single: input.onSelect });
+ return {
+ createPrompter: vi.fn(() => fake.prompter),
+ hasInteractiveTerminal: vi.fn(() => input.interactive ?? true),
+ isCodingAgentReplAvailable: vi.fn(
+ async (command) => input.available?.includes(command) ?? false,
+ ),
+ };
+}
+
+describe("selectInitHandoff", () => {
+ it("keeps non-interactive sessions on the direct eve dev path", async () => {
+ const deps = dependencies({ interactive: false, available: ["claude"] });
+
+ await expect(selectInitHandoff({ deps, agentName: "weather-bot" })).resolves.toBe("eve-dev");
+ expect(deps.isCodingAgentReplAvailable).not.toHaveBeenCalled();
+ expect(deps.createPrompter).not.toHaveBeenCalled();
+ });
+
+ it("keeps the direct eve dev path when no supported REPL is installed", async () => {
+ const deps = dependencies();
+
+ await expect(selectInitHandoff({ deps, agentName: "weather-bot" })).resolves.toBe("eve-dev");
+ expect(
+ vi.mocked(deps.isCodingAgentReplAvailable).mock.calls.map(([command]) => command),
+ ).toEqual(["claude", "codex", "cursor-agent", "droid", "gemini", "opencode", "pi"]);
+ expect(deps.createPrompter).not.toHaveBeenCalled();
+ });
+
+ it("starts every availability check before waiting for one to finish", async () => {
+ let releaseAvailabilityChecks: () => void;
+ const availabilityGate = new Promise<void>((resolve) => {
+ releaseAvailabilityChecks = resolve;
+ });
+ const isCodingAgentReplAvailable = vi.fn(async (_command: CodingAgentRepl) => {
+ await availabilityGate;
+ return false;
+ });
+ const deps: InitReplDependencies = {
+ createPrompter: vi.fn(),
+ hasInteractiveTerminal: vi.fn(() => true),
+ isCodingAgentReplAvailable,
+ };
+
+ const handoff = selectInitHandoff({ deps, agentName: "weather-bot" });
+ const checksStartedBeforeAnyFinished = isCodingAgentReplAvailable.mock.calls.length;
+ releaseAvailabilityChecks!();
+
+ await expect(handoff).resolves.toBe("eve-dev");
+ expect(checksStartedBeforeAnyFinished).toBe(7);
+ });
+
+ it("offers only available REPLs and preserves eve dev as the default", async () => {
+ const deps = dependencies({
+ available: ["codex"],
+ onSelect: (options) => {
+ expect(options.message).toBe("How would you like to continue?");
+ expect(options.initialValue).toBe("eve-dev");
+ expect(options.options.map((option) => option.value)).toEqual(["eve-dev", "codex"]);
+ expect(options.options.map((option) => option.focusHint)).toEqual([
+ "talk to 'weather-bot' in your terminal",
+ "build 'weather-bot' using Codex",
+ ]);
+ // Hints are focus-only, like the dev TUI lists, so no always-on hint is set.
+ expect(options.options.every((option) => option.hint === undefined)).toBe(true);
+ return "codex";
+ },
+ });
+
+ await expect(selectInitHandoff({ deps, agentName: "weather-bot" })).resolves.toBe("codex");
+ });
+});
+
+describe("replSpawnPlan", () => {
+ // A prompt with the newline and cmd metacharacters that break a shell launch.
+ const PROMPT = "line one\nline two (with parens) & a pipe |";
+
+ // Each REPL seeds its prompt differently once spawned shell-free: most take a
+ // bare positional prompt, Gemini needs `-i`, opencode needs `--prompt`.
+ it.each([
+ { command: "claude", args: [PROMPT] },
+ { command: "codex", args: [PROMPT] },
+ { command: "cursor-agent", args: [PROMPT] },
+ { command: "droid", args: [PROMPT] },
+ { command: "gemini", args: ["-i", PROMPT] },
+ { command: "opencode", args: ["--prompt", PROMPT] },
+ { command: "pi", args: [PROMPT] },
+ ] as const)("seeds $command verbatim when spawned shell-free", ({ command, args }) => {
+ expect(replSpawnPlan(command, "/usr/local/bin/agent", PROMPT, "linux")).toEqual({
+ file: "/usr/local/bin/agent",
+ args,
+ shell: false,
+ seeded: true,
+ });
+ });
+
+ it("spawns a resolved Windows .exe shell-free, prompt intact", () => {
+ expect(replSpawnPlan("claude", "C:\\bin\\claude.EXE", PROMPT, "win32")).toEqual({
+ file: "C:\\bin\\claude.EXE",
+ args: [PROMPT],
+ shell: false,
+ seeded: true,
+ });
+ });
+
+ it("launches a Windows .cmd shim bare, leaving the prompt unseeded", () => {
+ expect(replSpawnPlan("claude", "C:\\bin\\claude.CMD", PROMPT, "win32")).toEqual({
+ file: "claude",
+ args: [],
+ shell: true,
+ seeded: false,
+ });
+ });
+
+ it("launches bare when the command does not resolve", () => {
+ expect(replSpawnPlan("claude", null, PROMPT, "linux")).toEqual({
+ file: "claude",
+ args: [],
+ shell: false,
+ seeded: false,
+ });
+ expect(replSpawnPlan("claude", null, PROMPT, "win32").shell).toBe(true);
+ });
+});
+
+describe("spawnCodingAgentRepl", () => {
+ const PROMPT = "Help the user build their eve agent.";
+
+ async function awaitSpawn(): Promise<void> {
+ await vi.waitFor(() => expect(mockedSpawn).toHaveBeenCalled());
+ }
+
+ it("spawns the resolved executable shell-free and resolves true on clean exit", async () => {
+ const child = new ChildProcess();
+ mockedSpawn.mockReturnValue(child);
+
+ const result = spawnCodingAgentRepl({
+ command: "claude",
+ cwd: "/tmp/triage-bot",
+ prompt: PROMPT,
+ resolvePath: async () => "/usr/local/bin/claude",
+ });
+ await awaitSpawn();
+ child.emit("close", 0);
+
+ await expect(result).resolves.toBe(true);
+ expect(mockedSpawn).toHaveBeenCalledWith(
+ "/usr/local/bin/claude",
+ [PROMPT],
+ expect.objectContaining({ cwd: "/tmp/triage-bot", shell: false, stdio: "inherit" }),
+ );
+ });
+
+ it("surfaces the prompt and launches bare when the command cannot be seeded", async () => {
+ const child = new ChildProcess();
+ mockedSpawn.mockReturnValue(child);
+ const onPromptUnseeded = vi.fn();
+
+ const result = spawnCodingAgentRepl({
+ command: "claude",
+ cwd: "/tmp/triage-bot",
+ prompt: PROMPT,
+ resolvePath: async () => null,
+ onPromptUnseeded,
+ });
+ await awaitSpawn();
+ child.emit("close", 0);
+
+ await expect(result).resolves.toBe(true);
+ expect(onPromptUnseeded).toHaveBeenCalledWith(PROMPT);
+ expect(mockedSpawn).toHaveBeenCalledWith(
+ "claude",
+ [],
+ expect.objectContaining({ cwd: "/tmp/triage-bot", stdio: "inherit" }),
+ );
+ });
+
+ it("resolves false when the spawn errors", async () => {
+ const child = new ChildProcess();
+ mockedSpawn.mockReturnValue(child);
+
+ const result = spawnCodingAgentRepl({
+ command: "claude",
+ cwd: "/tmp/triage-bot",
+ prompt: PROMPT,
+ resolvePath: async () => "/usr/local/bin/claude",
+ });
+ await awaitSpawn();
+ child.emit("error", new Error("spawn failed"));
+
+ await expect(result).resolves.toBe(false);
+ });
+});
diff --git a/packages/eve/src/cli/commands/init-repl.ts b/packages/eve/src/cli/commands/init-repl.ts
new file mode 100644
index 000000000..5e755c9c1
--- /dev/null
+++ b/packages/eve/src/cli/commands/init-repl.ts
@@ -0,0 +1,213 @@
+import { spawn } from "node:child_process";
+import { constants } from "node:fs";
+import { access, stat } from "node:fs/promises";
+import { delimiter, extname, join } from "node:path";
+
+import { createPrompter, type Prompter, type SelectOption } from "#setup/prompter.js";
+
+import { hasInteractiveTerminal } from "./preconditions.js";
+
+// `promptArgs` is each harness's documented way to open its interactive REPL
+// seeded with an initial prompt. Most take a bare positional argument; Gemini
+// treats a positional as a one-shot query and needs `-i`, and opencode treats a
+// positional as a project path and needs `--prompt`.
+const positional = (prompt: string) => [prompt];
+const CODING_AGENT_REPLS = [
+ { command: "claude", label: "Claude Code", promptArgs: positional },
+ { command: "codex", label: "Codex", promptArgs: positional },
+ { command: "cursor-agent", label: "Cursor", promptArgs: positional },
+ { command: "droid", label: "Droid", promptArgs: positional },
+ { command: "gemini", label: "Gemini CLI", promptArgs: (prompt: string) => ["-i", prompt] },
+ { command: "opencode", label: "opencode", promptArgs: (prompt: string) => ["--prompt", prompt] },
+ { command: "pi", label: "Pi", promptArgs: positional },
+] as const;
+
+// Node exposes no PATH/PATHEXT-aware executable resolver, so availability is
+// probed by hand. `executableNames` reads the OS's own `PATHEXT` first; this
+// list is only the fallback for the rare shell that leaves it unset.
+const WINDOWS_EXECUTABLE_EXTENSIONS = [".COM", ".EXE", ".BAT", ".CMD"];
+
+type CodingAgentReplDefinition = (typeof CODING_AGENT_REPLS)[number];
+
+/** A coding-agent REPL that can take over the terminal after `eve init`. */
+export type CodingAgentRepl = CodingAgentReplDefinition["command"];
+
+/** The one post-init continuation point for a human terminal session. */
+export type InitHandoff = "eve-dev" | CodingAgentRepl;
+
+export interface InitReplDependencies {
+ createPrompter(): Prompter;
+ hasInteractiveTerminal(): boolean;
+ isCodingAgentReplAvailable(command: CodingAgentRepl): Promise<boolean>;
+}
+
+const defaultDependencies: InitReplDependencies = {
+ createPrompter,
+ hasInteractiveTerminal,
+ isCodingAgentReplAvailable,
+};
+
+function executableNames(command: string): readonly string[] {
+ if (process.platform !== "win32") return [command];
+
+ const extensions = process.env.PATHEXT?.split(";").filter(Boolean);
+ return (extensions && extensions.length > 0 ? extensions : WINDOWS_EXECUTABLE_EXTENSIONS).map(
+ (extension) => `${command}${extension}`,
+ );
+}
+
+async function isExecutable(filePath: string): Promise<boolean> {
+ try {
+ if (!(await stat(filePath)).isFile()) return false;
+ await access(filePath, constants.X_OK);
+ return true;
+ } catch {
+ return false;
+ }
+}
+
+/** The full path of the named REPL's executable on `PATH`, or null if absent. */
+export async function resolveCodingAgentRepl(command: CodingAgentRepl): Promise<string | null> {
+ const path = process.env.PATH;
+ if (path === undefined || path.length === 0) return null;
+
+ for (const directory of path.split(delimiter)) {
+ if (directory.length === 0) continue;
+ for (const executableName of executableNames(command)) {
+ const candidate = join(directory, executableName);
+ if (await isExecutable(candidate)) return candidate;
+ }
+ }
+ return null;
+}
+
+/** True when the named REPL resolves to an executable on the current `PATH`. */
+export async function isCodingAgentReplAvailable(command: CodingAgentRepl): Promise<boolean> {
+ return (await resolveCodingAgentRepl(command)) !== null;
+}
+
+// `focusHint` (not `hint`) so the menu reads like the dev TUI lists: only the
+// highlighted row shows its hint, rather than every row at once.
+function handoffOptions(
+ availableRepls: readonly CodingAgentReplDefinition[],
+ agentName: string,
+): SelectOption<InitHandoff>[] {
+ return [
+ {
+ value: "eve-dev",
+ label: "Start eve dev",
+ focusHint: `talk to '${agentName}' in your terminal`,
+ },
+ ...availableRepls.map((repl) => ({
+ value: repl.command,
+ label: `Open ${repl.label}`,
+ focusHint: `build '${agentName}' using ${repl.label}`,
+ })),
+ ];
+}
+
+/**
+ * Offers any locally installed coding-agent REPLs immediately before the
+ * existing `eve dev` handoff. Non-interactive sessions, and systems with none
+ * of them on `PATH`, keep the prior direct-to-dev behavior.
+ */
+export async function selectInitHandoff(input: {
+ agentName: string;
+ deps?: Partial<InitReplDependencies>;
+}): Promise<InitHandoff> {
+ const dependencies: InitReplDependencies = { ...defaultDependencies, ...input.deps };
+ if (!dependencies.hasInteractiveTerminal()) return "eve-dev";
+
+ const availability = await Promise.all(
+ CODING_AGENT_REPLS.map(({ command }) => dependencies.isCodingAgentReplAvailable(command)),
+ );
+ const availableRepls = CODING_AGENT_REPLS.filter((_, index) => availability[index]);
+ if (availableRepls.length === 0) return "eve-dev";
+
+ return dependencies.createPrompter().select<InitHandoff>({
+ message: "How would you like to continue?",
+ options: handoffOptions(availableRepls, input.agentName),
+ initialValue: "eve-dev",
+ });
+}
+
+function codingAgentRepl(command: CodingAgentRepl): CodingAgentReplDefinition {
+ const definition = CODING_AGENT_REPLS.find((repl) => repl.command === command);
+ if (definition === undefined) {
+ throw new Error(`Unsupported coding-agent REPL "${command}".`);
+ }
+ return definition;
+}
+
+// Only PE executables (.exe/.com) can be launched without a shell on Windows;
+// .cmd/.bat shims must go through cmd.exe. Everything on POSIX runs directly.
+function isDirectlySpawnable(resolvedPath: string, platform: NodeJS.Platform): boolean {
+ if (platform !== "win32") return true;
+ const extension = extname(resolvedPath).toLowerCase();
+ return extension === ".exe" || extension === ".com";
+}
+
+interface ReplSpawnPlan {
+ file: string;
+ args: readonly string[];
+ shell: boolean;
+ /** False means the prompt is not in argv and the caller must surface it. */
+ seeded: boolean;
+}
+
+/**
+ * Decides how to launch a REPL from its resolved executable path. A directly
+ * spawnable executable runs without a shell, so the multi-line prompt passes
+ * through argv verbatim. A `.cmd`/`.bat` shim (or an unresolved command) can
+ * only run via cmd.exe, which cannot carry the prompt's newlines or
+ * metacharacters in an argument, so it launches the bare REPL and reports the
+ * prompt as unseeded.
+ */
+export function replSpawnPlan(
+ command: CodingAgentRepl,
+ resolvedPath: string | null,
+ prompt: string,
+ platform: NodeJS.Platform = process.platform,
+): ReplSpawnPlan {
+ if (resolvedPath !== null && isDirectlySpawnable(resolvedPath, platform)) {
+ return {
+ file: resolvedPath,
+ args: codingAgentRepl(command).promptArgs(prompt),
+ shell: false,
+ seeded: true,
+ };
+ }
+ return { file: command, args: [], shell: platform === "win32", seeded: false };
+}
+
+/** Starts the selected coding-agent REPL in the newly initialized project. */
+export async function spawnCodingAgentRepl(input: {
+ command: CodingAgentRepl;
+ cwd: string;
+ prompt: string;
+ /** Surfaces the prompt when it could not be seeded into the REPL's argv. */
+ onPromptUnseeded?: (prompt: string) => void;
+ resolvePath?: (command: CodingAgentRepl) => Promise<string | null>;
+}): Promise<boolean> {
+ const resolvePath = input.resolvePath ?? resolveCodingAgentRepl;
+ const plan = replSpawnPlan(input.command, await resolvePath(input.command), input.prompt);
+ if (!plan.seeded) {
+ input.onPromptUnseeded?.(input.prompt);
+ }
+ return new Promise((resolve) => {
+ const child = spawn(plan.file, plan.args, {
+ cwd: input.cwd,
+ shell: plan.shell,
+ stdio: "inherit",
+ });
+ let settled = false;
+ const settle = (ok: boolean) => {
+ if (settled) return;
+ settled = true;
+ resolve(ok);
+ };
+
+ child.once("error", () => settle(false));
+ child.once("close", (code) => settle(code === 0));
+ });
+}
diff --git a/packages/eve/src/cli/commands/init.integration.test.ts b/packages/eve/src/cli/commands/init.integration.test.ts
index 9d2628116..10405edcb 100644
--- a/packages/eve/src/cli/commands/init.integration.test.ts
+++ b/packages/eve/src/cli/commands/init.integration.test.ts
@@ -18,8 +18,10 @@ import {
type ScaffoldBaseProjectOptions,
} from "#setup/scaffold/index.js";
import { pathExists } from "#setup/path-exists.js";
+import { WizardCancelledError } from "#setup/step.js";
import type { GitInitResult } from "./init-git.js";
+import { initAgentReplPrompt } from "./agent-instructions.js";
import {
EVE_INIT_PACKAGE_SPEC_ENV,
runInitCommand,
@@ -67,6 +69,8 @@ function dependencies(
runPackageManagerInstall: ReturnType<
typeof vi.fn<InitCommandDependencies["runPackageManagerInstall"]>
>;
+ selectInitHandoff: ReturnType<typeof vi.fn<InitCommandDependencies["selectInitHandoff"]>>;
+ spawnCodingAgentRepl: ReturnType<typeof vi.fn<InitCommandDependencies["spawnCodingAgentRepl"]>>;
spawnPackageManager: ReturnType<typeof vi.fn<InitCommandDependencies["spawnPackageManager"]>>;
tryInitializeGit: ReturnType<typeof vi.fn<InitCommandDependencies["tryInitializeGit"]>>;
} {
@@ -99,6 +103,8 @@ function dependencies(
webPackageVersions: { ...WEB_VERSIONS, ...options.webPackageVersions },
}),
runPackageManagerInstall: vi.fn(async () => true),
+ selectInitHandoff: vi.fn(async () => "eve-dev"),
+ spawnCodingAgentRepl: vi.fn(async () => true),
spawnPackageManager: vi.fn(async () => true),
tryInitializeGit: vi.fn(async () => gitResult),
};
@@ -183,6 +189,53 @@ describe("runInitCommand", () => {
expect(output.messages[3]).toContain("$ eve dev");
});
+ it("opens the selected coding-agent REPL instead of starting eve dev", async () => {
+ const parentDirectory = await mkdtemp(join(tmpdir(), "eve-init-repl-handoff-"));
+ const output = logger();
+ const deps = dependencies();
+ deps.selectInitHandoff.mockResolvedValue("codex");
+
+ await runInitCommand(output, parentDirectory, "my-agent", {}, deps);
+
+ const projectPath = join(parentDirectory, "my-agent");
+ expect(deps.spawnCodingAgentRepl).toHaveBeenCalledWith(
+ expect.objectContaining({
+ command: "codex",
+ cwd: projectPath,
+ prompt: expect.stringContaining("pnpm exec eve dev --no-ui"),
+ }),
+ );
+ const prompt = deps.spawnCodingAgentRepl.mock.calls[0]?.[0].prompt;
+ expect(prompt).toBe(
+ initAgentReplPrompt({
+ devCommand: "pnpm exec eve dev",
+ }),
+ );
+ expect(prompt).toContain("What should the agent do?");
+ expect(prompt).toContain("HMR development server");
+ expect(prompt).not.toContain(projectPath);
+ expect(prompt).not.toContain("{{");
+ expect(deps.spawnPackageManager).not.toHaveBeenCalled();
+ expect(output.messages.at(-1)).toContain("$ codex");
+ });
+
+ it("keeps a completed init successful when its optional handoff is cancelled", async () => {
+ const parentDirectory = await mkdtemp(join(tmpdir(), "eve-init-repl-cancelled-"));
+ const output = logger();
+ const deps = dependencies();
+ deps.selectInitHandoff.mockRejectedValue(new WizardCancelledError());
+
+ await expect(
+ runInitCommand(output, parentDirectory, "my-agent", {}, deps),
+ ).resolves.toBeUndefined();
+
+ const projectPath = join(parentDirectory, "my-agent");
+ await expect(pathExists(join(projectPath, "agent/agent.ts"))).resolves.toBe(true);
+ expect(deps.spawnCodingAgentRepl).not.toHaveBeenCalled();
+ expect(deps.spawnPackageManager).not.toHaveBeenCalled();
+ expect(output.errors).toEqual([]);
+ });
+
it("uses an explicit init package spec for fresh project scaffolds", async () => {
const parentDirectory = await mkdtemp(join(tmpdir(), "eve-init-package-spec-"));
const output = logger();
@@ -609,9 +662,11 @@ describe("runInitCommand", () => {
const output = logger();
const deps = dependencies();
- await expect(runInitCommand(output, parentDirectory, "host-app", {}, deps)).rejects.toThrow(
- "agent/instructions.md",
- );
+ await expect(
+ runInitCommand(output, parentDirectory, "host-app", {}, deps),
+ ).rejects.toMatchObject({
+ message: `Cannot add an eve agent to "${projectRoot}" because it already has: agent/instructions.md.`,
+ });
await expect(pathExists(join(projectRoot, "agent/agent.ts"))).resolves.toBe(false);
expect(await readFile(join(projectRoot, "agent/instructions.md"), "utf8")).toBe("existing\n");
@@ -632,26 +687,23 @@ describe("runInitCommand", () => {
expect(deps.runPackageManagerInstall).not.toHaveBeenCalled();
});
- it("scaffolds the current directory for a coding agent that omits the target", async () => {
+ it("hands a coding agent the setup guide when it omits the target", async () => {
const parentDirectory = await mkdtemp(join(tmpdir(), "eve-init-agent-bare-"));
const output = logger();
const deps = dependencies();
deps.isCodingAgentLaunch.mockResolvedValue(true);
- deps.detectInvokingPackageManager.mockReturnValue("pnpm");
await runInitCommand(output, parentDirectory, undefined, {}, deps);
- expect(await readFile(join(parentDirectory, "agent/agent.ts"), "utf8")).toContain(
- DEFAULT_AGENT_MODEL_ID,
- );
- expect(deps.runPackageManagerInstall).toHaveBeenCalledWith(
- "pnpm",
- parentDirectory,
- expect.anything(),
- );
- expect(deps.tryInitializeGit).toHaveBeenCalledWith(parentDirectory);
+ // A bare `eve init` from an agent means it has not chosen what to build, so
+ // we print the guide and touch nothing — no scaffold, install, Git, or dev.
+ await expect(pathExists(join(parentDirectory, "agent"))).resolves.toBe(false);
+ expect(deps.runPackageManagerInstall).not.toHaveBeenCalled();
+ expect(deps.tryInitializeGit).not.toHaveBeenCalled();
expect(deps.spawnPackageManager).not.toHaveBeenCalled();
- expect(output.messages.join("\n")).toContain("Do not start `eve dev`");
+ const printed = output.messages.join("\n");
+ expect(printed).toContain("Set up an eve agent");
+ expect(printed).toContain("npx eve@latest init <name>");
});
it("scaffolds and initializes Git for a coding agent but does not spawn the dev server", async () => {
@@ -674,6 +726,8 @@ describe("runInitCommand", () => {
expect(deps.tryInitializeGit).toHaveBeenCalledWith(projectPath);
// The dev server is handed off as text, never spawned — the dev TUI would
// wedge the launching agent. The handoff's content is the unit test's job.
+ expect(deps.selectInitHandoff).not.toHaveBeenCalled();
+ expect(deps.spawnCodingAgentRepl).not.toHaveBeenCalled();
expect(deps.spawnPackageManager).not.toHaveBeenCalled();
});
diff --git a/packages/eve/src/cli/commands/init.ts b/packages/eve/src/cli/commands/init.ts
index a121f4784..394be6af5 100644
--- a/packages/eve/src/cli/commands/init.ts
+++ b/packages/eve/src/cli/commands/init.ts
@@ -26,13 +26,19 @@ import {
import type { ProcessOutputLine } from "#setup/primitives/process-output.js";
import { addAgentToProject } from "#setup/scaffold/create/add-to-project.js";
import { ensureChannel, scaffoldBaseProject } from "#setup/scaffold/index.js";
+import { WizardCancelledError } from "#setup/step.js";
import {
DEFAULT_EVE_PACKAGE_CONTRACT,
type EvePackageContract,
} from "#setup/scaffold/create/project.js";
-import { initAgentDevHandoff } from "./agent-instructions.js";
+import {
+ initAgentDevHandoff,
+ initAgentInstructions,
+ initAgentReplPrompt,
+} from "./agent-instructions.js";
import { tryInitializeGit, type GitInitResult } from "./init-git.js";
+import { selectInitHandoff, spawnCodingAgentRepl, type InitHandoff } from "./init-repl.js";
export interface InitCliLogger {
error(message: string): void;
@@ -53,6 +59,8 @@ export interface InitCommandDependencies {
now: () => number;
runPackageManagerInstall: typeof runPackageManagerInstall;
scaffoldBaseProject: typeof scaffoldBaseProject;
+ selectInitHandoff: typeof selectInitHandoff;
+ spawnCodingAgentRepl: typeof spawnCodingAgentRepl;
spawnPackageManager: typeof spawnPackageManager;
tryInitializeGit: typeof tryInitializeGit;
}
@@ -66,6 +74,8 @@ const defaultDependencies: InitCommandDependencies = {
now: () => performance.now(),
runPackageManagerInstall,
scaffoldBaseProject,
+ selectInitHandoff,
+ spawnCodingAgentRepl,
spawnPackageManager,
tryInitializeGit,
};
@@ -390,6 +400,9 @@ async function runInitSteps(input: {
*
* Runs launched by a coding agent get the dev command printed instead of
* spawned after scaffolding, since the dev TUI would wedge the launching agent.
+ * A coding agent that omits the target entirely gets the setup guide printed and
+ * nothing scaffolded, since a bare `eve init` means it has not yet chosen what to
+ * build.
*/
export async function runInitCommand(
logger: InitCliLogger,
@@ -398,6 +411,15 @@ export async function runInitCommand(
options: InitCommandOptions,
dependencies: InitCommandDependencies = defaultDependencies,
): Promise<void> {
+ // A coding agent that runs `eve init` with no target has not decided what to
+ // build yet. Hand it the setup guide (collect intent, then re-run with an
+ // explicit target) rather than silently scaffolding the current directory. A
+ // human, or an explicit `.`/`<name>`, still scaffolds.
+ if (target === undefined && (await dependencies.isCodingAgentLaunch())) {
+ logger.log(initAgentInstructions());
+ return;
+ }
+
const result = await runInitSteps({ dependencies, logger, options, parentDirectory, target });
if (result.kind === "created") {
@@ -420,13 +442,45 @@ export async function runInitCommand(
logger.error(pc.yellow(`Git initialization failed: ${result.gitResult.reason}`));
}
+ const agentDevCommand = [result.packageManager, ...eveDevArguments(result.packageManager)].join(
+ " ",
+ );
+ const agentHandoff = initAgentDevHandoff({
+ projectPath: result.projectPath,
+ devCommand: agentDevCommand,
+ });
+
if (result.agentLaunched) {
- logger.log(
- initAgentDevHandoff({
- projectPath: result.projectPath,
- devCommand: [result.packageManager, ...eveDevArguments(result.packageManager)].join(" "),
- }),
- );
+ logger.log(agentHandoff);
+ return;
+ }
+
+ let handoff: InitHandoff;
+ try {
+ handoff = await dependencies.selectInitHandoff({ agentName: basename(result.projectPath) });
+ } catch (error) {
+ if (error instanceof WizardCancelledError) return;
+ throw error;
+ }
+ if (handoff !== "eve-dev") {
+ logger.log(pc.dim(`$ ${handoff}`));
+ if (
+ !(await dependencies.spawnCodingAgentRepl({
+ command: handoff,
+ cwd: result.projectPath,
+ prompt: initAgentReplPrompt({ devCommand: agentDevCommand }),
+ // A `.cmd`/`.bat` shim can't take the multi-line prompt on its command
+ // line, so print it for the user to paste once the REPL opens.
+ onPromptUnseeded: (prompt) => {
+ logger.log(
+ pc.yellow(`Could not seed ${handoff} automatically. Paste this prompt into it:`),
+ );
+ logger.log(prompt);
+ },
+ }))
+ ) {
+ throw new Error(`Coding-agent REPL exited unsuccessfully in "${result.projectPath}".`);
+ }
return;
}
diff --git a/packages/eve/src/cli/run.test.ts b/packages/eve/src/cli/run.test.ts
index a360b559d..218a88ef4 100644
--- a/packages/eve/src/cli/run.test.ts
+++ b/packages/eve/src/cli/run.test.ts
@@ -42,6 +42,36 @@ describe("CLI command registration", () => {
});
});
+describe("eve init for a coding agent that fumbles the invocation", () => {
+ // Detection must precede the commander failure: a bad/unknown arg trips
+ // parsing before the init action runs, so runCli itself falls back to the guide.
+ it("prints the setup guide but still fails on the malformed invocation", async () => {
+ const output: string[] = [];
+
+ // The guide is additive: the parse failure must still propagate (nonzero
+ // exit), so runCli rejects even though the agent gets actionable next steps.
+ await expect(
+ runCli(
+ ["init", "--unknown-flag"],
+ { error: (message) => output.push(message), log: (message) => output.push(message) },
+ { isCodingAgentLaunch: async () => true },
+ ),
+ ).rejects.toThrow();
+
+ expect(output.join("\n")).toContain("Set up an eve agent");
+ });
+
+ it("still surfaces the usage error for a human", async () => {
+ await expect(
+ runCli(
+ ["init", "--unknown-flag"],
+ { error: () => {}, log: () => {} },
+ { isCodingAgentLaunch: async () => false },
+ ),
+ ).rejects.toThrow();
+ });
+});
+
describe("eve dev --input", () => {
it("forwards the initial draft to the interactive TUI", async () => {
const runDevelopmentTui = vi.fn(async () => {});
diff --git a/packages/eve/src/cli/run.ts b/packages/eve/src/cli/run.ts
index c3fa73f7a..4d4d6b0f9 100644
--- a/packages/eve/src/cli/run.ts
+++ b/packages/eve/src/cli/run.ts
@@ -2,6 +2,7 @@ import { Command, CommanderError, InvalidArgumentError } from "#compiled/command
import { devBootPhase, type DevBootProgressReporter } from "#internal/dev-boot-progress.js";
import { resolveApplicationRoot } from "#internal/application/paths.js";
import { resolveInstalledPackageInfo } from "#internal/application/package.js";
+import { isCodingAgentLaunch } from "#cli/agent-detection.js";
import { eveCliBanner } from "#cli/banner.js";
import { registerProjectCommands } from "#cli/commands/register-project-commands.js";
import type { RunDevelopmentTuiInput } from "#cli/dev/tui/tui.js";
@@ -50,6 +51,7 @@ interface ProductionCliOptions {
}
interface CliRuntimeDependencies {
+ isCodingAgentLaunch(): Promise<boolean>;
buildHost(appRoot: string): Promise<string>;
printApplicationInfo(
logger: CliLogger,
@@ -656,6 +658,19 @@ export async function runCli(
return;
}
+ // A coding agent that fumbles `eve init` (e.g. an unknown flag) trips
+ // commander before the init action runs, so the action's own agent
+ // detection never fires. Commander has already written its usage error to
+ // stderr; add the setup guide on stdout so the agent gets actionable next
+ // steps — but still fall through to throw, so the malformed invocation
+ // keeps its nonzero exit instead of silently succeeding.
+ const detectCodingAgentLaunch = runtime.isCodingAgentLaunch ?? isCodingAgentLaunch;
+ const agentLaunched = await detectCodingAgentLaunch();
+ if (input[0] === "init" && agentLaunched) {
+ const { initAgentInstructions } = await import("#cli/commands/agent-instructions.js");
+ logger.log(initAgentInstructions());
+ }
+
throw new Error(error.message);
}
diff --git a/packages/eve/src/setup/scaffold/create/add-to-project.ts b/packages/eve/src/setup/scaffold/create/add-to-project.ts
index b2fe68355..12da2b915 100644
--- a/packages/eve/src/setup/scaffold/create/add-to-project.ts
+++ b/packages/eve/src/setup/scaffold/create/add-to-project.ts
@@ -93,7 +93,7 @@ export async function addAgentToProject(
if (conflicts.length > 0) {
throw new Error(
`Cannot add an eve agent to "${options.projectRoot}" because it already has: ` +
- `${conflicts.join(", ")}. Move them aside first.`,
+ `${conflicts.join(", ")}.`,
);
}
diff --git a/packages/eve/test/scenarios/eve-init.scenario.test.ts b/packages/eve/test/scenarios/eve-init.scenario.test.ts
index 192a8192b..0063646fb 100644
--- a/packages/eve/test/scenarios/eve-init.scenario.test.ts
+++ b/packages/eve/test/scenarios/eve-init.scenario.test.ts
@@ -301,7 +301,7 @@ describe("eve init smoke", () => {
]);
});
- it("scaffolds the current empty directory for a coding agent that omits the target", async () => {
+ it("hands a coding agent the setup guide when it omits the target", async () => {
const scratch = await createScratchDirectory("eve-init-agent-bare-");
const fakePnpmRoot = await createScratchDirectory("eve-init-agent-bare-pnpm-");
const fakePnpm = await createFakePnpmEnvironment(fakePnpmRoot);
@@ -309,23 +309,29 @@ describe("eve init smoke", () => {
const result = await runEveBin(scratch, ["init"], { ...fakePnpm.env, AI_AGENT: "claude" });
expect(result.exitCode, result.stderr).toBe(0);
- const canonicalProjectDir = await realpath(scratch);
- expect(await readFile(join(scratch, "agent/agent.ts"), "utf8")).toContain(
- DEFAULT_AGENT_MODEL_ID,
- );
- expect(await fakePnpm.readCalls()).toEqual([
- {
- args: [
- "--dir",
- canonicalProjectDir,
- "install",
- "--no-frozen-lockfile",
- "--config.minimum-release-age=0",
- ],
- cwd: canonicalProjectDir,
- },
- ]);
- expect(result.stdout).toContain("Do not start `eve dev`");
+ // A bare `eve init` from an agent prints the setup guide and scaffolds
+ // nothing — no agent files written. (No install runs, so the fake pnpm is
+ // never invoked and writes no call log.)
+ expect(result.stdout).toContain("Set up an eve agent");
+ expect(result.stdout).toContain("npx eve@latest init <name>");
+ await expect(pathExists(join(scratch, "agent/agent.ts"))).resolves.toBe(false);
+ });
+
+ it("prints the setup guide but still fails when a coding agent passes a bad flag", async () => {
+ const scratch = await createScratchDirectory("eve-init-agent-fumble-");
+ const fakePnpmRoot = await createScratchDirectory("eve-init-agent-fumble-pnpm-");
+ const fakePnpm = await createFakePnpmEnvironment(fakePnpmRoot);
+
+ const result = await runEveBin(scratch, ["init", "--unknown-flag"], {
+ ...fakePnpm.env,
+ AI_AGENT: "claude",
+ });
+
+ // The guide is still printed, but a malformed invocation must preserve its
+ // parse failure — exiting 0 would lie to any script or agent checking it.
+ expect(result.exitCode).not.toBe(0);
+ expect(result.stdout).toContain("Set up an eve agent");
+ await expect(pathExists(join(scratch, "agent/agent.ts"))).resolves.toBe(false);
});
it("scaffolds the current empty directory when the target is omitted", async () => {
@@ -376,9 +382,9 @@ describe("eve init smoke", () => {
);
await expect(pathExists(join(projectDir, ".git"))).resolves.toBe(true);
// Install runs through the real binary, but the dev server is handed off as
- // text rather than spawned: the only install call is the install itself,
- // and the handoff's "Do not start" line is the anchor that the TUI never
- // launched. The handoff's command text is the unit test's job.
+ // text rather than spawned: the only package-manager call is the install
+ // itself. The handoff supplies a headless command the coding agent can run
+ // later in a controllable background process.
expect(await fakePnpm.readCalls()).toEqual([
{
args: [
@@ -391,7 +397,7 @@ describe("eve init smoke", () => {
cwd: canonicalProjectDir,
},
]);
- expect(result.stdout).toContain("Do not start `eve dev`");
+ expect(result.stdout).toContain("eve dev --no-ui");
});
it("rejects path-like names without writing outside the current directory", async () => {