by husu
一个写接口文档的AI Agent。支持使用Vibe coding 的方式,编写接口文档,同时自带友好的文档查看工具与接口Mock工具
# Add to your Claude Code skills
git clone https://github.com/husu/loomLast scanned: 6/5/2026
{
"issues": [],
"status": "PASSED",
"scannedAt": "2026-06-05T08:07:34.714Z",
"npmAuditRan": true,
"pipAuditRan": true
}No comments yet. Be the first to share your thoughts!
30 days in the Featured rail
简体中文 | English
基于 AI 的 JSON Schema 文档生成器,集成 TUI 交互、Web 浏览器与 Mock 服务
docs/entities 中维护可复用的实体 Schema,通过 x-entity-ref 在接口 Schema 中引用/mock、/view)loom manifest rebuild 命令重建依赖/索引一致性npm install -g @vegamo/loom
# 或
yarn global add @vegamo/loom
默认全局配置路径:
~/.loom/config.json%APPDATA%/loom/config.json首次运行 loom chat 时,会以交互向导的形式引导你创建/更新该全局配置文件。
聊天首次引导的默认值:
provider:deepseekmodel:deepseek-chatbaseURL:https://api.deepseek.com/v1apiKey:必填,需由用户输入你也可以手动创建全局配置:
{
"outDir": "docs",
"llm": {
"provider": "deepseek",
"model": "deepseek-chat",
"baseURL": "https://api.deepseek.com/v1",
"apiKey": "your_deepseek_api_key",
"temperature": 0.7,
"maxTokens": 2000
},
"serve": {
"port": 3000,
"host": "0.0.0.0"
},
"mock": {
"port": 3001,
"host": "0.0.0.0"
}
}
docs/ 目录仍保留在各项目目录中(通过 --dir 指定),不会被移动到全局存储。
# 启动交互式 TUI 来生成 JSON Schema
loom chat
# 或指定项目目录
loom chat --dir ./my-api-project
在 loom chat 中,你也可以控制本地服务:
/mock、/mock stop、/mock restart [port]/view、/view stop、/view restart [port]# 启动 Web 文档浏览器
loom view
# 或指定端口
loom view --port 8080
# 启动 Mock API 服务
loom mock
# 或指定端口
loom mock --port 8081
# 在同一端口同时启动 Viewer 和 Mock 服务
loom serve
# 访问入口:
# - Web Viewer: http://localhost:3000
# - Mock API: http://localhost:3000/mock/...
# 手动触发升级
loom upgrade
执行其它命令时,Loom 也会检查 npm 是否有新版本。
发现新版本时,确认即可自动升级。
loom chat通过 AI 对话生成 JSON Schema 文档的交互式终端 UI。
loom chat [options]
Options:
-d, --dir <path> 目标项目目录(默认:当前目录)
-h, --help 显示帮助
典型流程:
loom chatdocs/ 目录(可配置)内置聊天命令:
Enter 发送,Shift+Enter/Alt+Enter 换行,↑/↓ 浏览历史记录(跨会话持久化),Tab 自动补全命令/help —— 显示命令帮助/reset —— 重置对话历史/list —— 列出已生成的 Schema 文件/mock、/mock stop、/mock restart [port] —— 管理 Mock 服务/view、/view stop、/view restart [port] —— 管理 Web Viewer/scan <dir> —— 通过 LLM 从源码中识别 API;/scan resume、/scan reset 管理断点/abort —— 中止当前请求/exit —— 退出 Loomloom view基于 React SPA 的现代化 Web 文档浏览器。
loom view [options]
Options:
-p, --port <number> 端口号(默认:3000)
-d, --dir <path> 目标项目目录(默认:当前目录)
-h, --help 显示帮助
特性:
docs/entities 中的实体x-entity-refloom mock基于 JSON Schema 动态生成数据的 Mock API 服务。
loom mock [options]
Options:
-p, --port <number> 端口号(默认:3001)
-d, --dir <path> 目标项目目录(默认:当前目录)
-h, --help 显示帮助
特性:
loom serve组合服务,同时运行 Web Viewer 与 Mock 服务。
loom serve [options]
Options:
-p, --port <number> 端口号(默认:3000)
-d, --dir <path> 目标项目目录(默认:当前目录)
-h, --help 显示帮助
URL 结构:
http://localhost:3000/ —— Web 文档浏览器http://localhost:3000/api/docs —— 文档 APIhttp://localhost:3000/api/schemas —— Schema 文件 APIhttp://localhost:3000/api/entities —— 实体文件 APIhttp://localhost:3000/mock/... —— Mock API 路由loom manifest rebuild重建文档清单索引文件 .loom-manifest.json,确保依赖/索引一致。
loom manifest rebuild [options]
Options:
-d, --dir <path> 目标项目目录(默认:当前目录)
-h, --help 显示帮助
loom upgrade将 loom 升级到 npm 上的最新版本。
loom upgrade
Loom 使用一套为 API 文档优化的自定义 JSON Schema 格式:
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Authentication API",
"description": "User authentication endpoints",
"version": "1.0.0",
"endpoints": [
{
"path": "/api/auth/login",
"method": "POST",
"summary": "User login",
"description": "Authenticate user with credentials",
"tags": ["auth"],
"request": {
"headers": {
"Content-Type": { "type": "string", "enum": ["application/json"] }
},
"body": {
"type": "object",
"properties": {
"username": { "type": "string" },
"password": { "type": "string" }
},
"required": ["username", "password"]
}
},
"response": {
"200": {
"type": "object",
"properties": {
"token": { "type": "string" },
"user": { "type": "object" }
}
},
"400": {
"type": "object",
"properties": {
"error": { "type": "string" }
}
}
}
}
]
}
Loom 支持以下位置的可复用实体 Schema:
docs/entities/*.entity.schema.json
实体文件示例:
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "User",
"description": "Reusable user entity",
"type": "object",
"properties": {
"id": { "type": "integer" },
"name": { "type": "string" },
"email": { "type": "string", "format": "email" }
},
"required": ["id", "name", "email"]
}
在接口 Schema 中通过 x-entity-ref 引用实体:
{
"user": {
"x-entity-ref": {
"entity": "User",
"pick": ["id", "name", "email"]
}
}
}
支持的形式:
"x-entity-ref": "User""x-entity-ref": { "entity": "User", "pick": ["id", "name"] }/scan 与 /scan resume 新增 --lang zh|en 参数。Phase 3(generate-entity)和 Phase 4(generate-endpoint)按所选语言输出 description 与 summary 文本。默认 zh;可通过 ~/.loom/config.json 中的 scan.language 全局覆盖,或在执行命令时使用该参数/scan 的 LLM 缓存对 Phase 3/4 改为按语言区分(键末尾追加 :zh 或 :en),Phase 1/2 仍跨语言共享。切换语言只会失效真正会变的那一半phase1 extract-endpoints、phase2 extract-entities、phase3 generate-entity、phase4 generate-endpoint)。升级自动迁移:旧版本的 Phase 1/2 记录继续命中;Phase 3/4 记录会在下次扫描时重新生成CACHE_VERSION 一刀切清空机制。缓存失效改由 source-hash + 每条记录的形状校验驱动。如有 prompt 重大变更,用户可手动 rm <outDir>/.loom-scan-cache.json 清空summary 时,不再回退到英文 brief,而是退化为 <METHOD> <path>,避免一句英文混在中文文档里/scan <dir> —— 多语言、LLM 驱动的源码 API 识别。识别框架、用 glob 收紧文件范围、提取接口标识(Phase 1)、识别并生成实体 Schema(Phase 1.5),然后按路由前缀生成单文件 Schema(Phase 2,通过 x-entity-ref 引用实体)/scan resume 和 /scan reset —— 基于断点继续被中断的扫描,或丢弃已保存的断点/scan 的 LLM 输出缓存,按文件内容哈希索引(<outDir>/.loom-scan-cache.json);增量扫描会跳过未变更的文件,可节省 25 分钟以上。可使用 --no-cache 强制调用 LLMloom chat 的输入历史持久化在全局 ~/.loom/history.jsonl(上限 100 条),上下方向键跨会话浏览src/tui/commands.ts),让 Header 面板、/help 文案与自动补全列表共享一份数据源{ userToken, action: "used" }。UUID 持久化于 ~/.loom/install-id,离线时落到 ~/.loom/telemetry-outbox.jsonl<outDir>/.loom-scan.log,以及来自 scan-failures.ts 的原始响应快照,便于排查 LLM 问题/scan 容忍推理模型的输出格式(例如 DeepSeek-R1 在同一响应中先输出 <think> 再给出最终 JSON)APIConnectionError 与 SDK 内部 abort 归为可重试的 timeout/scan resume,现在会提示 "scan already complete" 而不是默默重跑 analyzerequired[] 表达,而不是 type 联合doneCount 自增过程中保留 group 冲突策略/scan resume 能从正确步骤继续/help 同步(现在包含 /scan 与 /abort)/init 命令;若项目里存在 requirement.md,仍会作为 agent 上下文加载<name>.mock.json 存储(每个接口同时只有一个生效 override)/mock/<path> 会真的返回 HTTP 400)request schema 生成(path、query、headers、body 全部填充示例值)@cname、@integer(1,100)、'list|1-5': [...] 等)—— 模板原样存储,每次请求时再展开loom view)或组合服务(loom serve)时的 setNotFoundHandler 重复注册错误@stoplight/json-schema-viewer 依赖