Skip to content

armgit / eve

Public Imported from GitHub
0

The Open Framework for Building Agents

feat(eve): add eve extension init and eve extension build (#686)

Casey Gowriea5b43e753a38
diff --git a/.changeset/init-extension.md b/.changeset/init-extension.md
new file mode 100644
index 000000000..24577a464
--- /dev/null
+++ b/.changeset/init-extension.md
@@ -0,0 +1,5 @@
+---
+"eve": patch
+---
+
+Add `eve extension init` and `eve extension build` for scaffolding and building extension packages.
diff --git a/docs/extensions.md b/docs/extensions.md
index a07bdd74f..2bebae5a0 100644
--- a/docs/extensions.md
+++ b/docs/extensions.md
@@ -7,12 +7,20 @@ An extension packages eve capabilities — tools, connections, skills, instructi
## Authoring
+Start from a scaffold:
+
+```bash
+npx eve@latest extension init my-crm
+```
+
+This creates the package, installs dependencies, and initializes Git. You get `extension/extension.ts`, TypeScript config, and a `package.json` ready to publish or mount. Add tools, skills, hooks, and connections under `extension/` yourself.
+
An extension is an agent-shaped directory without `agent.ts` or `sandbox` (those belong to the consuming agent). Every slot works as it does in an agent, with names derived from paths.
```
@acme/crm/
package.json
- ext/
+ extension/
extension.ts # the extension declaration — see Configuration
tools/search.ts
connections/api.ts
@@ -21,13 +29,13 @@ An extension is an agent-shaped directory without `agent.ts` or `sandbox` (those
lib/http.ts # shared helpers, imported as ../lib/http
```
-Name tools and connections for what they do (`search`, not `crm_search`) — the mount supplies the namespace. Shared code goes in `ext/lib/`, imported by relative path — eve compiles the source, so relative imports need no `.js` extension.
+Name tools and connections for what they do (`search`, not `crm_search`) — the mount supplies the namespace. Shared code goes in `extension/lib/`, imported by relative path — eve compiles the source, so relative imports need no `.js` extension.
### Configuration
-Declare the extension in `ext/extension.ts` with `defineExtension`; its default export is the mount factory a consumer calls. Pass `config` — any [Standard Schema](https://standardschema.dev) (a Zod object here), like a tool's `inputSchema` — to accept consumer settings:
+Declare the extension in `extension/extension.ts` with `defineExtension`; its default export is the mount factory a consumer calls. Pass `config` — any [Standard Schema](https://standardschema.dev) (a Zod object here), like a tool's `inputSchema` — to accept consumer settings:
-```ts title="ext/extension.ts"
+```ts title="extension/extension.ts"
import { defineExtension } from "eve/extension";
import { z } from "zod";
@@ -41,7 +49,7 @@ export default defineExtension({
Config is optional — `defineExtension()` with no schema. Read it off the handle, imported from the declaration; it's typed from the schema:
-```ts title="ext/tools/search.ts"
+```ts title="extension/tools/search.ts"
import { defineTool } from "eve/tools";
import extension from "../extension";
@@ -65,17 +73,17 @@ Config is bound once when the consumer mounts the extension and stays constant f
## Publishing
-Point `eve.extension` at the source directory and run `eve build` (wired to `build`/`prepare`):
+Point `eve.extension` at the source directory and run `eve extension build` (wired to `build`/`prepare`):
```jsonc title="package.json"
{
"name": "@acme/crm",
"type": "module",
- "eve": { "extension": "./ext" },
- "files": ["ext", "dist"],
+ "eve": { "extension": "./extension" },
+ "files": ["extension", "dist"],
"peerDependencies": { "eve": "^x" },
"dependencies": { "zod": "^3" },
- "scripts": { "build": "eve build", "prepare": "eve build" },
+ "scripts": { "build": "eve extension build", "prepare": "eve extension build" },
}
```
@@ -90,17 +98,17 @@ Author the source with `moduleResolution: "bundler"` — eve compiles it, so rel
"noEmit": true,
"types": ["node"],
},
- "include": ["ext/**/*.ts"],
+ "include": ["extension/**/*.ts"],
}
```
-`eve build` compiles the package's entry points to plain JavaScript with type declarations — the mount factory (`dist/index.mjs`) and the tool re-exports overrides use (`dist/tools`) — and fills the `exports` map so you never hand-list it. Compiling is what lets an installed extension load directly; local and workspace packages also work without publishing.
+`eve extension build` compiles the package's entry points to plain JavaScript with type declarations — the mount factory (`dist/index.mjs`) and the tool re-exports overrides use (`dist/tools`) — and fills the `exports` map so you never hand-list it. Compiling is what lets an installed extension load directly; local and workspace packages also work without publishing.
### Dependencies
-`eve` is a **peer** dependency: one eve lives in the consuming app and the extension's `eve/*` imports resolve to it. Declare the eve versions your extension supports as the peer range (`"eve": "^1"`) — eve enforces it when the extension is mounted, failing the build with a clear error if the app's eve is out of range, rather than surfacing a confusing compile break. Everything else the extension imports (SDKs, `zod`, …) goes in `dependencies`; each extension resolves its own versions. The consumer recompiles the extension's contributions from source, so `files` must ship both `ext/` (that source) and `dist/` (the compiled entry points).
+`eve` is a **peer** dependency: one eve lives in the consuming app and the extension's `eve/*` imports resolve to it. Declare the eve versions your extension supports as the peer range (`"eve": "^1"`) — eve enforces it when the extension is mounted, failing the build with a clear error if the app's eve is out of range, rather than surfacing a confusing compile break. Everything else the extension imports (SDKs, `zod`, …) goes in `dependencies`; each extension resolves its own versions. The consumer recompiles the extension's contributions from source, so `files` must ship both `extension/` (that source) and `dist/` (the compiled entry points).
-Those deps resolve from `node_modules` under `eve dev`/`eve eval` and are bundled into the deployable by `eve build`. A dependency that can't be bundled (a native addon) must be listed in the **consuming agent's** `build.externalDependencies` — an extension can't declare build config, so note it in your README.
+Those deps resolve from `node_modules` under `eve dev`/`eve eval` and are bundled into the deployable by the consuming agent's `eve build`. A dependency that can't be bundled (a native addon) must be listed in the **consuming agent's** `build.externalDependencies` — an extension can't declare build config, so note it in your README.
## Mounting
diff --git a/docs/reference/cli.md b/docs/reference/cli.md
index 76c2d8b1f..b423ef2a7 100644
--- a/docs/reference/cli.md
+++ b/docs/reference/cli.md
@@ -1,25 +1,27 @@
---
title: "CLI"
-description: "Reference for every eve CLI command: init, info, build, start, dev, link, deploy, eval, and channels."
+description: "Reference for every eve CLI command: init, info, build, start, dev, 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`.
## Commands
-| Command | Description |
-| ------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
-| `eve init [target]` | Scaffold a new agent, or add one to an existing project directory |
-| `eve info` | Print the resolved application, including discovered tools, skills, subagents, schedules, channels, routes, artifact paths, and discovery diagnostics |
-| `eve build` | Compile `.eve/` artifacts and build the host output; prints the output directory |
-| `eve start` | Serve the built `.output/` app; prints the listening URL |
-| `eve dev` | Start the local dev server and open the terminal UI |
-| `eve dev <url>` | Connect the UI to an existing server URL (e.g. a remote deployment) instead of booting a local server |
-| `eve link` | Link the directory to a Vercel project and pull AI Gateway credentials |
-| `eve deploy` | Deploy the agent to Vercel production (links first if needed) |
-| `eve eval` | Run evals against the local app or a remote target |
-| `eve channels add [kind]` | Scaffold a channel interactively, or by kind (`slack` \| `web`) |
-| `eve channels list` | List user-authored channels |
+| Command | Description |
+| ----------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
+| `eve init [target]` | Create a new agent, or add an agent to an existing project |
+| `eve info` | Print the resolved application, including discovered tools, skills, subagents, schedules, channels, routes, artifact paths, and discovery diagnostics |
+| `eve build` | Compile `.eve/` artifacts and build the host output; prints the output directory |
+| `eve start` | Serve the built `.output/` app; prints the listening URL |
+| `eve dev` | Start the local dev server and open the terminal UI |
+| `eve dev <url>` | Connect the UI to an existing server URL (e.g. a remote deployment) instead of booting a local server |
+| `eve link` | Link the directory to a Vercel project and pull AI Gateway credentials |
+| `eve deploy` | Deploy the agent to Vercel production (links first if needed) |
+| `eve eval` | Run evals against the local app or a remote target |
+| `eve channels add [kind]` | Scaffold a channel interactively, or by kind (`slack` \| `web`) |
+| `eve channels list` | List user-authored channels |
+| `eve extension init [target]` | Create a new extension package |
+| `eve extension build` | Build the current package as an extension |
When `eve build` fails on discovery errors, it prints the full diagnostics report (severity, message, source path) and the diagnostics artifact path.
@@ -29,17 +31,49 @@ When `eve build` fails on discovery errors, it prints the full diagnostics repor
eve init [target] [--channel-web-nextjs]
```
-The optional `target` decides the mode:
+Creates a new agent app or adds an agent to an existing app. Always installs dependencies. New directories also initialize Git.
-- 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 .`. 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.
+| Target | What happens |
+| ----------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| `eve init my-agent` | New agent project in `my-agent/` |
+| `eve init .` (or an existing project dir) | Adds `agent/` plus missing `eve`, `ai`, and `zod` deps. Needs a `package.json` and no `agent/` files yet |
+| `eve init` with no target | Same as `eve init .`, except coding agents (Claude Code, Cursor, and similar) get a setup guide instead of scaffolding — they have not chosen a name yet |
-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.
+After scaffolding, a human terminal usually continues into `eve dev` (or a coding-agent REPL if one is on `PATH` and you pick it). Coding-agent launches print the next steps instead of opening the TUI, so the session does not get stuck. Fresh projects use the parent workspace's package manager when there is one; otherwise they use the manager that launched `eve init`.
-| Flag | Type | Default | Description |
-| ---------------------- | ---- | ------- | -------------------------------------------------------------------------------------------------------------------------------------- |
-| `--channel-web-nextjs` | flag | off | Add the Web Chat application (a Next.js app). Rejected when adding to an existing project; run `eve channels add web` there afterward. |
+| Flag | Type | Default | Description |
+| ---------------------- | ---- | ------- | ----------------------------------------------------------------------------------------------------- |
+| `--channel-web-nextjs` | flag | off | Add the Web Chat app (Next.js). Not for existing projects — run `eve channels add web` there instead. |
+
+## `eve extension`
+
+Commands for reusable [extension](/docs/extensions) packages. An extension is identified by `package.json#eve.extension` (for example `"eve": { "extension": "./extension" }`).
+
+### `eve extension init`
+
+```bash
+eve extension init [target]
+```
+
+Creates a new extension package, installs dependencies, and initializes Git. Prints next steps instead of starting `eve dev`.
+
+| Target | What happens |
+| --------------------------- | ------------------------------------------------------------- |
+| `eve extension init my-crm` | New extension package in `my-crm/` |
+| `eve extension init .` | Scaffold in the current empty directory |
+| No target | Same as `.` for humans; coding agents get a short setup guide |
+
+Create-only: cannot target an existing project that already has a `package.json`.
+
+See [Extensions](/docs/extensions) for authoring and mount details.
+
+### `eve extension build`
+
+```bash
+eve extension build
+```
+
+Builds the current package as an extension: compiles the mount factory and tool re-exports into `dist/`, and fills the package `exports` map. Requires `package.json#eve.extension`.
## `eve info`
diff --git a/e2e/fixtures/extensions/evals/dynamic-capability.eval.ts b/e2e/fixtures/extensions/evals/dynamic-capability.eval.ts
index d25f0ec5f..768ea8a0f 100644
--- a/e2e/fixtures/extensions/evals/dynamic-capability.eval.ts
+++ b/e2e/fixtures/extensions/evals/dynamic-capability.eval.ts
@@ -1,6 +1,6 @@
import { defineEval } from "eve/evals";
-// Token built by the extension's shared `ext/lib/brand` stamp() helper.
+// Token built by the extension's shared `extension/lib/brand` stamp() helper.
const TOOLKIT_FORECAST_TOKEN = "toolkit-forecast-ok-9F4Q";
export default defineEval({
diff --git a/e2e/fixtures/gizmo-extension/ext/extension.ts b/e2e/fixtures/gizmo-extension/extension/extension.ts
similarity index 100%
rename from e2e/fixtures/gizmo-extension/ext/extension.ts
rename to e2e/fixtures/gizmo-extension/extension/extension.ts
diff --git a/e2e/fixtures/gizmo-extension/ext/tools/gizmo_budget.ts b/e2e/fixtures/gizmo-extension/extension/tools/gizmo_budget.ts
similarity index 100%
rename from e2e/fixtures/gizmo-extension/ext/tools/gizmo_budget.ts
rename to e2e/fixtures/gizmo-extension/extension/tools/gizmo_budget.ts
diff --git a/e2e/fixtures/gizmo-extension/ext/tools/gizmo_search.ts b/e2e/fixtures/gizmo-extension/extension/tools/gizmo_search.ts
similarity index 100%
rename from e2e/fixtures/gizmo-extension/ext/tools/gizmo_search.ts
rename to e2e/fixtures/gizmo-extension/extension/tools/gizmo_search.ts
diff --git a/e2e/fixtures/gizmo-extension/package.json b/e2e/fixtures/gizmo-extension/package.json
index d5c44cc14..143582dae 100644
--- a/e2e/fixtures/gizmo-extension/package.json
+++ b/e2e/fixtures/gizmo-extension/package.json
@@ -4,7 +4,7 @@
"private": true,
"type": "module",
"exports": {
- ".": "./ext/extension.ts"
+ ".": "./extension/extension.ts"
},
"dependencies": {
"zod": "catalog:"
@@ -17,6 +17,6 @@
"eve": "workspace:*"
},
"eve": {
- "extension": "./ext"
+ "extension": "./extension"
}
}
diff --git a/e2e/fixtures/gizmo-extension/tsconfig.json b/e2e/fixtures/gizmo-extension/tsconfig.json
index 0f2d48ef3..91d7d5981 100644
--- a/e2e/fixtures/gizmo-extension/tsconfig.json
+++ b/e2e/fixtures/gizmo-extension/tsconfig.json
@@ -12,5 +12,5 @@
"noEmit": true,
"types": ["node"]
},
- "include": ["ext/**/*.ts"]
+ "include": ["extension/**/*.ts"]
}
diff --git a/e2e/fixtures/toolkit-extension/ext/extension.ts b/e2e/fixtures/toolkit-extension/extension/extension.ts
similarity index 100%
rename from e2e/fixtures/toolkit-extension/ext/extension.ts
rename to e2e/fixtures/toolkit-extension/extension/extension.ts
diff --git a/e2e/fixtures/toolkit-extension/ext/instructions/policy.md b/e2e/fixtures/toolkit-extension/extension/instructions/policy.md
similarity index 100%
rename from e2e/fixtures/toolkit-extension/ext/instructions/policy.md
rename to e2e/fixtures/toolkit-extension/extension/instructions/policy.md
diff --git a/e2e/fixtures/toolkit-extension/ext/lib/brand.ts b/e2e/fixtures/toolkit-extension/extension/lib/brand.ts
similarity index 67%
rename from e2e/fixtures/toolkit-extension/ext/lib/brand.ts
rename to e2e/fixtures/toolkit-extension/extension/lib/brand.ts
index f98853e41..1c19ec541 100644
--- a/e2e/fixtures/toolkit-extension/ext/lib/brand.ts
+++ b/e2e/fixtures/toolkit-extension/extension/lib/brand.ts
@@ -1,4 +1,4 @@
-// Shared helper: proves an extension bundles its own `ext/lib/` modules into its tools.
+// Shared helper: proves an extension bundles its own `extension/lib/` modules into its tools.
export const PROVIDER = "toolkit";
/** Prefixes a value with the provider name, e.g. stamp("forecast-ok-9F4Q"). */
diff --git a/e2e/fixtures/toolkit-extension/ext/skills/playbooks.ts b/e2e/fixtures/toolkit-extension/extension/skills/playbooks.ts
similarity index 100%
rename from e2e/fixtures/toolkit-extension/ext/skills/playbooks.ts
rename to e2e/fixtures/toolkit-extension/extension/skills/playbooks.ts
diff --git a/e2e/fixtures/toolkit-extension/ext/skills/toolkit-guide/SKILL.md b/e2e/fixtures/toolkit-extension/extension/skills/toolkit-guide/SKILL.md
similarity index 100%
rename from e2e/fixtures/toolkit-extension/ext/skills/toolkit-guide/SKILL.md
rename to e2e/fixtures/toolkit-extension/extension/skills/toolkit-guide/SKILL.md
diff --git a/e2e/fixtures/toolkit-extension/ext/tools/toolkit_budget.ts b/e2e/fixtures/toolkit-extension/extension/tools/toolkit_budget.ts
similarity index 100%
rename from e2e/fixtures/toolkit-extension/ext/tools/toolkit_budget.ts
rename to e2e/fixtures/toolkit-extension/extension/tools/toolkit_budget.ts
diff --git a/e2e/fixtures/toolkit-extension/ext/tools/toolkit_forecast.ts b/e2e/fixtures/toolkit-extension/extension/tools/toolkit_forecast.ts
similarity index 100%
rename from e2e/fixtures/toolkit-extension/ext/tools/toolkit_forecast.ts
rename to e2e/fixtures/toolkit-extension/extension/tools/toolkit_forecast.ts
diff --git a/e2e/fixtures/toolkit-extension/ext/tools/toolkit_lookup.ts b/e2e/fixtures/toolkit-extension/extension/tools/toolkit_lookup.ts
similarity index 100%
rename from e2e/fixtures/toolkit-extension/ext/tools/toolkit_lookup.ts
rename to e2e/fixtures/toolkit-extension/extension/tools/toolkit_lookup.ts
diff --git a/e2e/fixtures/toolkit-extension/ext/tools/toolkit_ping.ts b/e2e/fixtures/toolkit-extension/extension/tools/toolkit_ping.ts
similarity index 100%
rename from e2e/fixtures/toolkit-extension/ext/tools/toolkit_ping.ts
rename to e2e/fixtures/toolkit-extension/extension/tools/toolkit_ping.ts
diff --git a/e2e/fixtures/toolkit-extension/package.json b/e2e/fixtures/toolkit-extension/package.json
index d22b4f9b1..256e9be2d 100644
--- a/e2e/fixtures/toolkit-extension/package.json
+++ b/e2e/fixtures/toolkit-extension/package.json
@@ -4,7 +4,7 @@
"private": true,
"type": "module",
"exports": {
- ".": "./ext/extension.ts"
+ ".": "./extension/extension.ts"
},
"dependencies": {
"zod": "catalog:"
@@ -17,6 +17,6 @@
"eve": "workspace:*"
},
"eve": {
- "extension": "./ext"
+ "extension": "./extension"
}
}
diff --git a/e2e/fixtures/toolkit-extension/tsconfig.json b/e2e/fixtures/toolkit-extension/tsconfig.json
index 0f2d48ef3..91d7d5981 100644
--- a/e2e/fixtures/toolkit-extension/tsconfig.json
+++ b/e2e/fixtures/toolkit-extension/tsconfig.json
@@ -12,5 +12,5 @@
"noEmit": true,
"types": ["node"]
},
- "include": ["ext/**/*.ts"]
+ "include": ["extension/**/*.ts"]
}
diff --git a/packages/eve/README.md b/packages/eve/README.md
index 12f2b81c3..97ff903b4 100644
--- a/packages/eve/README.md
+++ b/packages/eve/README.md
@@ -135,6 +135,8 @@ CLI commands:
- `eve build` — compile `.eve/` and build the host output
- `eve start` — serve the built `.output/` app
- `eve dev` — start the local runtime and REPL
+- `eve extension init <name>` — create a new extension package
+- `eve extension build` — build an extension package
## Deploying
diff --git a/packages/eve/src/cli/commands/agent-instructions.test.ts b/packages/eve/src/cli/commands/agent-instructions.test.ts
index 559ed6f35..3a9c73744 100644
--- a/packages/eve/src/cli/commands/agent-instructions.test.ts
+++ b/packages/eve/src/cli/commands/agent-instructions.test.ts
@@ -7,6 +7,8 @@ import {
initAgentDevHandoff,
initAgentInstructions,
initAgentReplPrompt,
+ initExtensionHandoff,
+ initExtensionInstructions,
SETUP_SECTIONS,
} from "./agent-instructions.js";
@@ -25,6 +27,7 @@ describe("initAgentInstructions", () => {
// 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("npx eve@latest extension init <name>");
expect(instructions).toContain("full docs are bundled");
expect(instructions).toContain("node_modules/eve/docs/");
expect(instructions).toContain("resolve\nthe installed `eve` package location");
@@ -91,6 +94,35 @@ describe("initAgentReplPrompt", () => {
});
});
+describe("initExtensionInstructions", () => {
+ it("points coding agents at extension init with a package name", () => {
+ const instructions = initExtensionInstructions();
+
+ expect(instructions).toContain("npx eve@latest extension init <name>");
+ expect(instructions).toContain("eve extension build");
+ expect(instructions).toContain("does not start eve dev");
+ expect(instructions).not.toContain("{{");
+ });
+});
+
+describe("initExtensionHandoff", () => {
+ it("describes the scaffold and mount next steps without eve dev", () => {
+ const handoff = initExtensionHandoff({
+ packageManager: "pnpm",
+ packageName: "my-crm",
+ projectPath: "/tmp/my-crm",
+ });
+
+ expect(handoff).toContain("extension/extension.ts");
+ expect(handoff).toContain("pnpm run build");
+ expect(handoff).toContain("eve extension build");
+ expect(handoff).toContain('import ext from "my-crm"');
+ expect(handoff).toContain("agent/extensions/my-crm.ts");
+ expect(handoff).toContain("/tmp/my-crm");
+ expect(handoff).not.toContain("eve dev");
+ });
+});
+
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
diff --git a/packages/eve/src/cli/commands/agent-instructions.ts b/packages/eve/src/cli/commands/agent-instructions.ts
index cbe1627f0..3c972b297 100644
--- a/packages/eve/src/cli/commands/agent-instructions.ts
+++ b/packages/eve/src/cli/commands/agent-instructions.ts
@@ -69,3 +69,56 @@ export function initAgentReplPrompt(options: { devCommand: string }): string {
workingDirectory: ".",
});
}
+
+/**
+ * Pre-scaffold guide for a coding agent that ran `eve extension init` with no
+ * target. Mirrors agent bare-init: collect a package name, then re-run with it.
+ */
+export function initExtensionInstructions(): string {
+ return [
+ "You are scaffolding an eve extension package (a reusable package of tools,",
+ "connections, skills, and hooks that a consuming agent mounts under",
+ "agent/extensions/).",
+ "",
+ "Ask the user for a package directory name, then run:",
+ "",
+ " npx eve@latest extension init <name>",
+ "",
+ "That creates the package, installs dependencies, and initializes Git. It",
+ "prints what was set up and how to author, build, and mount the extension —",
+ "it does not start eve dev (extensions are not standalone agents).",
+ "",
+ "Build with `eve extension build` (or the package `build` script).",
+ ].join("\n");
+}
+
+/**
+ * Post-scaffold handoff after `eve extension init`. Same text for human and
+ * coding-agent launches: what was written and what to do next. Never assumes
+ * `eve dev`.
+ */
+export function initExtensionHandoff(options: {
+ packageManager: string;
+ packageName: string;
+ projectPath: string;
+}): string {
+ const buildCommand = `${options.packageManager} run build`;
+ return [
+ "",
+ "What we set up:",
+ " - package.json with eve.extension → ./extension, peer+dev eve, and zod",
+ " - extension/extension.ts (config schema via defineExtension)",
+ " - build/prepare scripts → eve extension build",
+ "",
+ "Next:",
+ " - Add tools, skills, hooks, or connections under extension/",
+ " (see AGENTS.md and node_modules/eve/docs/extensions.md)",
+ ` - ${buildCommand} # fills dist/ and package exports`,
+ " - Mount from a consumer agent:",
+ ` // agent/extensions/${options.packageName}.ts`,
+ ` import ext from "${options.packageName}";`,
+ " export default ext({ apiKey: process.env.API_KEY });",
+ "",
+ `Working directory: ${options.projectPath}`,
+ ].join("\n");
+}
diff --git a/packages/eve/src/cli/commands/agent-prompt/scaffold.md b/packages/eve/src/cli/commands/agent-prompt/scaffold.md
index 9cad74780..19af3ee49 100644
--- a/packages/eve/src/cli/commands/agent-prompt/scaffold.md
+++ b/packages/eve/src/cli/commands/agent-prompt/scaffold.md
@@ -13,6 +13,9 @@ This creates the project, installs its dependencies, and initializes Git. Since
coding agent launched init, it prints a development handoff instead of starting
the interactive terminal UI.
+If the user wants a reusable extension package instead of an agent, run
+`npx eve@latest extension init <name>` and follow that command's next steps.
+
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
diff --git a/packages/eve/src/cli/commands/extension-build.integration.test.ts b/packages/eve/src/cli/commands/extension-build.integration.test.ts
new file mode 100644
index 000000000..bbaa64c67
--- /dev/null
+++ b/packages/eve/src/cli/commands/extension-build.integration.test.ts
@@ -0,0 +1,70 @@
+import { mkdir, mkdtemp, writeFile } from "node:fs/promises";
+import { tmpdir } from "node:os";
+import { join } from "node:path";
+
+import { describe, expect, it } from "vitest";
+
+import { runExtensionBuildCommand, type ExtensionBuildCliLogger } from "./extension-build.js";
+
+function logger(): ExtensionBuildCliLogger & { messages: string[]; errors: string[] } {
+ const messages: string[] = [];
+ const errors: string[] = [];
+ return {
+ messages,
+ errors,
+ log: (message) => messages.push(message),
+ error: (message) => errors.push(message),
+ };
+}
+
+describe("runExtensionBuildCommand", () => {
+ it("rejects a package that is not an extension and points at eve extension build", async () => {
+ const root = await mkdtemp(join(tmpdir(), "eve-extension-build-agent-"));
+ await writeFile(
+ join(root, "package.json"),
+ `${JSON.stringify({ name: "my-agent", type: "module" }, null, 2)}\n`,
+ "utf8",
+ );
+ const output = logger();
+
+ await expect(runExtensionBuildCommand(output, root)).rejects.toThrow(
+ "This package is not an eve extension",
+ );
+ expect(output.messages).toEqual([]);
+ });
+
+ it("builds a valid extension package", async () => {
+ const root = await mkdtemp(join(tmpdir(), "eve-extension-build-ok-"));
+ await writeFile(
+ join(root, "package.json"),
+ `${JSON.stringify(
+ {
+ name: "@acme/crm",
+ type: "module",
+ eve: { extension: "./extension" },
+ },
+ null,
+ 2,
+ )}\n`,
+ "utf8",
+ );
+ await mkdir(join(root, "extension"), { recursive: true });
+ await writeFile(
+ join(root, "extension", "extension.ts"),
+ [
+ 'import { defineExtension } from "eve/extension";',
+ "export default defineExtension();",
+ "",
+ ].join("\n"),
+ "utf8",
+ );
+
+ const output = logger();
+ await runExtensionBuildCommand(output, root);
+
+ const printed = output.messages.join("\n");
+ expect(printed).toContain("built extension");
+ expect(printed).toContain("@acme/crm");
+ expect(printed).toContain(join(root, "dist"));
+ });
+});
diff --git a/packages/eve/src/cli/commands/extension-build.ts b/packages/eve/src/cli/commands/extension-build.ts
new file mode 100644
index 000000000..bd6285fbf
--- /dev/null
+++ b/packages/eve/src/cli/commands/extension-build.ts
@@ -0,0 +1,46 @@
+import pc from "picocolors";
+
+import { createCliTheme, renderCliTaggedLine } from "#cli/ui/output.js";
+import { createLogger } from "#internal/logging.js";
+import {
+ buildExtensionPackage,
+ tryReadExtensionBuildConfig,
+} from "#internal/nitro/host/build-extension.js";
+
+export interface ExtensionBuildCliLogger {
+ error(message: string): void;
+ log(message: string): void;
+}
+
+const buildLog = createLogger("extension-build");
+
+/**
+ * Builds the current package as an eve extension. Requires
+ * `package.json#eve.extension` pointing at the source root (e.g. `./extension`).
+ */
+export async function runExtensionBuildCommand(
+ logger: ExtensionBuildCliLogger,
+ appRoot: string,
+): Promise<void> {
+ const config = await tryReadExtensionBuildConfig(appRoot);
+ if (config === null) {
+ throw new Error(
+ 'This package is not an eve extension. Add `"eve": { "extension": "./extension" }` to package.json, ' +
+ "or run `eve build` for an agent app.",
+ );
+ }
+
+ buildLog.debug("building extension package", {
+ packageName: config.packageName,
+ sourceRoot: config.sourceRoot,
+ });
+ const outputDir = await buildExtensionPackage(appRoot, config);
+ const theme = createCliTheme();
+ logger.log(
+ renderCliTaggedLine(theme, {
+ message: `built extension ${pc.bold(config.packageName)} at ${outputDir}`,
+ tag: "build",
+ tone: "success",
+ }),
+ );
+}
diff --git a/packages/eve/src/cli/commands/extension-init.integration.test.ts b/packages/eve/src/cli/commands/extension-init.integration.test.ts
new file mode 100644
index 000000000..636037584
--- /dev/null
+++ b/packages/eve/src/cli/commands/extension-init.integration.test.ts
@@ -0,0 +1,208 @@
+import { mkdir, mkdtemp, readFile, writeFile } from "node:fs/promises";
+import { tmpdir } from "node:os";
+import { join } from "node:path";
+
+import { afterEach, describe, expect, it, vi } from "vitest";
+
+import { detectPackageManager } from "#setup/package-manager.js";
+import {
+ scaffoldExtensionProject,
+ type ScaffoldExtensionProjectOptions,
+} from "#setup/scaffold/index.js";
+import { pathExists } from "#setup/path-exists.js";
+
+import type { GitInitResult } from "./init-git.js";
+import {
+ EVE_INIT_PACKAGE_SPEC_ENV,
+ runExtensionInitCommand,
+ type ExtensionInitCliLogger,
+ type ExtensionInitCommandDependencies,
+} from "./extension-init.js";
+
+const BASE_VERSIONS = {
+ evePackage: { version: "0.6.0", nodeEngine: ">=24" },
+ typescriptPackageVersion: "7.0.2",
+ zodPackageVersion: "4.0.0",
+} as const;
+
+function logger(): ExtensionInitCliLogger & { messages: string[]; errors: string[] } {
+ const messages: string[] = [];
+ const errors: string[] = [];
+ return {
+ messages,
+ errors,
+ log: (message) => messages.push(message),
+ error: (message) => errors.push(message),
+ };
+}
+
+function dependencies(
+ gitResult: GitInitResult = { kind: "initialized" },
+): ExtensionInitCommandDependencies & {
+ detectInvokingPackageManager: ReturnType<
+ typeof vi.fn<ExtensionInitCommandDependencies["detectInvokingPackageManager"]>
+ >;
+ isCodingAgentLaunch: ReturnType<
+ typeof vi.fn<ExtensionInitCommandDependencies["isCodingAgentLaunch"]>
+ >;
+ now: ReturnType<typeof vi.fn<ExtensionInitCommandDependencies["now"]>>;
+ runPackageManagerInstall: ReturnType<
+ typeof vi.fn<ExtensionInitCommandDependencies["runPackageManagerInstall"]>
+ >;
+ tryInitializeGit: ReturnType<typeof vi.fn<ExtensionInitCommandDependencies["tryInitializeGit"]>>;
+} {
+ return {
+ detectInvokingPackageManager: vi.fn(() => undefined),
+ isCodingAgentLaunch: vi.fn(async () => false),
+ now: vi.fn(() => 0),
+ detectPackageManager,
+ scaffoldExtensionProject: (options: ScaffoldExtensionProjectOptions) => {
+ const merged = {
+ ...options,
+ evePackage: options.evePackage ?? BASE_VERSIONS.evePackage,
+ typescriptPackageVersion:
+ options.typescriptPackageVersion ?? BASE_VERSIONS.typescriptPackageVersion,
+ zodPackageVersion: options.zodPackageVersion ?? BASE_VERSIONS.zodPackageVersion,
+ };
+ return scaffoldExtensionProject(merged);
+ },
+ runPackageManagerInstall: vi.fn(async () => true),
+ tryInitializeGit: vi.fn(async () => gitResult),
+ };
+}
+
+async function createHostProject(
+ parentDirectory: string,
+ packageJson: Record<string, unknown> = { name: "host-app" },
+): Promise<string> {
+ const projectRoot = join(parentDirectory, "host-app");
+ await mkdir(projectRoot, { recursive: true });
+ await writeFile(
+ join(projectRoot, "package.json"),
+ `${JSON.stringify(packageJson, null, 2)}\n`,
+ "utf8",
+ );
+ await writeFile(join(projectRoot, "pnpm-lock.yaml"), "lockfileVersion: 9.0\n", "utf8");
+ return projectRoot;
+}
+
+afterEach(() => {
+ vi.restoreAllMocks();
+ vi.unstubAllEnvs();
+});
+
+describe("runExtensionInitCommand", () => {
+ it("scaffolds an extension package and prints next steps without starting eve dev", async () => {
+ const parentDirectory = await mkdtemp(join(tmpdir(), "eve-extension-init-"));
+ const output = logger();
+ const deps = dependencies();
+
+ await runExtensionInitCommand(output, parentDirectory, "my-crm", deps);
+
+ const projectPath = join(parentDirectory, "my-crm");
+ const packageJson = JSON.parse(await readFile(join(projectPath, "package.json"), "utf8")) as {
+ eve?: { extension?: string };
+ peerDependencies?: { eve?: string };
+ devDependencies?: { eve?: string; typescript?: string };
+ dependencies?: { zod?: string; ai?: string };
+ scripts?: Record<string, string>;
+ };
+ expect(packageJson.eve?.extension).toBe("./extension");
+ expect(packageJson.peerDependencies?.eve).toBe("^0.6.0");
+ expect(packageJson.devDependencies?.eve).toBe("^0.6.0");
+ expect(packageJson.dependencies?.zod).toBe("4.0.0");
+ expect(packageJson.dependencies?.ai).toBeUndefined();
+ expect(packageJson.scripts?.build).toBe("eve extension build");
+ expect(packageJson.scripts?.prepare).toBe("eve extension build");
+ expect(packageJson.scripts?.dev).toBeUndefined();
+ expect(await readFile(join(projectPath, "extension/extension.ts"), "utf8")).toContain(
+ "defineExtension",
+ );
+ await expect(pathExists(join(projectPath, "extension/tools"))).resolves.toBe(false);
+ await expect(pathExists(join(projectPath, "agent"))).resolves.toBe(false);
+
+ expect(deps.runPackageManagerInstall).toHaveBeenCalledWith(
+ "pnpm",
+ projectPath,
+ expect.objectContaining({ bypassMinimumReleaseAge: true }),
+ );
+ expect(deps.tryInitializeGit).toHaveBeenCalledWith(projectPath);
+
+ const printed = output.messages.join("\n");
+ expect(printed).toContain("Created an eve extension in ");
+ expect(printed).toContain(projectPath);
+ expect(printed).toContain("Initialized Git repository");
+ expect(printed).toContain("extension/extension.ts");
+ expect(printed).toContain("eve extension build");
+ expect(printed).toContain("pnpm run build");
+ expect(printed).toContain("agent/extensions/my-crm.ts");
+ expect(printed).not.toContain("eve dev");
+ });
+
+ it("scaffolds an extension for a coding agent with a named target", async () => {
+ const parentDirectory = await mkdtemp(join(tmpdir(), "eve-extension-init-agent-"));
+ const output = logger();
+ const deps = dependencies();
+ deps.isCodingAgentLaunch.mockResolvedValue(true);
+
+ await runExtensionInitCommand(output, parentDirectory, "my-crm", deps);
+
+ const projectPath = join(parentDirectory, "my-crm");
+ await expect(pathExists(join(projectPath, "extension/extension.ts"))).resolves.toBe(true);
+ expect(deps.runPackageManagerInstall).toHaveBeenCalled();
+ expect(deps.tryInitializeGit).toHaveBeenCalledWith(projectPath);
+ const printed = output.messages.join("\n");
+ expect(printed).toContain("Created an eve extension in ");
+ expect(printed).toContain("What we set up:");
+ expect(printed).not.toContain("Set up an eve agent");
+ });
+
+ it("hands a coding agent the extension setup guide when the target is omitted", async () => {
+ const parentDirectory = await mkdtemp(join(tmpdir(), "eve-extension-init-bare-"));
+ const output = logger();
+ const deps = dependencies();
+ deps.isCodingAgentLaunch.mockResolvedValue(true);
+
+ await runExtensionInitCommand(output, parentDirectory, undefined, deps);
+
+ await expect(pathExists(join(parentDirectory, "extension"))).resolves.toBe(false);
+ expect(deps.runPackageManagerInstall).not.toHaveBeenCalled();
+ expect(deps.tryInitializeGit).not.toHaveBeenCalled();
+ const printed = output.messages.join("\n");
+ expect(printed).toContain("npx eve@latest extension init <name>");
+ expect(printed).toContain("does not start eve dev");
+ expect(printed).toContain("eve extension build");
+ });
+
+ it("rejects an existing project with package.json", async () => {
+ const parentDirectory = await mkdtemp(join(tmpdir(), "eve-extension-init-existing-"));
+ const projectRoot = await createHostProject(parentDirectory);
+ const output = logger();
+ const deps = dependencies();
+
+ await expect(
+ runExtensionInitCommand(output, parentDirectory, "host-app", deps),
+ ).rejects.toThrow("cannot add to an existing project");
+
+ await expect(pathExists(join(projectRoot, "extension"))).resolves.toBe(false);
+ expect(deps.runPackageManagerInstall).not.toHaveBeenCalled();
+ });
+
+ it("honors EVE_INIT_PACKAGE_SPEC for peer and dev eve deps", async () => {
+ const parentDirectory = await mkdtemp(join(tmpdir(), "eve-extension-init-spec-"));
+ const output = logger();
+ const deps = dependencies();
+ vi.stubEnv(EVE_INIT_PACKAGE_SPEC_ENV, "file:/tmp/eve-local.tgz");
+
+ await runExtensionInitCommand(output, parentDirectory, "my-crm", deps);
+
+ const packageJson = JSON.parse(
+ await readFile(join(parentDirectory, "my-crm", "package.json"), "utf8"),
+ ) as {
+ peerDependencies?: { eve?: string };
+ devDependencies?: { eve?: string };
+ };
+ expect(packageJson.peerDependencies?.eve).toBe("file:/tmp/eve-local.tgz");
+ expect(packageJson.devDependencies?.eve).toBe("file:/tmp/eve-local.tgz");
+ });
+});
diff --git a/packages/eve/src/cli/commands/extension-init.ts b/packages/eve/src/cli/commands/extension-init.ts
new file mode 100644
index 000000000..6786cf4d1
--- /dev/null
+++ b/packages/eve/src/cli/commands/extension-init.ts
@@ -0,0 +1,340 @@
+import { mkdtemp, readdir, rename, rm, stat } from "node:fs/promises";
+import { basename, join, resolve } from "node:path";
+import { performance } from "node:perf_hooks";
+
+import pc from "picocolors";
+
+import { isCodingAgentLaunch } from "#cli/agent-detection.js";
+import { EVE_WORDMARK } from "#cli/banner.js";
+import { formatElapsed } from "#cli/format-elapsed.js";
+import { startCliLiveRow } from "#cli/ui/live-row.js";
+import { createLogger, isLogLevelEnabled } from "#internal/logging.js";
+import { formatNodeEngineOverrideWarning } from "#setup/node-engine.js";
+import {
+ detectInvokingPackageManager,
+ detectPackageManager,
+ type PackageManagerKind,
+} from "#setup/package-manager.js";
+import { pathExists } from "#setup/path-exists.js";
+import { parseProjectName } from "#setup/project-name.js";
+import { runPackageManagerInstall } from "#setup/primitives/index.js";
+import type { ProcessOutputLine } from "#setup/primitives/process-output.js";
+import {
+ DEFAULT_EVE_PACKAGE_CONTRACT,
+ type EvePackageContract,
+} from "#setup/scaffold/create/project.js";
+import { scaffoldExtensionProject } from "#setup/scaffold/index.js";
+import type { WorkspaceRootMutation } from "#setup/scaffold/workspace-root.js";
+
+import { initExtensionHandoff, initExtensionInstructions } from "./agent-instructions.js";
+import { tryInitializeGit, type GitInitResult } from "./init-git.js";
+
+export interface ExtensionInitCliLogger {
+ error(message: string): void;
+ log(message: string): void;
+}
+
+export interface ExtensionInitCommandDependencies {
+ detectInvokingPackageManager: typeof detectInvokingPackageManager;
+ detectPackageManager: typeof detectPackageManager;
+ isCodingAgentLaunch: typeof isCodingAgentLaunch;
+ now: () => number;
+ runPackageManagerInstall: typeof runPackageManagerInstall;
+ scaffoldExtensionProject: typeof scaffoldExtensionProject;
+ tryInitializeGit: typeof tryInitializeGit;
+}
+
+const defaultDependencies: ExtensionInitCommandDependencies = {
+ detectInvokingPackageManager,
+ detectPackageManager,
+ isCodingAgentLaunch,
+ now: () => performance.now(),
+ runPackageManagerInstall,
+ scaffoldExtensionProject,
+ tryInitializeGit,
+};
+
+const CURRENT_DIRECTORY_PROJECT_NAME = ".";
+const ALLOWED_CREATE_IN_PLACE_ENTRIES = new Set([".DS_Store", ".git", ".gitkeep", ".hg"]);
+/** Same override env as agent `eve init` so CI can pin the eve package specifier. */
+export const EVE_INIT_PACKAGE_SPEC_ENV = "EVE_INIT_PACKAGE_SPEC";
+
+const initLog = createLogger("extension-init");
+
+function isCurrentDirectoryTarget(target: string): boolean {
+ return /^\.(?:[/\\]+\.?)*$/u.test(target.trim());
+}
+
+async function resolveTargetDirectory(
+ parentDirectory: string,
+ target: string,
+): Promise<string | undefined> {
+ const targetPath = resolve(parentDirectory, target);
+ const stats = await stat(targetPath).catch(() => undefined);
+ return stats?.isDirectory() ? targetPath : undefined;
+}
+
+async function assertCanScaffoldInPlace(targetRoot: string): Promise<void> {
+ const entries = await readdir(targetRoot);
+ const blocking = entries.filter((entry) => !ALLOWED_CREATE_IN_PLACE_ENTRIES.has(entry));
+ if (blocking.length === 0) {
+ return;
+ }
+
+ const visible = blocking.slice(0, 5).join(", ");
+ const suffix = blocking.length > 5 ? `, and ${blocking.length - 5} more` : "";
+ throw new Error(
+ `Cannot create project in current directory because it is not empty. Found: ${visible}${suffix}. Use an empty directory.`,
+ );
+}
+
+async function moveDirectoryContents(sourceRoot: string, targetRoot: string): Promise<void> {
+ for (const entry of await readdir(sourceRoot)) {
+ await rename(join(sourceRoot, entry), join(targetRoot, entry));
+ }
+}
+
+function uniqueWorkspaceRootMutations(
+ mutations: readonly WorkspaceRootMutation[],
+): WorkspaceRootMutation[] {
+ const byKey = new Map<string, WorkspaceRootMutation>();
+ for (const mutation of mutations) {
+ const key = `${mutation.kind}:${mutation.path}`;
+ const existing = byKey.get(key);
+ byKey.set(key, {
+ ...mutation,
+ nodeEngineOverride: mutation.nodeEngineOverride ?? existing?.nodeEngineOverride,
+ });
+ }
+ return [...byKey.values()];
+}
+
+function formatWorkspaceRootMutationWarning(mutation: WorkspaceRootMutation): string {
+ const target = mutation.kind === "package-json" ? "package.json" : "configuration";
+ const suffix =
+ mutation.nodeEngineOverride === undefined
+ ? ""
+ : ` (${formatNodeEngineOverrideWarning(mutation.nodeEngineOverride)})`;
+ return `Updated workspace root ${target} at ${mutation.path}${suffix}`;
+}
+
+async function resolveScaffoldPackageManager(
+ projectPath: string,
+ dependencies: ExtensionInitCommandDependencies,
+): Promise<PackageManagerKind> {
+ const detected = await dependencies.detectPackageManager(projectPath);
+ if (detected.source !== "default") {
+ return detected.kind;
+ }
+ return dependencies.detectInvokingPackageManager() ?? "pnpm";
+}
+
+async function scaffoldExtension(
+ parentDirectory: string,
+ projectName: string,
+ packageManager: PackageManagerKind,
+ dependencies: ExtensionInitCommandDependencies,
+ evePackage: EvePackageContract | undefined,
+): Promise<{ projectPath: string; workspaceRootMutations: WorkspaceRootMutation[] }> {
+ const parentPath = resolve(parentDirectory);
+ const createInPlace = projectName === CURRENT_DIRECTORY_PROJECT_NAME;
+ const projectPath = createInPlace ? parentPath : join(parentPath, projectName);
+ if (createInPlace) {
+ await assertCanScaffoldInPlace(projectPath);
+ } else if (await pathExists(projectPath)) {
+ throw new Error(`Cannot create project because "${projectPath}" already exists.`);
+ }
+
+ const stagingDirectory = await mkdtemp(join(parentPath, ".eve-extension-init-"));
+ const workspaceRootMutations: WorkspaceRootMutation[] = [];
+ try {
+ const stagedProjectName = createInPlace ? basename(projectPath) : projectName;
+ const stagedProjectPath = await dependencies.scaffoldExtensionProject({
+ projectName: stagedProjectName,
+ evePackage,
+ targetDirectory: stagingDirectory,
+ workspaceProbeDirectory: projectPath,
+ packageManager,
+ onWorkspaceRootMutation: (mutation) => {
+ workspaceRootMutations.push(mutation);
+ },
+ });
+
+ if (createInPlace) {
+ await moveDirectoryContents(stagedProjectPath, projectPath);
+ } else {
+ await rename(stagedProjectPath, projectPath);
+ }
+ return {
+ projectPath,
+ workspaceRootMutations: uniqueWorkspaceRootMutations(workspaceRootMutations),
+ };
+ } finally {
+ await rm(stagingDirectory, { recursive: true, force: true });
+ }
+}
+
+function installProgressDetail(
+ packageManager: PackageManagerKind,
+ line: ProcessOutputLine,
+): string | undefined {
+ const text = line.text.trim();
+ if (text === "" || packageManager !== "npm") return text || undefined;
+
+ const manifest = /^npm silly fetch manifest (.+)$/u.exec(text);
+ if (manifest !== null) return `Resolving ${manifest[1]}`;
+
+ const failedRequest = /^npm http fetch \S+ \S+ attempt (\d+) failed with (\S+)$/u.exec(text);
+ if (failedRequest !== null) {
+ return `npm registry · attempt ${failedRequest[1]} failed: ${failedRequest[2]}`;
+ }
+
+ if (line.stream === "stdout" || /^npm (?:error|warn)\b/u.test(text)) return text;
+ return undefined;
+}
+
+const NPM_NOISE_LINE = /^\s*npm (?:silly|verbose|http|timing)\b/u;
+const INSTALL_OUTPUT_FALLBACK_LINES = 20;
+
+function resolveInitEvePackageOverride(): EvePackageContract | undefined {
+ const spec = process.env[EVE_INIT_PACKAGE_SPEC_ENV]?.trim();
+ if (spec === undefined || spec.length === 0) {
+ return undefined;
+ }
+
+ return {
+ nodeEngine: DEFAULT_EVE_PACKAGE_CONTRACT.nodeEngine,
+ version: spec,
+ };
+}
+
+/**
+ * Creates a new eve extension package. Same install/git flow as agent `eve init`,
+ * but always create-only and prints next steps instead of starting `eve dev`.
+ */
+export async function runExtensionInitCommand(
+ logger: ExtensionInitCliLogger,
+ parentDirectory: string,
+ target: string | undefined,
+ dependencies: ExtensionInitCommandDependencies = defaultDependencies,
+): Promise<void> {
+ // Coding agent with no target: print a setup guide, same gate as agent init.
+ if (target === undefined && (await dependencies.isCodingAgentLaunch())) {
+ logger.log(initExtensionInstructions());
+ return;
+ }
+
+ const debug = isLogLevelEnabled("debug");
+ const progress = startCliLiveRow(logger);
+ progress.update("Preparing project");
+
+ let projectPath: string;
+ let packageManager: PackageManagerKind;
+ let workspaceRootMutations: WorkspaceRootMutation[] = [];
+ let agentElapsedMs: number;
+ let installElapsedMs: number;
+ let gitResult: GitInitResult;
+
+ try {
+ const rawTarget = target ?? CURRENT_DIRECTORY_PROJECT_NAME;
+ const currentDirectoryTarget = isCurrentDirectoryTarget(rawTarget);
+ const existingDirectory = currentDirectoryTarget
+ ? (await pathExists(join(resolve(parentDirectory), "package.json")))
+ ? resolve(parentDirectory)
+ : undefined
+ : await resolveTargetDirectory(parentDirectory, rawTarget);
+ const evePackage = resolveInitEvePackageOverride();
+
+ if (existingDirectory !== undefined) {
+ throw new Error(
+ "`eve extension init` creates a new extension package and cannot add to an existing project. " +
+ "Pass a new directory name, or run from an empty directory with `eve extension init .`.",
+ );
+ }
+
+ progress.update("Creating extension");
+ initLog.debug("creating extension");
+ const agentStartedAt = dependencies.now();
+
+ const projectName = currentDirectoryTarget
+ ? CURRENT_DIRECTORY_PROJECT_NAME
+ : parseProjectName(rawTarget);
+ const parentPath = resolve(parentDirectory);
+ const plannedProjectPath =
+ projectName === CURRENT_DIRECTORY_PROJECT_NAME ? parentPath : join(parentPath, projectName);
+ packageManager = await resolveScaffoldPackageManager(plannedProjectPath, dependencies);
+ const scaffold = await scaffoldExtension(
+ parentDirectory,
+ projectName,
+ packageManager,
+ dependencies,
+ evePackage,
+ );
+ projectPath = scaffold.projectPath;
+ workspaceRootMutations = scaffold.workspaceRootMutations;
+ agentElapsedMs = dependencies.now() - agentStartedAt;
+ initLog.debug("creating extension done", { ms: agentElapsedMs });
+
+ progress.update("Installing dependencies", `${packageManager} install`);
+ initLog.debug(`installing dependencies with ${packageManager}`);
+ const installStartedAt = dependencies.now();
+ const installFailureOutput: string[] = [];
+ const recentInstallOutput: string[] = [];
+ const installed = await dependencies.runPackageManagerInstall(packageManager, projectPath, {
+ bypassMinimumReleaseAge: true,
+ progressDetails: process.stdout.isTTY === true && !debug,
+ onOutput: (line) => {
+ if (line.text.trim() !== "") {
+ recentInstallOutput.push(line.text);
+ if (recentInstallOutput.length > INSTALL_OUTPUT_FALLBACK_LINES) {
+ recentInstallOutput.shift();
+ }
+ if (!NPM_NOISE_LINE.test(line.text)) {
+ installFailureOutput.push(line.text);
+ }
+ }
+ if (debug) initLog.debug(line.text);
+ const detail = installProgressDetail(packageManager, line);
+ if (detail !== undefined) progress.update("Installing dependencies", detail);
+ },
+ });
+ installElapsedMs = dependencies.now() - installStartedAt;
+ if (!installed) {
+ initLog.debug("dependency installation failed", { ms: installElapsedMs });
+ progress.stop();
+ const failureOutput =
+ installFailureOutput.length > 0 ? installFailureOutput : recentInstallOutput;
+ for (const line of failureOutput) logger.error(line);
+ throw new Error(`Failed to install dependencies in "${projectPath}".`);
+ }
+ initLog.debug("dependencies installed", { ms: installElapsedMs });
+
+ progress.update("Initializing Git repository");
+ initLog.debug("initializing git repository");
+ gitResult = await dependencies.tryInitializeGit(projectPath);
+ } finally {
+ progress.stop();
+ }
+
+ logger.log(
+ `${pc.green("✓")} Created an ${EVE_WORDMARK} extension in ${pc.bold(projectPath!)} ${pc.dim(`in ${formatElapsed(agentElapsedMs!)}`)}`,
+ );
+ for (const mutation of workspaceRootMutations) {
+ logger.log(pc.yellow(`⚠ ${formatWorkspaceRootMutationWarning(mutation)}`));
+ }
+ logger.log(
+ `${pc.green("✓")} Installed dependencies ${pc.dim(`in ${formatElapsed(installElapsedMs!)}`)}`,
+ );
+ if (gitResult!.kind === "failed") {
+ logger.error(pc.yellow(`Git initialization failed: ${gitResult!.reason}`));
+ } else if (gitResult!.kind === "initialized") {
+ logger.log(`${pc.green("✓")} Initialized Git repository`);
+ }
+ logger.log(
+ initExtensionHandoff({
+ packageManager: packageManager!,
+ packageName: basename(projectPath!),
+ projectPath: projectPath!,
+ }),
+ );
+}
diff --git a/packages/eve/src/cli/commands/init.ts b/packages/eve/src/cli/commands/init.ts
index 82caca87a..bc6af9520 100644
--- a/packages/eve/src/cli/commands/init.ts
+++ b/packages/eve/src/cli/commands/init.ts
@@ -447,6 +447,8 @@ async function runInitSteps(input: {
* 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.
+ *
+ * For extension packages, use `eve extension init` instead.
*/
export async function runInitCommand(
logger: InitCliLogger,
diff --git a/packages/eve/src/cli/run.ts b/packages/eve/src/cli/run.ts
index f9b1de57b..9ea5f117e 100644
--- a/packages/eve/src/cli/run.ts
+++ b/packages/eve/src/cli/run.ts
@@ -305,6 +305,36 @@ function createCliProgram(logger: CliLogger, runtime: CliRuntimeOverrides): Comm
await runChannelsListCommand(logger, appRoot, options);
});
+ const extension = program
+ .command("extension")
+ .description("Create and build reusable eve extension packages.");
+
+ extension
+ // Optional: a missing target scaffolds the current directory, matching
+ // `eve extension init .`.
+ .command("init [target]")
+ .description("Create a new eve extension package.")
+ .option("-y, --yes", "Accepted for compatibility; has no effect")
+ .action(async (target: string | undefined, options: { yes?: boolean }) => {
+ if (options.yes) {
+ logger.error("warning: --yes has no effect for eve extension init.");
+ }
+
+ const { runExtensionInitCommand } = await import("#cli/commands/extension-init.js");
+ await runExtensionInitCommand(logger, appRoot, target);
+ });
+
+ extension
+ .command("build")
+ .description("Build the current package as an eve extension.")
+ .action(async () => {
+ const { loadDevelopmentEnvironmentFiles } = await import("#cli/dev/environment.js");
+ loadDevelopmentEnvironmentFiles(appRoot);
+
+ const { runExtensionBuildCommand } = await import("#cli/commands/extension-build.js");
+ await runExtensionBuildCommand(logger, appRoot);
+ });
+
program
// Optional: a missing target scaffolds or updates the current directory,
// matching `eve init .`.
diff --git a/packages/eve/src/discover/agent.integration.test.ts b/packages/eve/src/discover/agent.integration.test.ts
index 448c3a3f0..a2362e16c 100644
--- a/packages/eve/src/discover/agent.integration.test.ts
+++ b/packages/eve/src/discover/agent.integration.test.ts
@@ -622,14 +622,14 @@ describe("discoverAgent (memory)", () => {
appFiles: {
"node_modules/@acme/crm/package.json": JSON.stringify({
name: "@acme/crm",
- eve: { extension: "ext" },
+ eve: { extension: "extension" },
}),
- "node_modules/@acme/crm/ext/tools/search.ts": "export default {};\n",
+ "node_modules/@acme/crm/extension/tools/search.ts": "export default {};\n",
"node_modules/@acme/gizmo/package.json": JSON.stringify({
name: "@acme/gizmo",
- eve: { extension: "ext" },
+ eve: { extension: "extension" },
}),
- "node_modules/@acme/gizmo/ext/tools/search.ts": "export default {};\n",
+ "node_modules/@acme/gizmo/extension/tools/search.ts": "export default {};\n",
},
agentFiles: {
"extensions/crm.ts": 'export { default } from "@acme/crm";\n',
@@ -688,11 +688,11 @@ describe("discoverAgent (memory)", () => {
appFiles: {
"node_modules/@acme/crm/package.json": JSON.stringify({
name: "@acme/crm",
- eve: { extension: "ext" },
+ eve: { extension: "extension" },
}),
- "node_modules/@acme/crm/ext/tools/search.ts":
+ "node_modules/@acme/crm/extension/tools/search.ts":
'throw new Error("extension modules should not execute during discovery");\n',
- "node_modules/@acme/crm/ext/instructions/policy.md": "Use the CRM before guessing.",
+ "node_modules/@acme/crm/extension/instructions/policy.md": "Use the CRM before guessing.",
},
agentFiles: {
"extensions/crm.ts": 'export { default } from "@acme/crm";\n',
@@ -726,11 +726,11 @@ describe("discoverAgent (memory)", () => {
appFiles: {
"node_modules/@acme/crm/package.json": JSON.stringify({
name: "@acme/crm",
- eve: { extension: "ext" },
+ eve: { extension: "extension" },
}),
- "node_modules/@acme/crm/ext/agent.ts":
+ "node_modules/@acme/crm/extension/agent.ts":
'export default { model: "anthropic/claude-sonnet-5" };\n',
- "node_modules/@acme/crm/ext/tools/search.ts": "export default {};\n",
+ "node_modules/@acme/crm/extension/tools/search.ts": "export default {};\n",
},
agentFiles: {
"extensions/crm.ts": 'export { default } from "@acme/crm";\n',
@@ -774,9 +774,9 @@ describe("discoverAgent (memory)", () => {
appFiles: {
"node_modules/@acme/crm/package.json": JSON.stringify({
name: "@acme/crm",
- eve: { extension: "ext" },
+ eve: { extension: "extension" },
}),
- "node_modules/@acme/crm/ext/tools/search.ts":
+ "node_modules/@acme/crm/extension/tools/search.ts":
'throw new Error("extension modules should not execute during discovery");\n',
},
agentFiles: {
@@ -818,9 +818,9 @@ describe("discoverAgent (memory)", () => {
appFiles: {
"node_modules/@acme/crm/package.json": JSON.stringify({
name: "@acme/crm",
- eve: { extension: "ext" },
+ eve: { extension: "extension" },
}),
- "node_modules/@acme/crm/ext/tools/search.ts":
+ "node_modules/@acme/crm/extension/tools/search.ts":
'throw new Error("extension modules should not execute during discovery");\n',
},
agentFiles: {
@@ -859,9 +859,9 @@ describe("discoverAgent (memory)", () => {
appFiles: {
"node_modules/@acme/crm/package.json": JSON.stringify({
name: "@acme/crm",
- eve: { extension: "ext" },
+ eve: { extension: "extension" },
}),
- "node_modules/@acme/crm/ext/tools/search.ts": "export default {};\n",
+ "node_modules/@acme/crm/extension/tools/search.ts": "export default {};\n",
},
agentFiles: {
"extensions/crm.ts": 'export { default } from "@acme/crm";\n',
@@ -911,9 +911,9 @@ describe("discoverAgent (memory)", () => {
appFiles: {
"node_modules/@acme/crm/package.json": JSON.stringify({
name: "@acme/crm",
- eve: { extension: "ext" },
+ eve: { extension: "extension" },
}),
- "node_modules/@acme/crm/ext/tools/search.ts": "export default {};\n",
+ "node_modules/@acme/crm/extension/tools/search.ts": "export default {};\n",
},
agentFiles: {
"extensions/crm.ts": 'export { default } from "@acme/crm";\n',
@@ -942,11 +942,11 @@ describe("discoverAgent (memory)", () => {
appFiles: {
"node_modules/@acme/crm/package.json": JSON.stringify({
name: "@acme/crm",
- eve: { extension: "ext" },
+ eve: { extension: "extension" },
peerDependencies: { eve: "^2" },
}),
- "node_modules/@acme/crm/ext/extension.ts": "export default {};\n",
- "node_modules/@acme/crm/ext/tools/search.ts": "export default {};\n",
+ "node_modules/@acme/crm/extension/extension.ts": "export default {};\n",
+ "node_modules/@acme/crm/extension/tools/search.ts": "export default {};\n",
},
agentFiles: {
"extensions/crm.ts": 'export { default } from "@acme/crm";\n',
@@ -975,11 +975,11 @@ describe("discoverAgent (memory)", () => {
appFiles: {
"node_modules/@acme/crm/package.json": JSON.stringify({
name: "@acme/crm",
- eve: { extension: "ext" },
+ eve: { extension: "extension" },
peerDependencies: { eve: "^2" },
}),
- "node_modules/@acme/crm/ext/extension.ts": "export default {};\n",
- "node_modules/@acme/crm/ext/tools/search.ts": "export default {};\n",
+ "node_modules/@acme/crm/extension/extension.ts": "export default {};\n",
+ "node_modules/@acme/crm/extension/tools/search.ts": "export default {};\n",
},
agentFiles: {
"extensions/crm.ts": 'export { default } from "@acme/crm";\n',
@@ -1007,11 +1007,12 @@ describe("discoverAgent (memory)", () => {
appFiles: {
"node_modules/@acme/crm/package.json": JSON.stringify({
name: "@acme/crm",
- eve: { extension: "ext" },
+ eve: { extension: "extension" },
}),
- "node_modules/@acme/crm/ext/extension.ts": "export default {};\n",
+ "node_modules/@acme/crm/extension/extension.ts": "export default {};\n",
// Background scheduling is the consuming agent's to own, not an extension's.
- "node_modules/@acme/crm/ext/schedules/sweep.md": '---\ncron: "0 9 * * *"\n---\nSweep.',
+ "node_modules/@acme/crm/extension/schedules/sweep.md":
+ '---\ncron: "0 9 * * *"\n---\nSweep.',
},
agentFiles: {
"extensions/crm.ts": 'export { default } from "@acme/crm";\n',
@@ -1035,13 +1036,13 @@ describe("discoverAgent (memory)", () => {
appFiles: {
"node_modules/@acme/crm/package.json": JSON.stringify({
name: "@acme/crm",
- eve: { extension: "ext" },
+ eve: { extension: "extension" },
}),
- "node_modules/@acme/crm/ext/extension.ts": "export default {};\n",
- "node_modules/@acme/crm/ext/tools/search.ts": "export default {};\n",
+ "node_modules/@acme/crm/extension/extension.ts": "export default {};\n",
+ "node_modules/@acme/crm/extension/tools/search.ts": "export default {};\n",
// The mounted extension itself tries to mount another extension — not
// supported yet, so discovery must reject it rather than drop it.
- "node_modules/@acme/crm/ext/extensions/inner.ts":
+ "node_modules/@acme/crm/extension/extensions/inner.ts":
'export { default } from "@acme/inner";\n',
},
agentFiles: {
@@ -1068,9 +1069,9 @@ describe("discoverAgent (memory)", () => {
appFiles: {
"node_modules/@acme/crm/package.json": JSON.stringify({
name: "@acme/crm",
- eve: { extension: "ext" },
+ eve: { extension: "extension" },
}),
- "node_modules/@acme/crm/ext/tools/search.ts": "export default {};\n",
+ "node_modules/@acme/crm/extension/tools/search.ts": "export default {};\n",
},
agentFiles: {
"extensions/crm.ts": 'export { default } from "@acme/crm";\n',
diff --git a/packages/eve/src/internal/authored-module-loader.ts b/packages/eve/src/internal/authored-module-loader.ts
index bf5941d5f..a7698b7ac 100644
--- a/packages/eve/src/internal/authored-module-loader.ts
+++ b/packages/eve/src/internal/authored-module-loader.ts
@@ -151,7 +151,7 @@ function createFileImportSpecifier(modulePath: string): string {
* same plugin stack the dev/eval loader uses: `eve/*` and node_modules deps stay
* external, relative source is inlined, and (when `extensionScopeNamespace` is
* set) `defineState`/`defineExtension` are scoped to that namespace. Shared with
- * `eve build`'s extension entrypoint compilation so both paths bundle identically.
+ * `eve extension build`'s entrypoint compilation so both paths bundle identically.
*/
export async function bundleAuthoredModuleCode(
modulePath: string,
diff --git a/packages/eve/src/internal/bundler/extension-scope-plugin.integration.test.ts b/packages/eve/src/internal/bundler/extension-scope-plugin.integration.test.ts
index a8e8bcba2..e5a9c3336 100644
--- a/packages/eve/src/internal/bundler/extension-scope-plugin.integration.test.ts
+++ b/packages/eve/src/internal/bundler/extension-scope-plugin.integration.test.ts
@@ -27,7 +27,7 @@ const roots: string[] = [];
function scratchModule(source: string): { modulePath: string; sourceRoot: string } {
const dir = mkdtempSync(join(tmpdir(), "eve-ext-scope-"));
roots.push(dir);
- const sourceRoot = join(dir, "ext");
+ const sourceRoot = join(dir, "extension");
mkdirSync(join(sourceRoot, "tools"), { recursive: true });
const modulePath = join(sourceRoot, "tools", "budget.ts");
writeFileSync(modulePath, source, "utf8");
@@ -72,7 +72,10 @@ describe("extension-scope plugin (bundled)", () => {
const { modulePath } = scratchModule(STATE_MODULE);
const code = await bundle(modulePath, [
createExtensionScopePlugin([
- { sourceRoot: join(tmpdir(), "some-other-extension", "ext"), packageNamespace: "acme-crm" },
+ {
+ sourceRoot: join(tmpdir(), "some-other-extension", "extension"),
+ packageNamespace: "acme-crm",
+ },
]),
externalizeEvePlugin,
]);
diff --git a/packages/eve/src/internal/bundler/extension-scope-plugin.test.ts b/packages/eve/src/internal/bundler/extension-scope-plugin.test.ts
index c5c8b2538..1d6d42dff 100644
--- a/packages/eve/src/internal/bundler/extension-scope-plugin.test.ts
+++ b/packages/eve/src/internal/bundler/extension-scope-plugin.test.ts
@@ -6,7 +6,7 @@ import {
type ExtensionScopeBundlerPlugin,
} from "#internal/bundler/extension-scope-plugin.js";
-const SCOPES = [{ sourceRoot: "/pkg/crm/ext", packageNamespace: "acme-crm" }];
+const SCOPES = [{ sourceRoot: "/pkg/crm/extension", packageNamespace: "acme-crm" }];
function pathPlugin(): ExtensionScopeBundlerPlugin {
const created = createExtensionScopePlugin(SCOPES);
@@ -22,12 +22,12 @@ describe("createExtensionScopePlugin (path containment)", () => {
});
it("redirects eve/context to a namespaced shim for extension-owned importers", () => {
- const id = pathPlugin().resolveId("eve/context", "/pkg/crm/ext/tools/budget.ts");
+ const id = pathPlugin().resolveId("eve/context", "/pkg/crm/extension/tools/budget.ts");
expect(id).toBe("\0eve-ext-scope:context:acme-crm");
});
it("redirects eve/extension to a namespaced shim for extension-owned importers", () => {
- const id = pathPlugin().resolveId("eve/extension", "/pkg/crm/ext/config.ts");
+ const id = pathPlugin().resolveId("eve/extension", "/pkg/crm/extension/config.ts");
expect(id).toBe("\0eve-ext-scope:extension:acme-crm");
});
@@ -40,8 +40,10 @@ describe("createExtensionScopePlugin (path containment)", () => {
});
it("only intercepts the scoped framework modules", () => {
- expect(pathPlugin().resolveId("eve/tools", "/pkg/crm/ext/tools/budget.ts")).toBeUndefined();
- expect(pathPlugin().resolveId("zod", "/pkg/crm/ext/tools/budget.ts")).toBeUndefined();
+ expect(
+ pathPlugin().resolveId("eve/tools", "/pkg/crm/extension/tools/budget.ts"),
+ ).toBeUndefined();
+ expect(pathPlugin().resolveId("zod", "/pkg/crm/extension/tools/budget.ts")).toBeUndefined();
});
});
@@ -89,6 +91,6 @@ describe("shim baking (shared)", () => {
});
it("passes through non-shim ids in load", () => {
- expect(pathPlugin().load("/pkg/crm/ext/tools/budget.ts")).toBeUndefined();
+ expect(pathPlugin().load("/pkg/crm/extension/tools/budget.ts")).toBeUndefined();
});
});
diff --git a/packages/eve/src/internal/nitro/host/build-application.ts b/packages/eve/src/internal/nitro/host/build-application.ts
index b3f88e89f..5ab59275a 100644
--- a/packages/eve/src/internal/nitro/host/build-application.ts
+++ b/packages/eve/src/internal/nitro/host/build-application.ts
@@ -14,10 +14,7 @@ import { WorkflowBundleBuilder } from "#internal/workflow-bundle/builder.js";
import { normalizeEveVercelFunctionOutput } from "#internal/workflow-bundle/vercel-workflow-output.js";
import { createApplicationNitro } from "#internal/nitro/host/create-application-nitro.js";
import { emitVercelAgentSummary } from "#internal/nitro/host/build-vercel-agent-summary.js";
-import {
- buildExtensionPackage,
- tryReadExtensionBuildConfig,
-} from "#internal/nitro/host/build-extension.js";
+import { tryReadExtensionBuildConfig } from "#internal/nitro/host/build-extension.js";
import { prepareApplicationHost } from "#internal/nitro/host/prepare-application-host.js";
import { runVercelBuildPrewarm } from "#internal/nitro/host/vercel-build-prewarm.js";
import type { NitroBuildSurface, PreparedApplicationHost } from "#internal/nitro/host/types.js";
@@ -295,9 +292,13 @@ async function buildVercelNitroSurface(
* Builds the production Nitro output for an eve application.
*/
export async function buildApplication(rootDir: string): Promise<string> {
+ // Extension packages use `eve extension build`. Keep agent `eve build` agent-only
+ // so a mistaken run fails with a clear redirect instead of a half-Nitro path.
const extensionBuild = await tryReadExtensionBuildConfig(rootDir);
if (extensionBuild !== null) {
- return buildExtensionPackage(rootDir, extensionBuild);
+ throw new Error(
+ `Package "${extensionBuild.packageName}" is an eve extension. Run \`eve extension build\` instead of \`eve build\`.`,
+ );
}
const preparedHost = await prepareApplicationHost(rootDir);
diff --git a/packages/eve/src/internal/nitro/host/build-extension.integration.test.ts b/packages/eve/src/internal/nitro/host/build-extension.integration.test.ts
index c174ed99b..87a06bad6 100644
--- a/packages/eve/src/internal/nitro/host/build-extension.integration.test.ts
+++ b/packages/eve/src/internal/nitro/host/build-extension.integration.test.ts
@@ -16,7 +16,7 @@ describe("extension build config", () => {
const root = await mkdtemp(join(tmpdir(), "eve-ext-build-"));
await writeFile(
join(root, "package.json"),
- JSON.stringify({ name: "@acme/crm", type: "module", eve: { extension: "ext" } }),
+ JSON.stringify({ name: "@acme/crm", type: "module", eve: { extension: "extension" } }),
"utf8",
);
const config = await tryReadExtensionBuildConfig(root);
@@ -35,12 +35,12 @@ describe("extension build config", () => {
const root = await mkdtemp(join(tmpdir(), "eve-ext-nodecl-"));
await writeFile(
join(root, "package.json"),
- JSON.stringify({ name: "@acme/nodecl", type: "module", eve: { extension: "ext" } }),
+ JSON.stringify({ name: "@acme/nodecl", type: "module", eve: { extension: "extension" } }),
"utf8",
);
- await mkdir(join(root, "ext", "tools"), { recursive: true });
+ await mkdir(join(root, "extension", "tools"), { recursive: true });
await writeFile(
- join(root, "ext", "tools", "ping.mjs"),
+ join(root, "extension", "tools", "ping.mjs"),
'export default { description: "Ping.", async execute() { return {}; } };\n',
"utf8",
);
diff --git a/packages/eve/src/internal/nitro/host/build-extension.scenario.test.ts b/packages/eve/src/internal/nitro/host/build-extension.scenario.test.ts
index b0a8e838b..9388779db 100644
--- a/packages/eve/src/internal/nitro/host/build-extension.scenario.test.ts
+++ b/packages/eve/src/internal/nitro/host/build-extension.scenario.test.ts
@@ -11,24 +11,24 @@ import {
// `buildExtensionPackage` bundles the entrypoints with rolldown, so these live in
// the scenario tier. They guard the publishing contract: the Node-facing exports
-// must be self-contained runnable JS (no `.ts`/`../ext` source reachable, or an
+// must be self-contained runnable JS (no `.ts`/`../extension` source reachable, or an
// installed package fails under node_modules type-stripping), with the extension
// namespace baked in and declarations emitted.
async function createExtensionPackage(pkg?: Record<string, unknown>): Promise<string> {
const root = await mkdtemp(join(tmpdir(), "eve-ext-scenario-"));
await writeFile(
join(root, "package.json"),
- JSON.stringify({ name: "@acme/crm", type: "module", eve: { extension: "ext" }, ...pkg }),
+ JSON.stringify({ name: "@acme/crm", type: "module", eve: { extension: "extension" }, ...pkg }),
"utf8",
);
- await mkdir(join(root, "ext", "tools"), { recursive: true });
+ await mkdir(join(root, "extension", "tools"), { recursive: true });
await writeFile(
- join(root, "ext", "extension.ts"),
+ join(root, "extension", "extension.ts"),
'import { defineExtension } from "eve/extension";\nexport default defineExtension();\n',
"utf8",
);
await writeFile(
- join(root, "ext", "tools", "crm_search.ts"),
+ join(root, "extension", "tools", "crm_search.ts"),
'export default { description: "Search the CRM.", async execute() { return {}; } };\n',
"utf8",
);
@@ -42,7 +42,7 @@ describe("extension build output", () => {
const outDir = await buildExtensionPackage(root, config!);
const index = await readFile(join(outDir, "index.mjs"), "utf8");
- // Bundled from source: no `.ts`/`../ext` re-export Node would follow natively.
+ // Bundled from source: no `.ts`/`../extension` re-export Node would follow natively.
expect(index).not.toMatch(/from\s+["']\.\.\/ext\//);
// `eve/*` stays external (resolves to the consumer's eve); namespace baked in.
expect(index).toMatch(/from\s+["']eve\/extension["']/);
@@ -59,19 +59,19 @@ describe("extension build output", () => {
const outDir = await buildExtensionPackage(root, config!);
const indexDts = await readFile(join(outDir, "index.d.ts"), "utf8");
- expect(indexDts).toContain('export { default } from "../ext/extension.js"');
- expect(indexDts).toContain('export { default as crm } from "../ext/extension.js"');
+ expect(indexDts).toContain('export { default } from "../extension/extension.js"');
+ expect(indexDts).toContain('export { default as crm } from "../extension/extension.js"');
const toolsDts = await readFile(join(outDir, "tools", "index.d.ts"), "utf8");
expect(toolsDts).toContain(
- 'export { default as crm_search } from "../../ext/tools/crm_search.js"',
+ 'export { default as crm_search } from "../../extension/tools/crm_search.js"',
);
});
it("sanitizes kebab-case tool names into valid export bindings", async () => {
const root = await createExtensionPackage();
await writeFile(
- join(root, "ext", "tools", "get-weather.ts"),
+ join(root, "extension", "tools", "get-weather.ts"),
'export default { description: "Get the weather.", async execute() { return {}; } };\n',
"utf8",
);
diff --git a/packages/eve/src/internal/nitro/host/build-extension.ts b/packages/eve/src/internal/nitro/host/build-extension.ts
index 92afb5284..b6d800cac 100644
--- a/packages/eve/src/internal/nitro/host/build-extension.ts
+++ b/packages/eve/src/internal/nitro/host/build-extension.ts
@@ -57,7 +57,7 @@ interface ManagedExportTarget {
readonly default: string;
}
-/** Subpath exports `eve build` manages for an extension package. */
+/** Subpath exports `eve extension build` manages for an extension package. */
const MANAGED_EXTENSION_EXPORTS: Readonly<Record<string, ManagedExportTarget>> = {
".": { types: "./dist/index.d.ts", default: "./dist/index.mjs" },
"./tools": { types: "./dist/tools/index.d.ts", default: "./dist/tools/index.mjs" },
@@ -193,7 +193,7 @@ interface Reexport {
/**
* Emits one Node-facing entrypoint: a self-contained runnable `.mjs` (bundled
* from the authored source with the extension namespace baked in) and a `.d.ts`
- * barrel whose type re-exports resolve into the shipped `ext/` source.
+ * barrel whose type re-exports resolve into the shipped `extension/` source.
*/
async function emitEntrypoint(input: {
readonly entryPath: string;
@@ -228,7 +228,7 @@ async function emitEntrypoint(input: {
/**
* Rewrites a bundle specifier to the form a `.d.ts` re-export resolves for types,
- * so declarations resolve into the shipped `.ts` source (`../ext/x.ts` → `../ext/x.js`).
+ * so declarations resolve into the shipped `.ts` source (`../extension/x.ts` → `../extension/x.js`).
*/
function toDeclarationSpecifier(specifier: string): string {
return specifier
diff --git a/packages/eve/src/public/definitions/extension.ts b/packages/eve/src/public/definitions/extension.ts
index 8343ba36f..7f23344f2 100644
--- a/packages/eve/src/public/definitions/extension.ts
+++ b/packages/eve/src/public/definitions/extension.ts
@@ -51,7 +51,7 @@ export interface ExtensionHandle<S extends StandardSchemaV1 = StandardSchemaV1>
(values: StandardSchemaV1.InferInput<S>): MountedExtension;
/** The bound configuration, typed from the schema (defaults applied). */
readonly config: StandardSchemaV1.InferOutput<S>;
- /** The declared config schema; read by `eve build`. */
+ /** The declared config schema; read by `eve extension build`. */
readonly schema: S;
}
@@ -102,19 +102,19 @@ function validateConfig(
* Schema (e.g. a Zod object) — describing the settings a consuming agent passes
* at the mount site.
*
- * The default export of an extension's `ext/extension.ts` is a `defineExtension`
+ * The default export of an extension's `extension/extension.ts` is a `defineExtension`
* handle. A consuming agent mounts it, calling the handle to bind config
* (`export default crm({ apiKey })`) or re-exporting it directly when there is no
* config (`export { default } from "@acme/gizmo"`). The extension's own tools,
* hooks, and connections read the bound config through the handle:
*
* ```ts
- * // ext/extension.ts
+ * // extension/extension.ts
* import { defineExtension } from "eve/extension";
* import { z } from "zod";
* export default defineExtension({ config: z.object({ apiKey: z.string() }) });
*
- * // ext/tools/search.ts
+ * // extension/tools/search.ts
* import extension from "../extension.js";
* const { apiKey } = extension.config;
* ```
diff --git a/packages/eve/src/setup/scaffold/create/extension.ts b/packages/eve/src/setup/scaffold/create/extension.ts
new file mode 100644
index 000000000..1f6281e82
--- /dev/null
+++ b/packages/eve/src/setup/scaffold/create/extension.ts
@@ -0,0 +1,277 @@
+import { mkdir, readdir } from "node:fs/promises";
+import { basename, resolve } from "node:path";
+
+import type { PackageManagerKind } from "../../package-manager.js";
+import { pinnedNodeEngineMajor } from "../../node-engine.js";
+import { pathExists, writeTextFile } from "../files.js";
+import { resolveVersionToken } from "../version-tokens.js";
+import {
+ applyPackageManagerWorkspaceConfiguration,
+ isPackageManagerWorkspaceMember,
+ patchWorkspaceRootPackageJson,
+ type WorkspaceRootMutation,
+} from "../workspace-root.js";
+import {
+ CURRENT_DIRECTORY_PROJECT_NAME,
+ DEFAULT_EVE_PACKAGE_CONTRACT,
+ DEFAULT_ZOD_PACKAGE_VERSION,
+ formatEveDependencySpecifier,
+ resolveEvePackageContract,
+ ROOT_ONLY_PACKAGE_JSON_TEMPLATE_SUFFIX,
+ type EvePackageContract,
+} from "./project.js";
+
+const ALLOWED_CREATE_IN_PLACE_ENTRIES = new Set([".DS_Store", ".git", ".gitkeep", ".hg"]);
+const DEFAULT_TYPESCRIPT_PACKAGE_VERSION = "__TYPESCRIPT_VERSION__";
+
+interface ExtensionTemplateContext {
+ appName: string;
+ eveVersion: string;
+ zodPackageVersion: string;
+ typescriptPackageVersion: string;
+ nodeTypesVersion: string;
+ nodeEngine: string;
+}
+
+function renderTemplate(content: string, ctx: ExtensionTemplateContext): string {
+ return content
+ .replaceAll("__EVE_INIT_APP_NAME__", ctx.appName)
+ .replaceAll("__EVE_INIT_PACKAGE_VERSION__", formatEveDependencySpecifier(ctx.eveVersion))
+ .replaceAll("__EVE_INIT_ZOD_VERSION__", ctx.zodPackageVersion)
+ .replaceAll("__EVE_INIT_TYPESCRIPT_VERSION__", ctx.typescriptPackageVersion)
+ .replaceAll("__EVE_INIT_TYPES_NODE_VERSION__", ctx.nodeTypesVersion)
+ .replaceAll("__EVE_INIT_NODE_ENGINE__", ctx.nodeEngine);
+}
+
+/**
+ * Extension package.json as a plain object so named fields like `exports` stay
+ * structured. Tokens are still substituted by {@link renderTemplate}.
+ */
+function packageJsonTemplate(includeRootOnlyFields: boolean): string {
+ const packageJson = {
+ name: "__EVE_INIT_APP_NAME__",
+ version: "0.0.0",
+ type: "module",
+ eve: {
+ extension: "./extension",
+ },
+ files: ["extension", "dist"],
+ exports: {
+ ".": "./extension/extension.ts",
+ },
+ scripts: {
+ build: "eve extension build",
+ prepare: "eve extension build",
+ typecheck: "tsc",
+ },
+ dependencies: {
+ zod: "__EVE_INIT_ZOD_VERSION__",
+ },
+ devDependencies: {
+ "@types/node": "__EVE_INIT_TYPES_NODE_VERSION__",
+ eve: "__EVE_INIT_PACKAGE_VERSION__",
+ typescript: "__EVE_INIT_TYPESCRIPT_VERSION__",
+ },
+ peerDependencies: {
+ eve: "__EVE_INIT_PACKAGE_VERSION__",
+ },
+ };
+
+ // Same trailing engines block the agent scaffold appends for non-workspace roots.
+ return `${JSON.stringify(packageJson, null, 2).slice(0, -1)}${
+ includeRootOnlyFields ? ROOT_ONLY_PACKAGE_JSON_TEMPLATE_SUFFIX : ""
+ }}\n`;
+}
+
+const EXTENSION_DECLARATION_TEMPLATE = `import { defineExtension } from "eve/extension";
+import { z } from "zod";
+
+export default defineExtension({
+ config: z.object({
+ // Replace with the settings consumers pass at the mount site.
+ apiKey: z.string(),
+ }),
+});
+`;
+
+const TSCONFIG_TEMPLATE = `{
+ "compilerOptions": {
+ "target": "ES2022",
+ "module": "esnext",
+ "moduleResolution": "bundler",
+ "types": ["node"],
+ "strict": true,
+ "esModuleInterop": true,
+ "skipLibCheck": true,
+ "noEmit": true
+ },
+ "include": ["extension/**/*.ts"]
+}
+`;
+
+const GITIGNORE_TEMPLATE = `node_modules
+.env*
+.eve
+.vercel
+.workflow-data
+.output
+.nitro
+dist
+.DS_Store
+*.tsbuildinfo
+`;
+
+const AGENTS_MD_TEMPLATE = `# eve Extension Package
+
+This package is an eve extension — a reusable package of tools, connections,
+skills, hooks, and instruction fragments that a consuming agent mounts under
+\`agent/extensions/\`.
+
+Before writing code, read the Extensions guide from the installed eve package
+docs. In most installs, those docs are at \`node_modules/eve/docs/extensions.md\`.
+In workspaces or local package installs, resolve the installed \`eve\` package
+location first and read its \`docs/extensions.md\`. If package docs are
+unavailable, use https://eve.dev/docs/extensions as a fallback.
+
+## Authoring
+
+- Declare the extension in \`extension/extension.ts\` with \`defineExtension\` from
+ \`eve/extension\`. Config is optional; read bound values via the handle's
+ \`.config\` in tools and hooks.
+- Add contributions under \`extension/\` the same way as in an agent:
+ \`tools/\`, \`connections/\`, \`skills/\`, \`hooks/\`, and optional instruction
+ fragments. Names come from file paths; the mount supplies the namespace, so
+ name tools for what they do (\`search\`, not \`crm_search\`).
+- An extension cannot declare \`agent.ts\`, \`sandbox\`, \`schedules\`, or nested
+ \`extensions/\` — those belong to the consuming agent.
+
+## Build and publish
+
+\`eve extension build\` (wired to \`build\`/\`prepare\`) compiles the mount factory
+and tool re-exports into \`dist/\` and fills the package \`exports\` map. Ship both
+\`extension/\` (source the consumer recompiles) and \`dist/\`. Keep \`eve\` as a peer
+dependency so the consumer's eve is the one that runs.
+`;
+
+const CLAUDE_MD_TEMPLATE = `@AGENTS.md
+`;
+
+function templateFiles(includeRootOnlyPackageJsonFields: boolean): Record<string, string> {
+ return {
+ "extension/extension.ts": EXTENSION_DECLARATION_TEMPLATE,
+ "tsconfig.json": TSCONFIG_TEMPLATE,
+ ".gitignore": GITIGNORE_TEMPLATE,
+ "AGENTS.md": AGENTS_MD_TEMPLATE,
+ "CLAUDE.md": CLAUDE_MD_TEMPLATE,
+ "package.json": packageJsonTemplate(includeRootOnlyPackageJsonFields),
+ };
+}
+
+async function assertCanCreateInPlace(
+ targetRoot: string,
+ overwriteExisting: boolean,
+): Promise<void> {
+ if (!(await pathExists(targetRoot))) {
+ return;
+ }
+
+ const entries = await readdir(targetRoot);
+ const blocking = entries.filter((entry) => !ALLOWED_CREATE_IN_PLACE_ENTRIES.has(entry));
+ if (blocking.length > 0 && !overwriteExisting) {
+ const visible = blocking.slice(0, 5).join(", ");
+ const suffix = blocking.length > 5 ? `, and ${blocking.length - 5} more` : "";
+ throw new Error(
+ `Cannot create project in current directory because it is not empty. Found: ${visible}${suffix}. Use an empty directory.`,
+ );
+ }
+}
+
+export interface ScaffoldExtensionProjectOptions {
+ projectName: string;
+ /**
+ * The manager that owns command execution and manager-specific generated
+ * project files for this scaffold. Defaults to pnpm.
+ */
+ packageManager?: PackageManagerKind;
+ targetDirectory?: string;
+ overwriteExisting?: boolean;
+ onOverwriteFile?: (filePath: string) => void | Promise<void>;
+ evePackage?: EvePackageContract;
+ zodPackageVersion?: string;
+ typescriptPackageVersion?: string;
+ /**
+ * Final project path used to discover ancestor workspaces. This differs from
+ * the write target only when the CLI stages a scaffold before moving it into
+ * place.
+ */
+ workspaceProbeDirectory?: string;
+ onWorkspaceRootMutation?: (mutation: WorkspaceRootMutation) => void | Promise<void>;
+}
+
+/**
+ * Scaffolds a standalone eve extension package: `extension/extension.ts`, package
+ * metadata (`eve.extension`, peer+dev `eve`, zod), and TypeScript config. Does
+ * not write sample tools — authors add contributions under `extension/` themselves.
+ */
+export async function scaffoldExtensionProject(
+ options: ScaffoldExtensionProjectOptions,
+): Promise<string> {
+ const targetRoot = resolve(options.targetDirectory ?? process.cwd(), options.projectName);
+ const createInPlace = options.projectName === CURRENT_DIRECTORY_PROJECT_NAME;
+ const overwriteExisting = options.overwriteExisting ?? false;
+ const packageManager = options.packageManager ?? "pnpm";
+ const evePackage = resolveEvePackageContract(options.evePackage ?? DEFAULT_EVE_PACKAGE_CONTRACT);
+ const nodeEngine = pinnedNodeEngineMajor(evePackage.nodeEngine);
+ const workspaceProbeRoot = resolve(options.workspaceProbeDirectory ?? targetRoot);
+ const workspaceMember = isPackageManagerWorkspaceMember(packageManager, workspaceProbeRoot);
+
+ if (createInPlace) {
+ await assertCanCreateInPlace(targetRoot, overwriteExisting);
+ } else if (await pathExists(targetRoot)) {
+ throw new Error(`Cannot create project because "${targetRoot}" already exists.`);
+ }
+
+ const ctx: ExtensionTemplateContext = {
+ appName: basename(targetRoot),
+ eveVersion: evePackage.version,
+ zodPackageVersion: resolveVersionToken(
+ "zodPackageVersion",
+ options.zodPackageVersion ?? DEFAULT_ZOD_PACKAGE_VERSION,
+ ),
+ typescriptPackageVersion: resolveVersionToken(
+ "typescriptPackageVersion",
+ options.typescriptPackageVersion ?? DEFAULT_TYPESCRIPT_PACKAGE_VERSION,
+ ),
+ nodeTypesVersion: nodeEngine,
+ nodeEngine,
+ };
+
+ await mkdir(targetRoot, { recursive: true });
+
+ for (const [relPath, content] of Object.entries(templateFiles(!workspaceMember))) {
+ const filePath = `${targetRoot}/${relPath}`;
+ const existed = await pathExists(filePath);
+ await writeTextFile(filePath, renderTemplate(content, ctx), {
+ force: createInPlace && overwriteExisting,
+ });
+ if (existed) {
+ await options.onOverwriteFile?.(filePath);
+ }
+ }
+
+ await applyPackageManagerWorkspaceConfiguration({
+ packageManager,
+ projectRoot: targetRoot,
+ workspaceProbeRoot,
+ onWorkspaceRootMutation: options.onWorkspaceRootMutation,
+ });
+
+ // Extensions do not depend on `ai`; only reconcile engines.node on a workspace
+ // root when the package is a member.
+ await patchWorkspaceRootPackageJson(packageManager, workspaceProbeRoot, {
+ nodeEngineRequirement: evePackage.nodeEngine,
+ onWorkspaceRootMutation: options.onWorkspaceRootMutation,
+ });
+
+ return targetRoot;
+}
diff --git a/packages/eve/src/setup/scaffold/create/project.ts b/packages/eve/src/setup/scaffold/create/project.ts
index ceeab2b47..e6fd7fe4f 100644
--- a/packages/eve/src/setup/scaffold/create/project.ts
+++ b/packages/eve/src/setup/scaffold/create/project.ts
@@ -212,7 +212,8 @@ function packageJsonTemplate(input: {
`;
}
-const ROOT_ONLY_PACKAGE_JSON_TEMPLATE_SUFFIX = `,
+/** Trailing fields only written when the scaffold is not a workspace member. */
+export const ROOT_ONLY_PACKAGE_JSON_TEMPLATE_SUFFIX = `,
"engines": {
"node": "__EVE_INIT_NODE_ENGINE__"
}
diff --git a/packages/eve/src/setup/scaffold/index.integration.test.ts b/packages/eve/src/setup/scaffold/index.integration.test.ts
index c0c5353fe..4a31e4cc3 100644
--- a/packages/eve/src/setup/scaffold/index.integration.test.ts
+++ b/packages/eve/src/setup/scaffold/index.integration.test.ts
@@ -11,6 +11,7 @@ import {
listAuthoredChannels,
normalizeSlackConnectorSlug,
scaffoldBaseProject,
+ scaffoldExtensionProject,
type WebPackageVersions,
} from "./index.js";
import { PNPM_WORKSPACE_CONTENT } from "../primitives/pm/pnpm.js";
@@ -705,6 +706,66 @@ describe("listAuthoredChannels", () => {
});
});
+describe("scaffoldExtensionProject", () => {
+ test("writes a minimal extension package with peer+dev eve and no sample tools", async () => {
+ const targetDirectory = await createTempDir();
+ const projectRoot = await scaffoldExtensionProject({
+ projectName: "demo-extension",
+ targetDirectory,
+ evePackage: TEST_EVE_PACKAGE,
+ zodPackageVersion: "4.4.3",
+ });
+
+ const packageJson = JSON.parse(await readFile(join(projectRoot, "package.json"), "utf8")) as {
+ name: string;
+ eve?: { extension?: string };
+ files?: string[];
+ peerDependencies?: { eve?: string };
+ devDependencies?: Record<string, string>;
+ dependencies?: Record<string, string>;
+ scripts?: Record<string, string>;
+ engines?: { node?: string };
+ };
+ expect(packageJson).toMatchObject({
+ name: "demo-extension",
+ eve: { extension: "./extension" },
+ files: ["extension", "dist"],
+ peerDependencies: { eve: "^0.25.0" },
+ dependencies: { zod: "4.4.3" },
+ scripts: {
+ build: "eve extension build",
+ prepare: "eve extension build",
+ typecheck: "tsc",
+ },
+ engines: { node: "24.x" },
+ });
+ expect(packageJson.devDependencies?.eve).toBe("^0.25.0");
+ expect(packageJson.devDependencies?.typescript).toBe("7.0.2");
+ expect(packageJson.dependencies?.ai).toBeUndefined();
+ expect(packageJson.scripts?.dev).toBeUndefined();
+
+ const extensionSource = await readFile(join(projectRoot, "extension/extension.ts"), "utf8");
+ expect(extensionSource).toContain('from "eve/extension"');
+ expect(extensionSource).toContain("defineExtension");
+ expect(extensionSource).toContain("apiKey");
+ await expect(pathExists(join(projectRoot, "extension/tools"))).resolves.toBe(false);
+ await expect(pathExists(join(projectRoot, "agent"))).resolves.toBe(false);
+
+ const tsconfig = JSON.parse(await readFile(join(projectRoot, "tsconfig.json"), "utf8")) as {
+ compilerOptions: { moduleResolution?: string; types?: string[] };
+ include?: string[];
+ };
+ expect(tsconfig.compilerOptions.moduleResolution).toBe("bundler");
+ expect(tsconfig.compilerOptions.types).toEqual(["node"]);
+ expect(tsconfig.include).toEqual(["extension/**/*.ts"]);
+
+ const agentsMd = await readFile(join(projectRoot, "AGENTS.md"), "utf8");
+ expect(agentsMd).toContain("eve extension");
+ expect(agentsMd).toContain("extensions.md");
+ expect(agentsMd).toContain("cannot declare");
+ });
+});
+
describe("scaffoldBaseProject", () => {
test("writes a base eve project with the catalog TypeScript version", async () => {
const targetDirectory = await createTempDir();
diff --git a/packages/eve/src/setup/scaffold/index.ts b/packages/eve/src/setup/scaffold/index.ts
index b5c469a37..4f14acec4 100644
--- a/packages/eve/src/setup/scaffold/index.ts
+++ b/packages/eve/src/setup/scaffold/index.ts
@@ -7,6 +7,11 @@ export {
type ScaffoldBaseProjectOptions,
} from "./create/project.js";
+export {
+ scaffoldExtensionProject,
+ type ScaffoldExtensionProjectOptions,
+} from "./create/extension.js";
+
export {
DEFAULT_SLACK_CONNECTOR_SLUG,
SLACK_CHANNEL_DEFAULT_ROUTE,
diff --git a/packages/eve/test/scenarios/compile-agent.scenario.test.ts b/packages/eve/test/scenarios/compile-agent.scenario.test.ts
index 3d9973b62..f1be307bc 100644
--- a/packages/eve/test/scenarios/compile-agent.scenario.test.ts
+++ b/packages/eve/test/scenarios/compile-agent.scenario.test.ts
@@ -570,13 +570,13 @@ describe("compileAgent", () => {
"node_modules/@acme/crm/package.json": `${JSON.stringify({
name: "@acme/crm",
type: "module",
- eve: { extension: "ext" },
- exports: { ".": "./ext/index.mjs" },
+ eve: { extension: "extension" },
+ exports: { ".": "./extension/index.mjs" },
})}\n`,
- "node_modules/@acme/crm/ext/index.mjs": "export default {};\n",
- "node_modules/@acme/crm/ext/instructions/policy.mjs":
+ "node_modules/@acme/crm/extension/index.mjs": "export default {};\n",
+ "node_modules/@acme/crm/extension/instructions/policy.mjs":
'export default { markdown: "Prefer the CRM over guessing." };\n',
- "node_modules/@acme/crm/ext/tools/crm_search.mjs": [
+ "node_modules/@acme/crm/extension/tools/crm_search.mjs": [
'import { defineTool } from "eve/tools";',
"",
"export default defineTool({",
@@ -600,7 +600,7 @@ describe("compileAgent", () => {
expect(result.manifest.instructions?.markdown).toContain("Prefer the CRM over guessing.");
const moduleMapText = await readFile(result.paths.moduleMapPath, "utf8");
- expect(moduleMapText).toContain("@acme/crm/ext/tools/crm_search.mjs");
+ expect(moduleMapText).toContain("@acme/crm/extension/tools/crm_search.mjs");
expect(moduleMapText).toContain('"ext:crm:tools/crm_search.mjs"');
});
diff --git a/packages/eve/test/scenarios/mounted-extension-authored-source.scenario.test.ts b/packages/eve/test/scenarios/mounted-extension-authored-source.scenario.test.ts
index 736100619..dc31b6cc5 100644
--- a/packages/eve/test/scenarios/mounted-extension-authored-source.scenario.test.ts
+++ b/packages/eve/test/scenarios/mounted-extension-authored-source.scenario.test.ts
@@ -30,17 +30,17 @@ describe("mounted extension via authored-source loader", () => {
"node_modules/@acme/crm/package.json": `${JSON.stringify({
name: "@acme/crm",
type: "module",
- eve: { extension: "ext" },
- exports: { ".": "./ext/extension.mjs" },
+ eve: { extension: "extension" },
+ exports: { ".": "./extension/extension.mjs" },
})}\n`,
- "node_modules/@acme/crm/ext/extension.mjs": [
+ "node_modules/@acme/crm/extension/extension.mjs": [
'import { defineExtension } from "eve/extension";',
// Minimal pass-through Standard Schema — this scenario tests binding, not validation.
"const config = { '~standard': { version: 1, vendor: 'scenario', validate: (value) => ({ value }) } };",
"export default defineExtension({ config });",
"",
].join("\n"),
- "node_modules/@acme/crm/ext/tools/crm_echo.mjs": [
+ "node_modules/@acme/crm/extension/tools/crm_echo.mjs": [
'import { defineTool } from "eve/tools";',
'import extension from "../extension.mjs";',
"export default defineTool({",
diff --git a/packages/eve/test/scenarios/mounted-extension-directory-override.scenario.test.ts b/packages/eve/test/scenarios/mounted-extension-directory-override.scenario.test.ts
index fe406d54c..edc8f7fd2 100644
--- a/packages/eve/test/scenarios/mounted-extension-directory-override.scenario.test.ts
+++ b/packages/eve/test/scenarios/mounted-extension-directory-override.scenario.test.ts
@@ -55,16 +55,16 @@ describe("mounted extension via directory form with override", () => {
"node_modules/@acme/crm/package.json": `${JSON.stringify({
name: "@acme/crm",
type: "module",
- eve: { extension: "ext" },
- exports: { ".": "./ext/extension.mjs" },
+ eve: { extension: "extension" },
+ exports: { ".": "./extension/extension.mjs" },
})}\n`,
- "node_modules/@acme/crm/ext/extension.mjs": [
+ "node_modules/@acme/crm/extension/extension.mjs": [
'import { defineExtension } from "eve/extension";',
"const config = { '~standard': { version: 1, vendor: 'scenario', validate: (value) => ({ value }) } };",
"export default defineExtension({ config });",
"",
].join("\n"),
- "node_modules/@acme/crm/ext/tools/crm_echo.mjs": [
+ "node_modules/@acme/crm/extension/tools/crm_echo.mjs": [
'import { defineTool } from "eve/tools";',
'import extension from "../extension.mjs";',
"export default defineTool({",
@@ -76,7 +76,7 @@ describe("mounted extension via directory form with override", () => {
"});",
"",
].join("\n"),
- "node_modules/@acme/crm/ext/tools/crm_status.mjs": [
+ "node_modules/@acme/crm/extension/tools/crm_status.mjs": [
'import { defineTool } from "eve/tools";',
"export default defineTool({",
' description: "Report the extension status.",',
@@ -87,7 +87,7 @@ describe("mounted extension via directory form with override", () => {
"});",
"",
].join("\n"),
- "node_modules/@acme/crm/ext/tools/crm_legacy.mjs": [
+ "node_modules/@acme/crm/extension/tools/crm_legacy.mjs": [
'import { defineTool } from "eve/tools";',
"export default defineTool({",
' description: "A legacy tool the consumer opts out of.",',
@@ -98,7 +98,7 @@ describe("mounted extension via directory form with override", () => {
"});",
"",
].join("\n"),
- "node_modules/@acme/crm/ext/tools/crm_pulse.mjs": [
+ "node_modules/@acme/crm/extension/tools/crm_pulse.mjs": [
'import { defineDynamic, defineTool } from "eve/tools";',
"export default defineDynamic({",
" events: {",
diff --git a/packages/eve/test/scenarios/mounted-extension-installed.scenario.test.ts b/packages/eve/test/scenarios/mounted-extension-installed.scenario.test.ts
index fb5161680..38031c558 100644
--- a/packages/eve/test/scenarios/mounted-extension-installed.scenario.test.ts
+++ b/packages/eve/test/scenarios/mounted-extension-installed.scenario.test.ts
@@ -28,13 +28,13 @@ afterEach(async () => {
const PACKAGE_NAME = "@acme/installed-crm";
const EXT_TREE: Readonly<Record<string, string>> = {
- "ext/extension.ts": [
+ "extension/extension.ts": [
'import { defineExtension } from "eve/extension";',
'const config = { "~standard": { version: 1, vendor: "scenario", validate: (value) => ({ value }) } };',
"export default defineExtension({ config });",
"",
].join("\n"),
- "ext/tools/echo.ts": [
+ "extension/tools/echo.ts": [
'import { defineTool } from "eve/tools";',
'import extension from "../extension.js";',
"export default defineTool({",
@@ -49,8 +49,8 @@ const EXT_TREE: Readonly<Record<string, string>> = {
};
/**
- * Runs `eve build` over a `.ts`-authored extension and returns the built package
- * (compiled `dist/` + source `ext/`) as files to place under the consumer's real
+ * Runs the extension package build over a `.ts`-authored extension and returns the built package
+ * (compiled `dist/` + source `extension/`) as files to place under the consumer's real
* `node_modules/`. Placing it there — rather than a workspace symlink — means the
* mount's `.` entrypoint resolves under `node_modules` and is externalized, so
* Node loads the emitted `dist/index.mjs` directly. The `.ts` source is
@@ -62,10 +62,10 @@ async function buildInstalledExtensionFiles(): Promise<Record<string, string>> {
tempRoots.push(extRoot);
await writeFile(
join(extRoot, "package.json"),
- `${JSON.stringify({ name: PACKAGE_NAME, type: "module", eve: { extension: "./ext" } }, null, 2)}\n`,
+ `${JSON.stringify({ name: PACKAGE_NAME, type: "module", eve: { extension: "./extension" } }, null, 2)}\n`,
"utf8",
);
- await mkdir(join(extRoot, "ext", "tools"), { recursive: true });
+ await mkdir(join(extRoot, "extension", "tools"), { recursive: true });
for (const [path, contents] of Object.entries(EXT_TREE)) {
await writeFile(join(extRoot, path), contents, "utf8");
}
@@ -74,7 +74,7 @@ async function buildInstalledExtensionFiles(): Promise<Record<string, string>> {
await buildExtensionPackage(extRoot, config!);
// `eve build` writes dist/ (compiled entrypoints + declarations) and the
- // exports map into package.json; ship those plus the ext/ source verbatim.
+ // exports map into package.json; ship those plus the extension/ source verbatim.
const packaged = [
"package.json",
"dist/index.mjs",
diff --git a/packages/eve/test/scenarios/mounted-extension-no-config.scenario.test.ts b/packages/eve/test/scenarios/mounted-extension-no-config.scenario.test.ts
index 555527920..20096754f 100644
--- a/packages/eve/test/scenarios/mounted-extension-no-config.scenario.test.ts
+++ b/packages/eve/test/scenarios/mounted-extension-no-config.scenario.test.ts
@@ -26,15 +26,15 @@ describe("mounted extension without config", () => {
"node_modules/@acme/widget/package.json": `${JSON.stringify({
name: "@acme/widget",
type: "module",
- eve: { extension: "ext" },
- exports: { ".": "./ext/extension.mjs" },
+ eve: { extension: "extension" },
+ exports: { ".": "./extension/extension.mjs" },
})}\n`,
- "node_modules/@acme/widget/ext/extension.mjs": [
+ "node_modules/@acme/widget/extension/extension.mjs": [
'import { defineExtension } from "eve/extension";',
"export default defineExtension();",
"",
].join("\n"),
- "node_modules/@acme/widget/ext/tools/widget_ping.mjs": [
+ "node_modules/@acme/widget/extension/tools/widget_ping.mjs": [
'import { defineTool } from "eve/tools";',
"export default defineTool({",
' description: "Return a fixed widget token.",',