The Open Framework for Building Agents
Warn and continue on unknown eve init options (#324)
Rui2e4e15de7a4d
diff --git a/.changeset/quiet-ravens-build.md b/.changeset/quiet-ravens-build.mdnew file mode 100644index 000000000..84e90a1dc--- /dev/null+++ b/.changeset/quiet-ravens-build.md@@ -0,0 +1,5 @@+---+"eve": patch+---++`eve init` now accepts `--yes` as a no-op compatibility flag and warns before continuing.diff --git a/packages/eve/src/cli/run.test.ts b/packages/eve/src/cli/run.test.tsindex 218a88ef4..172eb3077 100644--- a/packages/eve/src/cli/run.test.ts+++ b/packages/eve/src/cli/run.test.ts@@ -42,17 +42,32 @@ 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 () => {+describe("eve init compatibility flags", () => {+ it("lists --yes as an accepted compatibility flag", async () => {+ const output: string[] = [];++ await runCli(["init", "--help"], {+ error: (message) => output.push(message),+ log: (message) => output.push(message),+ });++ expect(output.join("\n")).toContain("-y, --yes");+ });++ it("still rejects unknown init options", async () => {+ await expect(+ runCli(["init", "my-agent", "--template"], { error: () => {}, log: () => {} }),+ ).rejects.toThrow();+ });+});++describe("eve CLI malformed argument handling", () => {+ it("prints the setup guide for a coding agent when init has too many targets", 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"],+ ["init", "first", "second"],{ error: (message) => output.push(message), log: (message) => output.push(message) },{ isCodingAgentLaunch: async () => true },),@@ -61,13 +76,9 @@ describe("eve init for a coding agent that fumbles the invocation", () => {expect(output.join("\n")).toContain("Set up an eve agent");});- it("still surfaces the usage error for a human", async () => {+ it("still surfaces the usage error for commands other than init", async () => {await expect(- runCli(- ["init", "--unknown-flag"],- { error: () => {}, log: () => {} },- { isCodingAgentLaunch: async () => false },- ),+ runCli(["dev", "--unknown-flag"], { error: () => {}, log: () => {} }),).rejects.toThrow();});});diff --git a/packages/eve/src/cli/run.ts b/packages/eve/src/cli/run.tsindex 5cf53e378..79e766684 100644--- a/packages/eve/src/cli/run.ts+++ b/packages/eve/src/cli/run.ts@@ -379,10 +379,22 @@ function createCliProgram(logger: CliLogger, runtime: CliRuntimeOverrides): Comm.command("init [target]").description("Create a new eve agent, or add one to an existing project directory.").option("--channel-web-nextjs", "Add the Web Chat application (Next.js)")- .action(async (target: string | undefined, options: { channelWebNextjs?: boolean }) => {- const { runInitCommand } = await import("#cli/commands/init.js");- await runInitCommand(logger, appRoot, target, options);- });+ .option("-y, --yes", "Accepted for compatibility; has no effect")+ .action(+ async (+ target: string | undefined,+ options: { channelWebNextjs?: boolean; yes?: boolean },+ ) => {+ if (options.yes) {+ logger.error("warning: --yes has no effect for eve init.");+ }++ const { runInitCommand } = await import("#cli/commands/init.js");+ await runInitCommand(logger, appRoot, target, {+ channelWebNextjs: options.channelWebNextjs,+ });+ },+ );registerProjectCommands({ program, logger, appRoot });@@ -652,12 +664,11 @@ 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.+ // A coding agent that fumbles `eve init` can trip 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.const detectCodingAgentLaunch = runtime.isCodingAgentLaunch ?? isCodingAgentLaunch;const agentLaunched = await detectCodingAgentLaunch();if (input[0] === "init" && agentLaunched) {diff --git a/packages/eve/test/scenarios/eve-init.scenario.test.ts b/packages/eve/test/scenarios/eve-init.scenario.test.tsindex 0063646fb..1bc9a1540 100644--- a/packages/eve/test/scenarios/eve-init.scenario.test.ts+++ b/packages/eve/test/scenarios/eve-init.scenario.test.ts@@ -317,21 +317,20 @@ describe("eve init smoke", () => {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 () => {+ it("warns and continues when a coding agent passes the compatibility yes 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"], {+ const result = await runEveBin(scratch, ["init", "fumble-agent", "--yes"], {...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);+ expect(result.exitCode, result.stderr).toBe(0);+ expect(result.stderr).toContain("warning: --yes has no effect for eve init.");+ expect(result.stdout).toContain("eve dev --no-ui");+ await expect(pathExists(join(scratch, "fumble-agent", "agent/agent.ts"))).resolves.toBe(true);});it("scaffolds the current empty directory when the target is omitted", async () => {