本文へ移動
cccskills
無料GitHub で公開日本語紹介

cli

LobeHub CLIのコマンド構成や認証、出力、開発手順を把握し、新しいコマンドやサブコマンドを追加・保守するためのガイドです。

原文原文の説明を見る

LobeHub CLI (@lobehub/cli) development guide — commands, subcommands, architecture.

lobehub/lobehubスター 83,500(GitHub 83,500 + cccskills 0)

実行スコア 未検証

インストール方法を見る

こんなときに便利

  • CLIにコマンドを追加したいとき
  • 認証やワークスペースの仕組みを調べたいとき
  • テーブル・JSON出力を実装したいとき
  • ローカルサーバーでCLIを試したいとき

日本語での紹介

できること

LobeHub CLI(@lobehub/cli)の構成やコマンドの登録方法を確認し、新しいコマンドを追加・保守する際の手引きとして使えます。ログイン、エージェント、タスク、ファイル、ナレッジベース、モデル、スキルなど、コマンド群の役割が一覧になっています。コマンドファイルの作成からエントリーポイントへの登録、テーブルやJSONでの出力、認証トークンの取得、確認プロンプトの扱いまで、実装例を交えて説明します。ワークスペースの選択規則や設定ファイルの保存場所、ローカル開発サーバーに接続して動作させる手順も参照できます。

こんなときに便利

既存CLIのどこに機能を追加すればよいか調べたい開発者や、コマンド間の出力・認証の作法を揃えたいときに向いています。ローカル環境と本番環境の設定を分けて開発したい場合にも、記載された実行例を確認できます。

使い方の例

  • 「このCLIに新しいサブコマンドを追加する手順を教えて」
  • 「一覧コマンドのJSON出力を既存の形式に合わせて」
  • 「開発用サーバーに接続してコマンドを試す方法を整理して」

注意点

CLIはNode.jsまたはBunで動作します。ローカル開発サーバーを使う手順には、サーバーの起動と認証が含まれます。

この紹介文は、公開されている SKILL.md をもとに AI(OpenAI Codex)が作成しました。正確な仕様は下の原文を確認してください。

資料チェック

SKILL.md の記述から、注意が要る操作と導入の前提を AI が確認しました。点数は実際に動かした結果(実行検証)だけで付けています。

安全面送信・削除・コマンド実行などの扱いが明示されているか
B一部不足認証情報の取得・保存やサーバー接続を扱うが、操作前の確認範囲は抜粋で不明。
導入のしやすさ必要なツールや API キーが少ないか、書かれているか
B一部不足Node.jsまたはBunが必要で、ローカルサーバーの起動と認証も必要と記載される。

点数には入れていません。 2026年10月26日 時点で AI(OpenAI Codex)が判定しました。目安なので、入れる前に原文も確認してください。

評価が違うと思ったら、見直しを依頼する

どの項目が、なぜ違うと思うかを書いてください。ログインは不要です。内容を SKILL.md と照らし合わせて評価を作り直し、この欄に反映します。

このフォームは reCAPTCHA で保護されており、Google のプライバシーポリシーと利用規約が適用されます。

含まれるファイル(11)

  • SKILL.md17.0 KB
  • agents/openai.yaml43 B
  • references/agent.md9.0 KB
  • references/conversation.md4.1 KB
  • references/generate.md14.1 KB
  • references/goal.md9.4 KB
  • references/knowledge.md8.0 KB
  • references/memory.md3.5 KB
  • references/models-providers.md5.7 KB
  • references/search-config.md7.7 KB
  • references/skills-plugins.md3.7 KB

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

LobeHub CLI Development Guide

Overview

LobeHub CLI (@lobehub/cli) is a command-line tool for managing and interacting with LobeHub services. Built with Commander.js + TypeScript.

  • Package: apps/cli/
  • Entry: apps/cli/src/index.ts
  • Binaries: lh, lobe, lobehub (all aliases for the same CLI)
  • Build: tsup
  • Runtime: Node.js / Bun

Architecture

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 Groups

CommandAliasDescription
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 generategenContent 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 workspacewsWorkspace 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

Workspace Scope

Every command runs against one scope, resolved in this order:

  1. an explicit --workspace <id> on the commands that take it
  2. the LOBEHUB_WORKSPACE_ID env var
  3. the scope persisted by lh workspace use <id|slug>
  4. personal content (no workspace)

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.

Adding a New Command

1. Create Command File

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
    });
}

2. Register in Entry Point

In apps/cli/src/index.ts:

import { registerNewCommand } from './commands/new';
// ...
registerNewCommand(program);

3. Add Tests

Create apps/cli/src/commands/<name>.test.ts alongside the command file.

Conventions

Output Patterns

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 logging

Table Output

const rows = items.map((item) => [item.id, truncate(item.title, 40), timeAgo(item.updatedAt)]);
printTable(rows, ['ID', 'TITLE', 'UPDATED']);

JSON Output

if (options.json !== undefined) {
  const fields = typeof options.json === 'string' ? options.json : undefined;
  outputJson(items, fields);
  return;
}

Authentication

Commands that need auth use getTrpcClient() which auto-resolves tokens:

const client = await getTrpcClient();
// client.router.procedure.query/mutate(...)

Confirmation Prompts

import { confirm } from '../utils/format';
if (!options.yes) {
  const ok = await confirm('Are you sure?');
  if (!ok) return;
}

