---
title: 项目结构
description: 了解 next-ai-ready 创建的文件及其作用。
canonical_url: https://next-ai-ready.vercel.app/zh/docs/getting-started/project-structure
url: https://next-ai-ready.vercel.app/zh/docs/getting-started/project-structure
last_updated: 2026-06-02
updated: 2026-06-02
author: next-ai-ready 团队
summary: 了解 next-ai-ready 创建的文件及其作用。
topics: [next.js, setup, project-structure]
---

# 项目结构

运行 `npx next-ai-ready init` 后，你的项目会新增一些文件和目录。以下是每个文件的作用。

## 配置文件

- `ai-ready.config.mjs` — 全站配置。定义 `site` 元数据、内容 glob、action 模块路径和产物开关。详见 [配置](/docs/api-reference/config)。

## 构建产物

由 `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/%5Fai-ready/llms-txt/route.ts` — 提供 `/llms.txt`
- `app/%5Fai-ready/llms-full/route.ts` — 提供 `/llms-full.txt`
- `app/%5Fai-ready/md/[...path]/route.ts` — 提供 `/<route>.md`
- `app/%5Fai-ready/ai-json/[...path]/route.ts` — 提供 `/<route>.ai.json`
- `app/%5Fai-ready/openapi/route.ts` — 提供 `/openapi.json`
- `app/%5Fai-ready/tools/route.ts` — 提供 `/tools.json`
- `app/api/actions/[name]/route.ts` — action 执行端点
- `app/api/mcp/[transport]/route.ts` — MCP 服务器端点

## Actions

- `actions/index.mjs` — action 定义。导出 `defineAction()` 数组。详见 [Actions](/docs/guides/actions)。

## 可选文件

- `instrumentation.ts` + `instrumentation-node.ts` — Next.js instrumentation（通过 `next-ai-ready/hooks` 注册 Node 专用 hook）。详见 [分析](/docs/guides/analytics)。
