# Lune 命令行应用

Lune 命令行应用可以把 Lune MCP 服务器安装到受支持的本地 Agent。它也能在终端里处理登录和团队、创建访问密钥，并报告自身的配置状况。

命令行应用是可选的。科研工作请交给 AI Agent，由它调用 Lune 的 MCP 工具；命令行应用自带的查询只适合快速核对。

## 安装

```sh
npm install -g @retrograde-labs/lune-cli
```

需要 Node.js 22.12 或更高版本。如果还没有 Node，请通过 [nodejs.org](https://nodejs.org) 或包管理器安装。

## 登录

```sh
lune login
```

这会打开浏览器标签页，让你用 Lune 账户登录。命令行应用会保存登录状态，只有在运行 `lune logout` 之后、使用新的 `--profile` 时，或闲置 90 天后，才需要重新登录。想改用访问密钥登录，运行 `lune login --api-key lune_your_access_key`。

```sh
lune whoami
```

显示这次登录计费的团队（浏览器登录时就是个人团队）、它的套餐、今天已用请求数与每日额度、点数余额，以及登录方式。它需要 `account:read` 权限，浏览器登录和用默认权限创建的密钥都带有这项权限。

## 把 Lune 接入本地 AI Agent

命令行应用可以一步写好下列 Agent 的 MCP 配置：

```sh
lune install --client claude-code
lune install --client cursor
lune install --client vscode
lune install --client codex
lune install --client opencode
```

先用 `lune login` 登录。不带参数运行 `lune install` 可以从列表中选择。它会问你是新建访问密钥，还是使用已有的密钥。新密钥归你选择的团队（只有你加入了不止一个团队时才会问），并带有默认的四项权限。密钥随后写进 Agent 的配置文件。如果你是用访问密钥登录的，安装时会直接沿用那个密钥。

有些应用通过自己的界面接入，例如 Claude Desktop、Perplexity 和 Manus。对这类应用，命令会给出控制台上对应步骤的链接：

```sh
lune install --client claude-desktop
```

之后若要从某个 Agent 移除 Lune：

```sh
lune uninstall --client cursor
```

对于在应用内部配置的连接，`lune uninstall` 会引导你去凭证页面撤销密钥或已接入的应用。

## 在已接入的 Agent 中使用 Lune

安装完成后，打开本地 Agent，让它检索 Paper、阅读全文、追踪引用、比较方法、核验论断或查询科研最佳实践。Agent 会自己选用 Lune 的工具。

不开 Agent，也可以快速核对：

```sh
lune papers search "diffusion model guidance"
lune guidance search "how to design an ablation"
```

每次查询都和对应的工具调用一样，计入每日额度。

## 管理账户

```sh
lune teams list                  # 你加入的所有团队
lune teams use <slug>            # 设置 lune keys create 使用的团队
lune teams current               # 显示该团队

lune keys create --name laptop   # 新建访问密钥（只显示一次）
```

`lune keys create` 支持用 `--scopes` 和 `--expires` 指定密钥的权限和有效期。它需要浏览器登录：用访问密钥登录时无法创建密钥。要列出或撤销密钥，请前往[凭证页面](https://luneresearch.com/dashboard/settings/credentials)。

## 多个身份

如果你同时把 Lune 用于个人和团队工作，`--profile` 参数可以把两者分开。

```sh
lune --profile work login
lune --profile work teams use acme
lune --profile work keys create --name work-laptop
```

不传 `--profile` 时，命令行应用使用 `default`。每个 profile 都有自己的登录状态，以及 `lune keys create` 使用的团队。浏览器登录的用量始终记在个人团队名下，与 profile 选中的团队无关。想在命令行里使用共享团队的额度，请用在该团队创建的访问密钥登录这个 profile。

## 诊断

```sh
lune doctor
```

输出版本和 profile、是否保存了登录及登录方式、profile 对应的团队、Lune 服务是否可达，以及检测到的每个 Agent 和 `lune install` 会为它写入的配置文件。它不会检查已保存的登录是否仍然有效，也不会测试 MCP 连接。要测试连接，请用[故障排查](https://luneresearch.com/zh-Hans/docs/troubleshooting#手动测试连接)中的方法。
