The Open Framework for Building Agents
Choose init or dev for bare eve commands (#2066)
Casey Gowrie7ab7d9786acf
diff --git a/.changeset/light-buttons-scream.md b/.changeset/light-buttons-scream.mdnew file mode 100644index 000000000..b046e3197--- /dev/null+++ b/.changeset/light-buttons-scream.md@@ -0,0 +1,5 @@+---+"eve": patch+---++Running eve without a command now initializes the current directory when no eve project is present, and starts development when one is detected.diff --git a/docs/reference/cli.md b/docs/reference/cli.mdindex e33d6e570..d2ae2b605 100644--- a/docs/reference/cli.md+++ b/docs/reference/cli.md@@ -3,12 +3,13 @@ title: "CLI"description: "Reference for every eve CLI command: init, set, info, build, start, dev, logs, trace, link, deploy, eval, channels, and extension."----The `eve` binary (`bin: eve`) runs from your app root, and every command first loads `.env`/`.env.local` from that root. Running `eve` with no command runs `eve dev`.+The `eve` binary (`bin: eve`) runs from your app root. Every command first loads `.env`/`.env.local` from that root. Running `eve` with no command runs `eve init` when the current directory is not an eve project, or `eve dev` when it is.## Commands| Command | Description || ----------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- |+| `eve` | Initialize the current directory, or start development when it is already an eve project || `eve init [target]` | Create a new agent, or add an agent to an existing project || `eve info` | Print the resolved application, including static instructions and discovered capabilities, routes, artifact paths, and diagnostics || `eve build` | Compile `.eve/` artifacts and build the host output; prints the output directory |diff --git a/packages/eve/README.md b/packages/eve/README.mdindex 89ab4e1ee..d04beb7fd 100644--- a/packages/eve/README.md+++ b/packages/eve/README.md@@ -133,6 +133,7 @@ project or deploy the agent.CLI commands:+- `eve` (including `npx eve`) — initialize the current directory, or start development in an eve project- `eve init <name>` — create a new agent- `eve info` — discovery results and compiled artifacts- `eve build` — compile `.eve/` and build the host outputdiff --git a/packages/eve/src/cli/run.test.ts b/packages/eve/src/cli/run.test.tsindex d7419416f..9a34439aa 100644--- a/packages/eve/src/cli/run.test.ts+++ b/packages/eve/src/cli/run.test.ts@@ -182,6 +182,64 @@ describe("CLI command registration", () => {});});+describe("bare eve command", () => {+ it("runs init in the current directory when no eve project is detected", async () => {+ const logger = { error: vi.fn(), log: vi.fn() };+ const isEveProject = vi.fn(async () => false);+ runInitCommand.mockClear();++ await runCli([], logger, { isEveProject });++ expect(isEveProject).toHaveBeenCalledWith(resolve(process.cwd()));+ expect(runInitCommand).toHaveBeenCalledWith(logger, resolve(process.cwd()), undefined, {+ channelWebNextjs: undefined,+ model: undefined,+ reasoning: undefined,+ });+ });++ it("runs dev when an eve project is detected", async () => {+ const logger = { error: vi.fn(), log: vi.fn() };+ const isEveProject = vi.fn(async () => true);+ const close = vi.fn(async () => {});+ const startHost = vi.fn(() => ({+ start: async () => ({+ kind: "started" as const,+ appRoot: "/canonical/app",+ url: "http://127.0.0.1:4321/",+ }),+ close,+ }));+ const runDevelopmentTui = vi.fn(async () => {});+ runInitCommand.mockClear();++ await withInteractiveTerminal(() =>+ runCli([], logger, { isEveProject, runDevelopmentTui, startHost }),+ );++ expect(isEveProject).toHaveBeenCalledWith(resolve(process.cwd()));+ expect(startHost).toHaveBeenCalledWith(resolve(process.cwd()), {+ existing: "attach-if-unconfigured",+ host: undefined,+ onBootProgress: expect.any(Function),+ output: undefined,+ port: undefined,+ });+ expect(runDevelopmentTui).toHaveBeenCalledOnce();+ expect(runInitCommand).not.toHaveBeenCalled();+ expect(close).toHaveBeenCalledOnce();+ });++ it("does not inspect the project when a command is explicit", async () => {+ const logger = { error: vi.fn(), log: vi.fn() };+ const isEveProject = vi.fn(async () => false);++ await runCli(["init"], logger, { isEveProject });++ expect(isEveProject).not.toHaveBeenCalled();+ });+});+describe("eve init compatibility flags", () => {it("lists the supported init options", async () => {const output: string[] = [];diff --git a/packages/eve/src/cli/run.ts b/packages/eve/src/cli/run.tsindex 43af5cd3a..73fb32018 100644--- a/packages/eve/src/cli/run.ts+++ b/packages/eve/src/cli/run.ts@@ -62,6 +62,7 @@ interface CliLogger {interface CliRuntimeDependencies {isCodingAgentLaunch(): Promise<boolean>;+ isEveProject(appRoot: string): Promise<boolean>;isActiveDevelopmentServerForApp(input: {readonly appRoot: string;readonly serverUrl: string;@@ -134,6 +135,10 @@ async function loadStartHost(): Promise<CliRuntimeDependencies["startHost"]> {return (await import("#cli/dev/local-server-process.js")).createDevelopmentServer;}+async function loadIsEveProject(): Promise<CliRuntimeDependencies["isEveProject"]> {+ return (await import("#setup/scaffold/index.js")).isEveProject;+}+const loadIsActiveDevelopmentServerForApp = async () =>(await import("#internal/nitro/host.js")).isActiveDevelopmentServerForApp;@@ -145,8 +150,11 @@ function hasInteractiveTerminal(): boolean {return Boolean(process.stdin.isTTY && process.stdout.isTTY);}-function createCliProgram(logger: CliLogger, runtime: CliRuntimeOverrides): Command {- const appRoot = resolveApplicationRoot();+function createCliProgram(+ logger: CliLogger,+ runtime: CliRuntimeOverrides,+ appRoot: string,+): Command {const packageVersion = resolveInstalledPackageInfo().version;const program = new Command();const theme = createCliTheme();@@ -632,8 +640,13 @@ export async function runCli(logger: CliLogger = console,runtime: CliRuntimeOverrides = {},): Promise<void> {- const program = createCliProgram(logger, runtime);- const input = argv.length === 0 ? ["dev"] : argv;+ const appRoot = resolveApplicationRoot();+ const program = createCliProgram(logger, runtime, appRoot);+ let input = argv;+ if (input.length === 0) {+ const detectEveProject = runtime.isEveProject ?? (await loadIsEveProject());+ input = [(await detectEveProject(appRoot)) ? "dev" : "init"];+ }try {await program.parseAsync(input, {diff --git a/packages/eve/test/scenarios/cli.scenario.test.ts b/packages/eve/test/scenarios/cli.scenario.test.tsindex f8e055814..55726c922 100644--- a/packages/eve/test/scenarios/cli.scenario.test.ts+++ b/packages/eve/test/scenarios/cli.scenario.test.ts@@ -278,11 +278,12 @@ describe("runCli", () => {expect(output).toContain("0 errors, 0 warnings");});- it("defaults to dev when no command is provided", async () => {+ it("defaults to dev when no command is provided in an eve project", async () => {const logger = {error: vi.fn(),log: vi.fn(),};+ const isEveProject = vi.fn(async () => true);const startHost = vi.fn(() => ({start: async () => {throw new Error("dev started");@@ -292,10 +293,12 @@ describe("runCli", () => {await expect(runCli([], logger, {+ isEveProject,startHost,}),).rejects.toThrow("dev started");+ expect(isEveProject).toHaveBeenCalledOnce();expect(startHost).toHaveBeenCalledOnce();});