AI 文档生成多模型支持Schema 联调

Loom — 面向 API Schema 的 AI 文档引擎

用自然语言驱动接口建模,自动生成结构化 JSON Schema、可复用实体、AI API 文档与 Mock API。
内置 DeepSeek / OpenAI 等 provider 支持,一套命令即可完成 API 文档设计、联调、校验与迭代。

loom chat

自然语言生成 AI API 文档与 Schema

loom view

启动 API 文档与 Schema 查看器

loom mock

启动动态 Mock API 服务做联调

loom serve

文档、Schema 与 Mock 一体化运行

API Schema

AI 驱动 Schema 生成

在 TUI 对话里直接描述接口意图,即可生成和更新 JSON Schema,快速完成接口定义、AI 文档生成与说明同步。

Entity Model

实体优先的复用建模

将通用字段沉淀为实体并在多个端点复用,通过 x-entity-ref 保持请求/响应结构稳定一致,让 API 文档与数据模型更统一。

Mock API

文档查看与 Mock 联动

内置 Web Viewer 与 Mock Server,支持聊天内服务控制,让前后端围绕同一份 API 文档与 Schema 并行开发和联调。

快速开始

几步完成安装,立即开始用 AI 生成 API 文档、Schema 与 Mock 服务

📖 Usage Guide

loom chat

Interactive terminal UI for generating JSON Schema documents through AI conversation.

loom chat [options]

Options:
  -d, --dir <path>    Target project directory (default: current directory)
  -h, --help          Display help

Example Workflow:

  1. Run loom chat
  2. Describe your API endpoints in natural language
  3. AI generates JSON Schema with proper structure
  4. Schema files are saved to docs/ directory (configurable)

Built-in chat commands:

  • Input tip: Enter to send, Shift+Enter/Alt+Enter for newline, / to navigate history (persisted across sessions), Tab to autocomplete commands
  • /help — Show command help
  • /reset — Reset conversation history
  • /list — List generated schema files
  • /mock, /mock stop, /mock restart [port] — Manage mock server
  • /view, /view stop, /view restart [port] — Manage web viewer
  • /scan <dir> — Discover APIs from source code via LLM; /scan resume, /scan reset manage the checkpoint
  • /abort — Abort current request
  • /exit — Exit Loom

loom view

Modern web-based documentation viewer with React SPA interface.

loom view [options]

Options:
  -p, --port <number>  Port number (default: 3000)
  -d, --dir <path>     Target project directory (default: current directory)
  -h, --help           Display help

Features:

  • 📁 Module browsing with endpoint counts
  • 🧩 Entity browsing from docs/entities
  • 🔍 Real-time search across modules and endpoints
  • 📊 Swagger-like schema table viewer for all request/response sections (query params, path params, headers, body)
  • 🔗 x-entity-ref auto-resolve in endpoint request/response rendering
  • 🎨 Clean, responsive UI with dark sidebar
  • 🔗 Direct links to specific endpoints

loom mock

Dynamic mock API server that generates realistic data based on JSON Schema.

loom mock [options]

Options:
  -p, --port <number>  Port number (default: 3001)
  -d, --dir <path>     Target project directory (default: current directory)
  -h, --help           Display help

Features:

  • 🚀 Automatic route registration from JSON Schema files
  • 🎲 Smart mock data generation using mock-json-schema
  • 📡 Support for all HTTP methods (GET, POST, PUT, DELETE, PATCH)
  • 🔧 Configurable response status codes and schemas

loom serve

Combined service that runs both web viewer and mock server together.

loom serve [options]

Options:
  -p, --port <number>  Port number (default: 3000)
  -d, --dir <path>     Target project directory (default: current directory)
  -h, --help           Display help

URL Structure:

  • http://localhost:3000/ - Web documentation viewer
  • http://localhost:3000/api/docs - Documentation API
  • http://localhost:3000/api/schemas - Schema file API
  • http://localhost:3000/api/entities - Entity file API
  • http://localhost:3000/mock/... - Mock API endpoints

loom manifest rebuild

Rebuild docs manifest index file (.loom-manifest.json) for dependency/index consistency.

loom manifest rebuild [options]

Options:
  -d, --dir <path>  Target project directory (default: current directory)
  -h, --help        Display help

loom upgrade

Upgrade loom to the latest npm version.

loom upgrade

常见问题

围绕 AI 文档生成、配置、升级、扫描与本地 API 联调的高频问题

Loom 使用全局配置文件,默认路径为 macOS/Linux 的 ~/.loom/config.json 与 Windows 的 %APPDATA%/loom/config.json,也可通过 LOOM_CONFIG 指定自定义路径。配置完成后,AI 文档生成、API Schema 建模与 Mock 服务能力都会复用同一套设置。

首次执行 loom chat 时会进入引导流程,帮助你创建或更新全局配置;其中 apiKey 为必填项,其他参数可先使用默认值再按需调整。完成后即可开始用 AI 生成 API 文档、JSON Schema 与接口说明。

当前 README 中明确支持通过 LLM provider 生成和更新文档,默认引导以 DeepSeek 为例,同时也可使用 OpenAI 等 provider(按配置切换)。你可以按团队偏好选择模型,用于 AI API 文档生成、Schema 设计与接口迭代。

可以。在 loom chat 中可直接使用 /mock、/view 及其 stop/restart 子命令控制 mock server 与文档查看器,减少来回切换。这样在编写 AI 生成的 API 文档时,也能同步验证接口返回与页面展示。

支持。启动时 Loom 会检查 npm 是否有新版本;你可以确认后自动升级,也可以手动执行 loom upgrade。保持版本更新有助于获得更稳定的 AI 文档生成体验与最新的 Schema 能力。

可以。你可以在聊天中使用 /scan <dir> 触发扫描,并通过 /scan resume、/scan reset 管理扫描进度。Loom 会把现有接口信息整理为更易维护的 API 文档、Schema 与实体定义,方便后续继续用 AI 迭代。