@lobehub/cli 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +79 -12
- package/man/man1/lh.1 +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -28140,15 +28140,73 @@ function registerMessageCommand(program) {
|
|
|
28140
28140
|
//#region src/commands/migrate/openclaw.ts
|
|
28141
28141
|
const EXCLUDED_NAMES = new Set([
|
|
28142
28142
|
".idea",
|
|
28143
|
+
".vscode",
|
|
28144
|
+
".fleet",
|
|
28145
|
+
".cursor",
|
|
28146
|
+
".zed",
|
|
28147
|
+
".git",
|
|
28148
|
+
".svn",
|
|
28149
|
+
".hg",
|
|
28143
28150
|
".DS_Store",
|
|
28151
|
+
"Thumbs.db",
|
|
28152
|
+
"desktop.ini",
|
|
28144
28153
|
".openclaw",
|
|
28145
28154
|
"node_modules",
|
|
28146
|
-
".
|
|
28147
|
-
"
|
|
28155
|
+
".pnp",
|
|
28156
|
+
"bower_components",
|
|
28157
|
+
"vendor",
|
|
28158
|
+
".venv",
|
|
28159
|
+
"venv",
|
|
28148
28160
|
"__pycache__",
|
|
28149
|
-
".
|
|
28161
|
+
".mypy_cache",
|
|
28162
|
+
".ruff_cache",
|
|
28163
|
+
".pytest_cache",
|
|
28164
|
+
".tox",
|
|
28165
|
+
".eggs",
|
|
28166
|
+
"*.egg-info",
|
|
28167
|
+
".cache",
|
|
28168
|
+
".parcel-cache",
|
|
28169
|
+
".next",
|
|
28170
|
+
".nuxt",
|
|
28171
|
+
".turbo",
|
|
28172
|
+
"dist",
|
|
28173
|
+
"build",
|
|
28174
|
+
"out",
|
|
28175
|
+
".output",
|
|
28176
|
+
".env",
|
|
28177
|
+
".env.local",
|
|
28178
|
+
"coverage",
|
|
28179
|
+
".nyc_output",
|
|
28180
|
+
".terraform",
|
|
28181
|
+
".sass-cache",
|
|
28182
|
+
"tmp",
|
|
28183
|
+
".tmp"
|
|
28150
28184
|
]);
|
|
28151
|
-
const
|
|
28185
|
+
const DEFAULT_AGENT_NAME = "OpenClaw";
|
|
28186
|
+
const IDENTITY_FILES = ["IDENTITY.md", "SOUL.md"];
|
|
28187
|
+
/**
|
|
28188
|
+
* Try to extract the agent name, description, and avatar emoji from
|
|
28189
|
+
* IDENTITY.md or SOUL.md. Falls back to "OpenClaw" if neither file
|
|
28190
|
+
* exists or parsing fails.
|
|
28191
|
+
*/
|
|
28192
|
+
function readAgentProfile(workspacePath) {
|
|
28193
|
+
for (const filename of IDENTITY_FILES) {
|
|
28194
|
+
const filePath = path.join(workspacePath, filename);
|
|
28195
|
+
if (!fs.existsSync(filePath)) continue;
|
|
28196
|
+
const content = fs.readFileSync(filePath, "utf8");
|
|
28197
|
+
const nameMatch = content.match(/\*{0,2}Name:?\*{0,2}\s*(.+)/i);
|
|
28198
|
+
const title = nameMatch ? nameMatch[1].trim() : DEFAULT_AGENT_NAME;
|
|
28199
|
+
const descMatch = content.match(/\*{0,2}(?:Creature|Vibe|Description):?\*{0,2}\s*(.+)/i);
|
|
28200
|
+
const description = descMatch ? descMatch[1].trim() : void 0;
|
|
28201
|
+
const emojiMatch = content.match(/\*{0,2}Emoji:?\*{0,2}\s*(.+)/i);
|
|
28202
|
+
return {
|
|
28203
|
+
avatar: emojiMatch ? emojiMatch[1].trim() : void 0,
|
|
28204
|
+
description,
|
|
28205
|
+
title
|
|
28206
|
+
};
|
|
28207
|
+
}
|
|
28208
|
+
return { title: DEFAULT_AGENT_NAME };
|
|
28209
|
+
}
|
|
28152
28210
|
/**
|
|
28153
28211
|
* Recursively collect all files under `dir`, skipping excluded directories/files.
|
|
28154
28212
|
* Returns paths relative to `baseDir`.
|
|
@@ -28165,9 +28223,9 @@ function collectFiles(dir, baseDir) {
|
|
|
28165
28223
|
}
|
|
28166
28224
|
/**
|
|
28167
28225
|
* Resolve the target agent ID.
|
|
28168
|
-
* Priority: --agent-id > --slug > create new
|
|
28226
|
+
* Priority: --agent-id > --slug > create new agent from workspace profile.
|
|
28169
28227
|
*/
|
|
28170
|
-
async function resolveAgentId(client, opts) {
|
|
28228
|
+
async function resolveAgentId(client, opts, profile) {
|
|
28171
28229
|
if (opts.agentId) return opts.agentId;
|
|
28172
28230
|
if (opts.slug) {
|
|
28173
28231
|
const agent = await client.agent.getBuiltinAgent.query({ slug: opts.slug });
|
|
@@ -28177,17 +28235,23 @@ async function resolveAgentId(client, opts) {
|
|
|
28177
28235
|
}
|
|
28178
28236
|
return agent.id;
|
|
28179
28237
|
}
|
|
28180
|
-
log$1.info(`Creating new agent "${
|
|
28181
|
-
const id = (await client.agent.createAgent.mutate({ config: {
|
|
28238
|
+
log$1.info(`Creating new agent "${profile.title}"...`);
|
|
28239
|
+
const id = (await client.agent.createAgent.mutate({ config: {
|
|
28240
|
+
avatar: profile.avatar,
|
|
28241
|
+
description: profile.description,
|
|
28242
|
+
title: profile.title
|
|
28243
|
+
} })).agentId;
|
|
28182
28244
|
if (!id) {
|
|
28183
28245
|
log$1.error("Failed to create agent — no agentId returned.");
|
|
28184
28246
|
process.exit(1);
|
|
28185
28247
|
}
|
|
28186
|
-
|
|
28248
|
+
const label = profile.avatar ? `${profile.avatar} ${profile.title}` : profile.title;
|
|
28249
|
+
console.log(`${import_picocolors.default.green("✓")} Agent created: ${import_picocolors.default.bold(label)}`);
|
|
28187
28250
|
return id;
|
|
28188
28251
|
}
|
|
28189
28252
|
function registerOpenClawMigration(migrate) {
|
|
28190
28253
|
migrate.command("openclaw").description("Import OpenClaw workspace files as agent documents into a new \"OpenClaw\" agent").option("--source <path>", "Path to OpenClaw workspace", path.join(process.env.HOME || "~", ".openclaw", "workspace")).option("--agent-id <id>", "Import into an existing agent by ID").option("--slug <slug>", "Import into an existing agent by slug (e.g. \"inbox\")").option("--dry-run", "Preview files without importing").option("--yes", "Skip confirmation prompt").action(async (options) => {
|
|
28254
|
+
if (!options.dryRun) await getTrpcClient();
|
|
28191
28255
|
const workspacePath = path.resolve(options.source);
|
|
28192
28256
|
if (!fs.existsSync(workspacePath)) {
|
|
28193
28257
|
log$1.error(`OpenClaw workspace not found: ${workspacePath}`);
|
|
@@ -28197,6 +28261,7 @@ function registerOpenClawMigration(migrate) {
|
|
|
28197
28261
|
log$1.error(`Not a directory: ${workspacePath}`);
|
|
28198
28262
|
process.exit(1);
|
|
28199
28263
|
}
|
|
28264
|
+
const profile = readAgentProfile(workspacePath);
|
|
28200
28265
|
const files = collectFiles(workspacePath, workspacePath);
|
|
28201
28266
|
if (files.length === 0) {
|
|
28202
28267
|
log$1.info("No files found in workspace.");
|
|
@@ -28210,15 +28275,17 @@ function registerOpenClawMigration(migrate) {
|
|
|
28210
28275
|
return;
|
|
28211
28276
|
}
|
|
28212
28277
|
if (!options.yes) {
|
|
28213
|
-
const
|
|
28278
|
+
const agentLabel = profile.avatar ? `${profile.avatar} ${profile.title}` : profile.title;
|
|
28279
|
+
const target = options.agentId ? `agent ${import_picocolors.default.bold(options.agentId)}` : options.slug ? `agent slug "${import_picocolors.default.bold(options.slug)}"` : `a new ${import_picocolors.default.bold(agentLabel)} agent`;
|
|
28214
28280
|
if (!await confirm(`Import ${files.length} file(s) as agent documents into ${target}?`)) {
|
|
28215
28281
|
console.log("Cancelled.");
|
|
28216
28282
|
return;
|
|
28217
28283
|
}
|
|
28218
28284
|
}
|
|
28219
28285
|
const client = await getTrpcClient();
|
|
28220
|
-
const agentId = await resolveAgentId(client, options);
|
|
28221
|
-
|
|
28286
|
+
const agentId = await resolveAgentId(client, options, profile);
|
|
28287
|
+
const displayName = profile.avatar ? `${profile.avatar} ${profile.title}` : profile.title;
|
|
28288
|
+
console.log(`\nImporting to ${import_picocolors.default.bold(displayName)}...\n`);
|
|
28222
28289
|
let success = 0;
|
|
28223
28290
|
let failed = 0;
|
|
28224
28291
|
for (const relativePath of files) {
|
package/man/man1/lh.1
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
.\" Code generated by `npm run man:generate`; DO NOT EDIT.
|
|
2
2
|
.\" Manual command details come from the Commander command tree.
|
|
3
|
-
.TH LH 1 "" "@lobehub/cli 0.0.
|
|
3
|
+
.TH LH 1 "" "@lobehub/cli 0.0.2" "User Commands"
|
|
4
4
|
.SH NAME
|
|
5
5
|
lh \- LobeHub CLI \- manage and connect to LobeHub services
|
|
6
6
|
.SH SYNOPSIS
|