getting started
项目结构
了解 next-ai-ready 创建的文件及其作用。
运行 npx next-ai-ready init 后,你的项目会新增一些文件和目录。以下是每个文件的作用。
配置文件
ai-ready.config.mjs— 全站配置。定义site元数据、内容 glob、action 模块路径和产物开关。详见 配置。
构建产物
由 npx next-ai-ready build 生成,应加入 gitignore:
.next-ai-ready/graph.json— SemanticGraph。包含所有路由、章节、分块、FAQ 条目和 JSON-LD 块。运行时 handler 读取此文件。.next-ai-ready/actions.manifest.json— 已注册的 action 及其 JSON Schema(handler 已剥离)。供 OpenAPI、tools.json 和 MCP 使用。
静态输出
构建时写入 public/:
public/llms.txt— 面向 LLM 和 AI 爬虫的全站索引。public/llms-full.txt— 完整 dump(正文 + FAQ),供 RAG 使用。public/openapi.json— OpenAPI 3.1 规范。public/tools.json— OpenAI function-calling 格式的工具定义。public/.well-known/ai-plugin.json— AI 网关的插件清单。public/robots.txt— AI 爬虫策略。
路由 handler
由 init 创建在 app/ 下。每个文件都是一行 re-export——可读、可审计、可自定义:
app/_ai-ready/llms-txt/route.ts— 提供/llms.txtapp/_ai-ready/llms-full/route.ts— 提供/llms-full.txtapp/_ai-ready/md/[...path]/route.ts— 提供/<route>.mdapp/_ai-ready/ai-json/[...path]/route.ts— 提供/<route>.ai.jsonapp/_ai-ready/openapi/route.ts— 提供/openapi.jsonapp/_ai-ready/tools/route.ts— 提供/tools.jsonapp/api/actions/[name]/route.ts— action 执行端点app/api/mcp/[transport]/route.ts— MCP 服务器端点
Actions
actions/index.mjs— action 定义。导出defineAction()数组。详见 Actions。
可选文件
instrumentation.ts+instrumentation-node.ts— Next.js instrumentation(通过next-ai-ready/hooks注册 Node 专用 hook)。详见 分析。