准备环境

Eve 当前要求 Node.js 24 或更高版本。先确认版本:

node -v

如果低于 24,可以用 nvm 切换:

nvm install 24
nvm use 24

还需要准备一个 Vercel AI Gateway API Key。第一篇先走全套 Vercel 方案,不处理自定义 OpenAI-Compatible Provider。模型切换、自定义 base URL、API key 和上下文窗口预算,会放到下一篇展开。

用 eve init 创建项目

进入系列仓库的样例目录:

cd example

执行:

npx eve@latest init 01-first-agent

eve init 会做几件事:

  • 创建 01-first-agent/ 目录;
  • 写入最小 Agent 文件;
  • 安装依赖;
  • 生成内置 Eve channel;
  • 初始化本地开发所需配置。

创建完成后进入项目:

cd 01-first-agent

本文最终整理后的核心结构大致是:

example/01-first-agent/
  package.json
  tsconfig.json
  .env.example
  agent/
    agent.ts
    instructions.md
    channels/
      eve.ts

这里最值得先记住的是 agent/ 目录。

Eve 的设计是:一个目录就是一个 Agent 的 authored surface。模型配置、系统提示词、工具、技能、子 Agent、渠道、定时任务,都会逐步放在这个目录下面。

从 eve init 到第一个可运行 Agent

先看 package.json

eve init 会写好常用脚本:

{
  "scripts": {
    "build": "eve build",
    "dev": "eve dev",
    "start": "eve start",
    "typecheck": "tsc"
  }
}

这一篇主要用两个命令:

npm run dev
npm exec -- eve info

npm run dev 会启动 Eve 本地开发 TUI,也就是我们用来聊天的 CLI 界面。

eve info 不启动聊天界面,只检查 Eve 是否正确发现了项目里的 Agent 文件。后续目录越来越多时,这个命令会很有用。

配置第一个 Agent

打开 agent/agent.ts,改成下面这样:

import { defineAgent } from "eve";

const defaultGatewayModelId = "minimax/minimax-m3";

export default defineAgent({
  model: process.env.EVE_GATEWAY_MODEL_ID ?? defaultGatewayModelId,
  modelContextWindowTokens: 200_000,
});

defineAgent 是 Agent 的运行配置入口。

这里先只做两件事:

第一,指定模型。字符串形式的模型 ID 会通过 Vercel AI Gateway 路由。为了方便调整,我们允许用环境变量 EVE_GATEWAY_MODEL_ID 覆盖默认模型。

第二,显式写了 modelContextWindowTokens。这是一个很现实的 beta 细节:如果 Eve 当前还没有拿到某个 Gateway 模型的上下文窗口元数据,构建时可能会提示无法编译 compaction 配置。显式声明上下文窗口可以让样例先稳定跑起来。

正式项目里,这个值应该按所选模型的真实上下文窗口调整。下一篇接入自定义 Provider 时,我们会把模型配置、上下文窗口、token 预算和失败边界一起讲清楚。

编写 instructions

接下来改 agent/instructions.md

它是 Agent 的 always-on system prompt。Eve 会把这份内容放进每一轮模型调用里,所以它适合写稳定身份、长期规则和行为边界,不适合塞一整套临时工作流程。

这一篇先写一个很小的 SpringForAll 内容运营助手:

# SpringForAll Content Assistant

You are the first content operations assistant for the SpringForAll community.

Your mission is to help maintain a Chinese technical community for Java and Spring developers.

## Responsibilities

- Explain what you can do for SpringForAll content operations.
- Help brainstorm Java, Spring, Spring AI, Spring Cloud, JVM, backend engineering, and developer tooling topics.
- Turn vague topic ideas into practical article angles, outlines, and follow-up questions.
- Keep answers practical and useful for engineers.
- Ask for human confirmation before treating any content as publish-ready.

## Current limits

- You do not have skills yet.
- You do not have subagents yet.
- You do not have custom tools yet.
- You do not publish content automatically.
- You should not claim to have checked live sources unless the user provides them in the conversation.

## Output style

- Write in concise Chinese by default.
- Use Markdown when structure helps.

我会刻意在早期 instructions 里写清楚限制。

这不是给 Agent 降能力,而是让它知道当前阶段的边界:它现在只是一个基础聊天 Agent,还没有搜索工具、内容工作流、审稿 checklist,也没有自动发布能力。

如果一开始就让它表现得像完整内容团队,后面加 skills、subagents 和 sandbox 时,读者反而看不清每一步到底解决了什么问题。

Logo

Agent 垂直技术社区,欢迎活跃、内容共建。

更多推荐