用途
Nudocs 用于把文档上传到 Nudocs.ai 进行富文本编辑,获取可分享的编辑链接,并在编辑完成后把结果拉取回来。它适合需要为文档生成协作编辑链接、让用户在线编辑后再取回更新版本的场景。
主要能力
- 上传文档并获得编辑链接
- 列出所有文档
- 获取指定文档的编辑链接(未指定 ULID 时默认最近一次上传)
- 下载文档,默认格式为 docx,可指定其他格式
- 删除文档
- 查看当前配置
安装与配置
安装 CLI:
npm install -g @nutrient-sdk/nudocs-cli
从 https://nudocs.ai 获取 API 密钥(登录后点击 "Integration")。
配置密钥,方式一为环境变量:
export NUDOCS_API_KEY="nudocs_your_key_here"
方式二为配置文件:
mkdir -p ~/.config/nudocs
echo "nudocs_your_key_here" > ~/.config/nudocs/api_key
使用方式
命令示例:
nudocs upload <file> # 上传并获取编辑链接
nudocs list # 列出所有文档
nudocs link [ulid] # 获取编辑链接(未指定 ULID 时取最近上传)
nudocs pull [ulid] [--format fmt] # 下载文档(默认 docx)
nudocs delete <ulid> # 删除文档
nudocs config # 显示配置
上传流程:创建或编写文档内容,保存为 Markdown 或其他支持的格式,运行 nudocs upload <file>,把返回的编辑链接分享给用户。
拉取流程:用户请求取回文档时,运行 nudocs pull [ulid] --format <fmt>,读取并呈现下载的文件。
格式选择建议:用户使用富文本格式编辑时用 docx(默认);简单文本或代码内容用 md;最终交付或分享用 pdf。完整格式支持见 references/formats.md。
自然语言触发意图包括:上传/发送类(如 "send to nudocs"、"upload to nudocs"、"open in nudocs"、"edit this in nudocs"、"put this in nudocs");拉取/获取类(如 "pull it back"、"pull from nudocs"、"get that doc"、"fetch from nudocs"、"download from nudocs"、"grab the updated version"、"what did I change"、"get my edits");链接类(如 "get the nudocs link"、"share link"、"where's that doc"、"nudocs url");列表类(如 "show my nudocs"、"list my documents"、"what docs do I have"、"my nudocs documents")。
文档最佳实践
上传前确保结构良好:清晰的标题层级(H1 → H2 → H3)、一致的间距、合适的列表格式、简洁的段落(3-5 句)。模板和指南见 references/document-design.md。
示例会话
用户:写一篇关于远程工作的博客文章并发送到 Nudocs。
代理:1. 编写结构良好的 blog-remote-work.md;2. 运行 nudocs upload blog-remote-work.md;3. 返回 "Here's your Nudocs link: https://nudocs.ai/file/01ABC..."。
用户:在 Nudocs 中编辑,添加格式和图片。 用户:把它拉取回来。
代理:1. 运行 nudocs pull --format docx;2. 读取下载的文件;3. 返回 "Got your updated document! Here's what changed..."。
错误处理
- "No API key found":缺少凭据,设置 NUDOCS_API_KEY 或创建配置文件。
- "DOCUMENT_LIMIT_REACHED":免费版限制(10 个文档),删除旧文档或升级到 Pro。
- "Unauthorized":API 密钥无效,在 Nudocs 设置中重新生成密钥。
- "No ULID provided":缺少文档 ID,指定 ULID 或先上传文档。
相关链接
- CLI:https://github.com/PSPDFKit/nudocs-cli
- MCP Server:https://github.com/PSPDFKit/nudocs-mcp-server
- Nudocs:https://nudocs.ai