Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

🔖 chore(cli): sync 0.0.77 and automate npm releases (#22792)

Rdmclin25a9dcc6da1ab
diff --git a/.github/workflows/release-cli.yml b/.github/workflows/release-cli.yml
new file mode 100644
index 00000000000..74de9f5b640
--- /dev/null
+++ b/.github/workflows/release-cli.yml
@@ -0,0 +1,117 @@
+name: Release CLI
+
+permissions:
+ contents: read
+ id-token: write
+
+on:
+ push:
+ branches:
+ - canary
+ paths:
+ - apps/cli/package.json
+ - .github/workflows/release-cli.yml
+ workflow_dispatch: {}
+
+# Never interrupt a publish or let two runs publish the same version concurrently.
+concurrency:
+ group: release-cli
+ cancel-in-progress: false
+
+jobs:
+ publish:
+ name: Publish CLI
+ if: github.repository == 'lobehub/lobehub' && github.ref == 'refs/heads/canary'
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v7
+
+ - name: Check release version
+ id: release
+ run: |
+ node --input-type=module <<'NODE'
+ import { appendFile, readFile } from 'node:fs/promises';
+
+ const { name, version } = JSON.parse(await readFile('apps/cli/package.json', 'utf8'));
+ if (!/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/.test(version)) {
+ throw new Error(`Only stable versions can be published to latest: ${version}`);
+ }
+ const response = await fetch(`https://registry.npmjs.org/${encodeURIComponent(name)}`, {
+ signal: AbortSignal.timeout(30_000),
+ });
+ if (!response.ok) throw new Error(`Registry lookup failed: HTTP ${response.status}`);
+ const metadata = await response.json();
+ if (!metadata.versions || !metadata['dist-tags']?.latest) {
+ throw new Error('Registry response is missing versions or latest');
+ }
+ if (Object.hasOwn(metadata.versions, version)) {
+ console.log(`${name}@${version} is already published; skipping.`);
+ await appendFile(process.env.GITHUB_OUTPUT, 'publish=false\n');
+ } else {
+ const latest = metadata['dist-tags'].latest;
+ if (!/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/.test(latest)) {
+ throw new Error(`Unexpected latest version: ${latest}`);
+ }
+ const currentParts = version.split('.').map(BigInt);
+ const latestParts = latest.split('.').map(BigInt);
+ const firstDifference = currentParts.findIndex((part, i) => part !== latestParts[i]);
+ if (firstDifference < 0 || currentParts[firstDifference] < latestParts[firstDifference]) {
+ throw new Error(`${version} must be newer than latest (${latest})`);
+ }
+ await appendFile(process.env.GITHUB_OUTPUT, 'publish=true\n');
+ console.log(`Publishing ${name}@${version}`);
+ }
+ NODE
+
+ - name: Setup environment
+ if: steps.release.outputs.publish == 'true'
+ uses: ./.github/actions/setup-env
+
+ - name: Configure npm registry
+ if: steps.release.outputs.publish == 'true'
+ uses: actions/setup-node@v6
+ with:
+ node-version: 24.16.0
+ registry-url: https://registry.npmjs.org
+
+ - name: Install dependencies
+ if: steps.release.outputs.publish == 'true'
+ run: pnpm install
+
+ - name: Install CLI workspace dependencies
+ if: steps.release.outputs.publish == 'true'
+ run: pnpm install
+ working-directory: apps/cli
+
+ - name: Test CLI bundle and model-facing docs
+ if: steps.release.outputs.publish == 'true'
+ run: bunx vitest run --config vitest.config.mts --silent='passed-only' tsdown.config.test.ts bundle.test.ts src/modelFacingDocs.test.ts
+ working-directory: apps/cli
+
+ - name: Build publishable CLI bundle
+ if: steps.release.outputs.publish == 'true'
+ run: npm run prepublishOnly
+ working-directory: apps/cli
+
+ - name: Smoke check
+ if: steps.release.outputs.publish == 'true'
+ run: |
+ node dist/index.js --version
+ node dist/index.js --help
+ test -s dist/maintenanceWorker.mjs
+ test -s dist/acceptance-report.html
+ test -s man/man1/lh.1
+ working-directory: apps/cli
+
+ # Publish exactly the bundle checked above, without rebuilding in lifecycle hooks.
+ - name: Pack CLI
+ if: steps.release.outputs.publish == 'true'
+ run: npm pack --ignore-scripts
+ working-directory: apps/cli
+
+ - name: Publish to npm
+ if: steps.release.outputs.publish == 'true'
+ run: npm publish ./lobehub-cli-*.tgz --provenance --access public --tag latest
+ working-directory: apps/cli
+ env:
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
diff --git a/apps/cli/README.md b/apps/cli/README.md
index 296adacfe98..53ff87ab4b3 100644
--- a/apps/cli/README.md
+++ b/apps/cli/README.md
@@ -2,6 +2,31 @@
LobeHub command-line interface.
+## Release to npm
+
+The `Release CLI` GitHub Actions workflow publishes stable versions to npm's
+`latest` tag from `canary`. To release, bump `apps/cli/package.json` in a PR:
+
+```bash
+cd apps/cli
+npm version patch --no-git-tag-version
+bun run man:generate
+```
+
+Commit the version and generated manual, complete the checks and any product
+acceptance required by the change, then merge the PR into `canary`. CI checks
+the registry, tests the CLI bundle, runs the complete `prepublishOnly` build
+(including the offline report), smoke-checks it, and publishes with provenance.
+The workflow can also be dispatched manually on `canary` to retry a failed run.
+Already published versions are skipped; prereleases and versions older than
+`latest` are rejected. Registry errors stop the run instead of assuming a
+version is unpublished. CI does not change versions or commit back to the repo.
+
+Publishing uses the repository's `NPM_TOKEN` secret, as the SDK release does.
+It must have publish permission for `@lobehub/cli` and support unattended
+publishing under the package's npm authentication policy. PR previews continue
+to publish separately to `pkg.pr.new`.
+
## Update a connected device
```bash
diff --git a/apps/cli/man/man1/lh.1 b/apps/cli/man/man1/lh.1
index 8d9fc6b305c..1ca6ef311db 100644
--- a/apps/cli/man/man1/lh.1
+++ b/apps/cli/man/man1/lh.1
@@ -1,6 +1,6 @@
.\" Code generated by `npm run man:generate`; DO NOT EDIT.
.\" Manual command details come from the Commander command tree.
-.TH LH 1 "" "@lobehub/cli 0.0.76" "User Commands"
+.TH LH 1 "" "@lobehub/cli 0.0.77" "User Commands"
.SH NAME
lh \- LobeHub CLI \- manage and connect to LobeHub services
.SH SYNOPSIS
@@ -71,6 +71,9 @@ Recall what happened around a topic: matching messages, conversations, goals and
.B kb
Manage knowledge bases, folders, documents, and files
.TP
+.B meeting
+Read recorded meetings
+.TP
.B memory
Manage user memories
.TP
@@ -146,11 +149,11 @@ Manage dashboards (boards of monitoring widgets)
.B widget
Build monitoring widgets: sandboxed scripts rendered as dashboard cards
.TP
-.B plugin
-Manage plugins
+.B legacy\-plugin
+Manage legacy 1.0 plugins (user_installed_plugins) Alias: plugin.
.TP
.B connector
-Manage MCP connectors (user connectors and their synced tools)
+Manage MCP connectors (user connectors and their synced tools) Alias: mcp.
.TP
.B workspace
Manage workspaces and the workspace scope commands run under Alias: ws.
diff --git a/apps/cli/package.json b/apps/cli/package.json
index 7439acdcf15..939b1619514 100644
--- a/apps/cli/package.json
+++ b/apps/cli/package.json
@@ -1,6 +1,11 @@
{
"name": "@lobehub/cli",
- "version": "0.0.76",
+ "version": "0.0.77",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/lobehub/lobehub",
+ "directory": "apps/cli"
+ },
"type": "module",
"bin": {
"lh": "dist/index.js",