通过实际操作产品验证交付内容,记录用户可查看的证据,并发布验收报告。可检查已有验证计划或创建检查项,选择合适的操作界面,并使用 `lh` CLI 发布结果。
- 实际检查更改后的产品行为
- 收集截图或其他验证证据
- 编写验证计划和报告
本指南介绍 LobeHub CLI(`@lobehub/cli`)的命令结构、认证和工作区规则,以及如何新增或维护命令。还涵盖表格与 JSON 输出、设置文件位置和连接本地开发服务器的流程。
LobeHub CLI (@lobehub/cli) development guide — commands, subcommands, architecture.
实测评分 未实测
查看安装方法本指南说明 LobeHub CLI(@lobehub/cli)的结构,以及如何添加和维护命令。它列出了登录、智能体、任务、文件、知识库、模型和技能等命令组的用途。指南通过示例介绍如何创建命令文件、在入口文件中注册命令、输出表格或 JSON、获取认证令牌,以及处理确认提示。内容还包括工作区选择规则、设置文件的保存位置,以及连接本地开发服务器并运行 CLI 的步骤。
需要确认新功能应加到现有 CLI 的哪个位置,或希望各命令遵循相同的输出和认证方式时,可以参考本指南。它也适用于需要区分本地与生产环境设置,并想按照文档中的运行示例进行开发的情况。
CLI 可通过 Node.js 或 Bun 运行。使用本地开发服务器的流程包括启动服务器和进行认证。
本介绍由 AI(OpenAI Codex)根据公开的 SKILL.md 撰写。准确的规格请查看下方原文。
AI 根据 SKILL.md 的内容检查了需要注意的操作和使用前提。评分只依据实际运行的结果(实测对比)。
不计入评分。 由 AI(OpenAI Codex)于 2026年10月26日 评估。仅供参考,安装前请同时查看原文。
安装前可以查看交给 AI 代理的指令内容。
LobeHub CLI (@lobehub/cli) is a command-line tool for managing and interacting with LobeHub services. Built with Commander.js + TypeScript.
apps/cli/apps/cli/src/index.tslh, lobe, lobehub (all aliases for the same CLI)apps/cli/src/
├── index.ts # Entry point — parses argv, invokes program.ts
├── program.ts # Builds the Commander program, registers every command
├── api/
│ ├── acceptance/ # `lh acceptance`: review loop, rounds (run/), plans, criteria, rubrics; `lh verify` aliases
│ ├── client.ts # tRPC client (type-safe backend API)
│ └── http.ts # Raw HTTP utilities
├── auth/
│ ├── credentials.ts # Encrypted credential storage (AES-256-GCM)
│ ├── identity.ts # Account fingerprint for machine-local state
│ ├── refresh.ts # Token auto-refresh
│ └── resolveToken.ts # Token resolution (flag > stored)
├── commands/ # All CLI commands (one file per command group)
│ ├── agent.ts # Agent CRUD + run
│ ├── agent-group.ts # Agent group CRUD
│ ├── agent-signal/ # Inspect and trigger Agent Signal source events
│ ├── artifact.ts # Publish local HTML pages as artifacts
│ ├── bot.ts # Bot integrations (channels, access policies, messengers)
│ ├── completion.ts # Shell completion script output
│ ├── config.ts # whoami, usage
│ ├── connect.ts # Device gateway connection + daemon
│ ├── device.ts # Manage connected devices
│ ├── doc.ts # Document management
│ ├── doctor.ts # Machine diagnostics (runtime, endpoints, credentials, readiness)
│ ├── eval.ts # Evaluation workflows & benchmarks
│ ├── file.ts # File management
│ ├── generate/ # Content generation (text/image/video/tts/asr)
│ ├── goal.ts # Long-horizon Goal Graphs
│ ├── hetero.ts # Run heterogeneous agent CLIs, stream their output
│ ├── kb.ts # Knowledge base management
│ ├── login.ts # OIDC Device Code Flow / API key auth
│ ├── logout.ts # Clear credentials
│ ├── man.ts # CLI manual pages
│ ├── memory.ts # User memory management
│ ├── message.ts # Message management
│ ├── migrate/ # Import data from external tools (OpenClaw, ChatGPT, Claude, etc.)
│ ├── model.ts # AI model management
│ ├── notify.ts # Send a callback message to a topic to trigger the agent
│ ├── plugin.ts # Plugin management
│ ├── project.ts # Goal-oriented project management
│ ├── provider.ts # AI provider management
│ ├── search.ts # Global search
│ ├── session-group.ts # Agent session group management
│ ├── skill.ts # Agent skill management
│ ├── status.ts # Gateway connectivity check
│ ├── task/ # Agent task management (assignees, checkpoints, deps, review)
│ ├── thread.ts # Message thread management
│ ├── topic.ts # Conversation topic management
│ ├── trace/ # Inspect and replay recorded agent execution traces
│ ├── update.ts # Self-update to the latest published version
│ ├── user.ts # User account & settings
│ └── workspace.ts # Workspace list/scope/members/usage/audit
├── daemon/
│ └── manager.ts # Background daemon process management
├── tools/
│ ├── shell.ts # Shell command execution (for gateway)
│ └── file.ts # File operations (for gateway)
├── settings/
│ └── index.ts # Persistent settings (~/.lobehub/)
├── utils/
│ ├── logger.ts # Logging (verbose mode)
│ ├── format.ts # Table output, JSON, timeAgo/timeUntil, truncate
│ └── agentStream.ts # WebSocket streaming for agent runs and task follow
└── constants/
└── urls.ts # Official server & gateway URLs
| Command | Alias | Description |
|---|---|---|
lh login | - | Authenticate via OIDC Device Code Flow or API key |
lh logout | - | Clear stored credentials |
lh connect | - | Device gateway connection & daemon management |
lh device | - | Manage connected devices |
lh status | - | Quick gateway connectivity check |
lh doctor | - | Diagnose machine readiness (runtime, endpoints, credentials, scope, device, agent) |
lh agent | - | Agent CRUD, run, status |
lh agent-group | - | Agent group CRUD |
lh agent-signal | - | Inspect and trigger Agent Signal source events |
lh hetero | - | Run heterogeneous agent CLIs (Claude Code, Codex, etc.), stream their output |
lh goal | - | Run long-horizon Goal Graphs |
lh project | - | Manage goal-oriented projects |
lh task | - | Manage agent tasks (assignees, checkpoints, deps, review) |
lh thread | - | Manage message threads |
lh trace | - | Inspect and replay recorded agent execution traces |
lh acceptance | - | Delivery acceptances: review loop, rounds, per-run check plans, criteria, rubrics |
lh verify | - | Deprecated alias of lh acceptance commands |
lh eval | - | Manage evaluation workflows and benchmarks |
lh generate | gen | Content generation (text, image, video, tts, asr, download) |
lh doc | - | Document CRUD, batch-create, parse, topic linking |
lh file | - | File list, view, delete, recent |
lh artifact | - | Publish local HTML pages as artifacts |
lh kb | - | Knowledge base CRUD, folders, docs, upload, tree view |
lh memory | - | User memory CRUD + extraction |
lh message | - | Message list, search, delete, count, heatmap |
lh topic | - | Topic CRUD + search + recent |
lh notify | - | Send a callback message to a topic and trigger the agent to process it |
lh migrate | - | Import data from external tools (OpenClaw, ChatGPT, Claude, etc.) |
lh bot | - | Manage bot integrations (channels, access policies, messengers) |
lh skill | - | Skill CRUD + import (GitHub/URL/market) |
lh model | - | Model CRUD, toggle, batch-toggle, clear |
lh provider | - | Provider CRUD, config, test, toggle |
lh plugin | - | Plugin install, uninstall, update |
lh search | - | Global search across all types |
lh session-group | - | Manage agent session groups |
lh workspace | ws | Workspace list, scope switch, members, invites, usage |
lh user | - | Manage user account and settings |
lh whoami | - | Current user info (including the resolved workspace scope) |
lh usage | - | Monthly/daily usage statistics |
lh man | - | Show a manual page for the CLI or a subcommand |
lh completion | - | Output shell completion script |
lh update | - | Update the CLI to the latest published version |
Every command runs against one scope, resolved in this order:
--workspace <id> on the commands that take itLOBEHUB_WORKSPACE_ID env varlh workspace use <id|slug>The persisted scope is bound to the account and server it was chosen under. If
either changes — a different lh login, a --server switch — it is ignored and
reported as stale rather than attaching a workspace header the new identity has
no membership in. lh logout clears it. lh whoami and lh workspace current
both print which of the four sources is in effect.
API-key auth carries no local account identity, so there is nothing to bind a
saved scope to — those callers pass LOBEHUB_WORKSPACE_ID instead.
Create apps/cli/src/commands/<name>.ts:
import type { Command } from 'commander';
import { getTrpcClient } from '../api/client';
import { outputJson, printTable, truncate } from '../utils/format';
export function register<Name>Command(program: Command) {
const cmd = program.command('<name>').description('...');
// Subcommands
cmd
.command('list')
.description('List items')
.option('-L, --limit <n>', 'Maximum number of items', '30')
.option('--json [fields]', 'Output JSON, optionally specify fields')
.action(async (options) => {
const client = await getTrpcClient();
const result = await client.<router>.<procedure>.query({ ... });
// Handle output
});
}
In apps/cli/src/index.ts:
import { registerNewCommand } from './commands/new';
// ...
registerNewCommand(program);
Create apps/cli/src/commands/<name>.test.ts alongside the command file.
All list/view commands follow consistent patterns:
--json [fields] - JSON output with optional field filtering--yes - Skip confirmation for destructive ops-L, --limit <n> - Pagination limit (default: 30)-v, --verbose - Verbose loggingconst rows = items.map((item) => [item.id, truncate(item.title, 40), timeAgo(item.updatedAt)]);
printTable(rows, ['ID', 'TITLE', 'UPDATED']);
if (options.json !== undefined) {
const fields = typeof options.json === 'string' ? options.json : undefined;
outputJson(items, fields);
return;
}
Commands that need auth use getTrpcClient() which auto-resolves tokens:
const client = await getTrpcClient();
// client.router.procedure.query/mutate(...)
import { confirm } from '../utils/format';
if (!options.yes) {
const ok = await confirm('Are you sure?');
if (!ok) return;
}
| File | Path | Purpose |
|---|---|---|
| Credentials | ~/.lobehub/credentials.json | Encrypted tokens (AES-256-GCM) |
| Settings | ~/.lobehub/settings.json | Custom server/gateway URLs |
| Workspace | ~/.lobehub/active-workspace | Active scope + the account/server it is bound to |
| Daemon PID | ~/.lobehub/daemon.pid | Background process PID |
| Daemon Status | ~/.lobehub/daemon.status.json | Connection status JSON |
| Daemon Log | ~/.lobehub/daemon.log | Daemon output log |
The base directory (~/.lobehub/) can be overridden with the LOBEHUB_CLI_HOME env var (e.g. LOBEHUB_CLI_HOME=.lobehub-dev for dev mode isolation).
commander - CLI framework@trpc/client + superjson - Type-safe API client@lobechat/device-gateway-client - WebSocket gateway connection@lobechat/local-file-shell - Local shell/file tool executionpicocolors - Terminal colorsws - WebSocketdiff - Text diffingfast-glob - File pattern matchingDev mode uses LOBEHUB_CLI_HOME=.lobehub-dev to isolate credentials from the global ~/.lobehub/ directory, so dev and production configs never conflict.
# Run a command in dev mode (from apps/cli/)
cd apps/cli && bun run dev -- <command>
# This is equivalent to:
LOBEHUB_CLI_HOME=.lobehub-dev bun src/index.ts <command>
To test CLI against a local dev server (e.g. localhost:3011):
Step 1: Start the local server
# From cloud repo root
bun run dev
# Server starts on http://localhost:3011 (or configured port)
Step 2: Login to local server via Device Code Flow
cd apps/cli && bun run dev -- login --server http://localhost:3011
This will:
POST http://localhost:3011/oidc/device/auth to get a device codehttp://localhost:3011/oidc/device?user_code=XXXX-YYYYapps/cli/.lobehub-dev/credentials.jsonapps/cli/.lobehub-dev/settings.jsonAfter login, all subsequent bun run dev -- <command> calls will use the local server.
Step 3: Run commands against local server
cd apps/cli && bun run dev -- task list
cd apps/cli && bun run dev -- task create -i "Test task" -n "My Task"
cd apps/cli && bun run dev -- agent list
Troubleshooting:
invalid_grant, make sure the local OIDC provider is properly configured (check OIDC_* env vars in .env)UNAUTHORIZED on API calls, your token may have expired — run bun run dev -- login --server http://localhost:3011 againapps/cli/.lobehub-dev/ (gitignored), not in ~/.lobehub/# Dev mode (local server) — uses .lobehub-dev/
cd apps/cli && bun run dev -- <command>
# Production (app.lobehub.com) — uses ~/.lobehub/
lh <command>
The two environments are completely isolated by different credential directories.
# Build CLI
cd apps/cli && bun run build
# Unit tests
cd apps/cli && bun run test
# E2E tests (requires authenticated CLI)
cd apps/cli && bunx vitest run e2e/kb.e2e.test.ts
# Link globally for testing (installs lh/lobe/lobehub commands)
cd apps/cli && bun run cli:link
See references/ for each command group:
references/agent.md (CRUD, run, status)references/goal.md (planning turn, state, events, lifecycle, decisions)references/generate.md (text, image, video, tts, asr, download)references/knowledge.md (kb, file, doc)references/conversation.md (topic, message)references/memory.md (memory management, extraction)references/skills-plugins.md (skill, plugin)references/models-providers.md (model, provider)references/search-config.md (search, whoami, usage, workspace)还没有评价。欢迎分享你的使用感受。
无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。
还没有评论。来写第一条吧。
通过实际操作产品验证交付内容,记录用户可查看的证据,并发布验收报告。可检查已有验证计划或创建检查项,选择合适的操作界面,并使用 `lh` CLI 发布结果。
本技能指导在 LobeHub 中接入 AI 模型提供商,涵盖运行时、模型信息、设置、品牌展示、文档和验收,并帮助判断新增模型是否需要新的提供商集成。
本技能指导如何用服务器端环境变量设置用户偏好默认值,涵盖变量校验、服务器配置、写入用户状态,以及更新 `.env.example` 和自托管文档。
说明如何在智能体执行步骤、工具调用、人工审批、上下文压缩和子智能体调用时注册钩子。钩子可观察事件、模拟本地工具结果,也可通过 Webhook 按配置策略允许或拒绝工具调用。
此技能用于为智能体设计事件驱动的后台工作流,划分来源、信号、动作和策略的职责,并处理异步交接、去重、执行范围、完成记录与运行观测。
本技能在 macOS 桌面聊天应用中测试机器人频道:打开应用、进入频道或联系人、发送消息、等待回复并截图。支持 Discord、Slack、Telegram、微信、飞书和 QQ;iMessage 使用 BlueBubbles 桥接。