Storage Locations

FilePathPurpose
Credentials~/.lobehub/credentials.jsonEncrypted tokens (AES-256-GCM)
Settings~/.lobehub/settings.jsonCustom server/gateway URLs
Workspace~/.lobehub/active-workspaceActive scope + the account/server it is bound to
Daemon PID~/.lobehub/daemon.pidBackground process PID
Daemon Status~/.lobehub/daemon.status.jsonConnection status JSON
Daemon Log~/.lobehub/daemon.logDaemon 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).

Key Dependencies

  • 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 execution
  • picocolors - Terminal colors
  • ws - WebSocket
  • diff - Text diffing
  • fast-glob - File pattern matching

Development

Running in Dev Mode

Dev 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>

Connecting to Local Dev Server

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:

  1. Call POST http://localhost:3011/oidc/device/auth to get a device code
  2. Print a URL like http://localhost:3011/oidc/device?user_code=XXXX-YYYY
  3. Open the URL in your browser — log in and authorize
  4. Save credentials to apps/cli/.lobehub-dev/credentials.json
  5. Save server URL to apps/cli/.lobehub-dev/settings.json

After 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:

  • If login returns invalid_grant, make sure the local OIDC provider is properly configured (check OIDC_* env vars in .env)
  • If you get UNAUTHORIZED on API calls, your token may have expired — run bun run dev -- login --server http://localhost:3011 again
  • Dev credentials are stored in apps/cli/.lobehub-dev/ (gitignored), not in ~/.lobehub/

Switching Between Local and Production

# 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 & Test

# 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

Detailed Command References

See references/ for each command group:

  • Agent: references/agent.md (CRUD, run, status)
  • Goals: references/goal.md (planning turn, state, events, lifecycle, decisions)
  • Content Generation: references/generate.md (text, image, video, tts, asr, download)
  • Knowledge & Files: references/knowledge.md (kb, file, doc)
  • Conversation: references/conversation.md (topic, message)
  • Memory: references/memory.md (memory management, extraction)
  • Skills & Plugins: references/skills-plugins.md (skill, plugin)
  • Models & Providers: references/models-providers.md (model, provider)
  • Search & Config: references/search-config.md (search, whoami, usage, workspace)

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

コメント

ログインなしで書き込めます。使ってみた感想、質問、動かなかった環境などを気軽にどうぞ。

まだコメントはありません。最初のコメントを書いてみませんか。

送信するとすぐに公開されます。メールアドレスや電話番号などの個人情報は書かないでください。URL は 2 つまでです。

0 / 1000 文字

このフォームは reCAPTCHA で保護されており、Google のプライバシーポリシーと利用規約が適用されます。

同じリポジトリのスキル

acceptance

無料概要あり

実際の製品を操作して、利用者が確認できる動作証拠を集め、検証計画に沿った受け入れレポートとして公開するスキルです。

  • 変更後の製品動作を実地で検証したいとき
  • 画面キャプチャなどの証拠を集めたいとき
  • 検証計画とレポートを作成したいとき
lobehub/lobehub8.4万2026年10月26日 更新

add-model-provider

無料概要あり

LobeHubにAIモデルプロバイダーを追加し、実行時連携からモデル表示、設定、ブランド表記、文書化、動作確認まで進めるスキルです。

  • 新しいAIモデルプロバイダーを追加したいとき
  • プロバイダーの設定手順や説明文を更新したいとき
  • 既存プロバイダーへのモデル追加要件を見極めたいとき
lobehub/lobehub8.4万2026年10月26日 更新

add-setting-env

無料概要あり

ユーザー設定の初期値をサーバー側の環境変数で切り替えるため、型定義や設定の組み立て、ユーザーストアへの反映、環境変数の例と説明書きを追加する手順です。

  • 設定の初期値を環境変数で変えたいとき
  • 設定項目をサーバー設定に追加したいとき
  • 環境変数の例と説明を更新したいとき
lobehub/lobehub8.4万2026年10月26日 更新

agent-runtime-hooks

無料概要あり

エージェント実行中の各段階をフックで監視し、ツール呼び出しの模擬・制御や人の承認、圧縮、サブエージェント処理に介入する仕組みを扱います。

  • エージェントの実行状況を記録したいとき
  • ツール結果をテスト用に模擬したいとき
  • Webhookでツール実行を許可・拒否したいとき
lobehub/lobehub8.4万2026年10月26日 更新

agent-signal

無料概要あり

イベントを起点にエージェントのバックグラウンド処理を組み立て、ソース・シグナル・アクション・ポリシーの役割分担や非同期連携を実装するためのスキルです。

  • イベント起点の処理を追加したいとき
  • バックグラウンド処理を非同期化したいとき
  • 重複実行を防ぐ仕組みを整えたいとき
lobehub/lobehub8.4万2026年10月26日 更新

agent-testing-bot

無料概要あり

DiscordやSlackなどの実際のチャットアプリでボットにメッセージを送り、応答を画面で確認する受け入れテストを行うスキルです。

  • 実際のDiscordでボット応答を確かめたいとき
  • SlackやTelegramの会話経路をテストしたいとき
  • macOSアプリ上の操作結果を画面で記録したいとき
lobehub/lobehub8.4万2026年10月26日 更新

lobehub のスキルをすべて見る

このスキルの問題を報告する