@elizaos/cli 1.0.6 → 1.0.8

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.
Files changed (88) hide show
  1. package/README.md +12 -11
  2. package/dist/assets/{index-BlgsVC9v.js → index-CZAd5zm2.js} +17 -17
  3. package/dist/assets/index-CZAd5zm2.js.br +0 -0
  4. package/dist/assets/{index-BlgsVC9v.js.map → index-CZAd5zm2.js.map} +1 -1
  5. package/dist/assets/{index-TLtd8ntA.js → index-CaEsCLCC.js} +4155 -10851
  6. package/dist/assets/{index-TLtd8ntA.js.map → index-CaEsCLCC.js.map} +1 -1
  7. package/dist/assets/index-DyA-lndn.css +1 -0
  8. package/dist/assets/index-DyA-lndn.css.br +0 -0
  9. package/dist/assets/{vendor-BiCY-iVm.js → vendor-DSdxb8P-.js} +2 -2
  10. package/dist/assets/vendor-DSdxb8P-.js.br +0 -0
  11. package/dist/assets/{vendor-BiCY-iVm.js.map → vendor-DSdxb8P-.js.map} +1 -1
  12. package/dist/chunk-33BHGAF7.js +616 -0
  13. package/dist/{chunk-YTV6GDEJ.js → chunk-CVADLFW6.js} +100 -42
  14. package/dist/chunk-F24MS2YR.js +19 -0
  15. package/dist/{chunk-7HDCC22V.js → chunk-IEKLJDUU.js} +99 -0
  16. package/dist/chunk-MA2ZXPG6.js +260 -0
  17. package/dist/chunk-REBZFQYE.js +11728 -0
  18. package/dist/chunk-W3HS2NP6.js +154 -0
  19. package/dist/commands/agent/actions/index.d.ts +25 -0
  20. package/dist/commands/agent/actions/index.js +23 -0
  21. package/dist/commands/agent/index.d.ts +16 -0
  22. package/dist/commands/agent/index.js +24 -0
  23. package/dist/commands/create/actions/index.d.ts +35 -0
  24. package/dist/commands/create/actions/index.js +30 -0
  25. package/dist/commands/create/index.d.ts +5 -0
  26. package/dist/commands/create/index.js +17 -0
  27. package/dist/commands/shared/index.d.ts +35 -0
  28. package/dist/commands/shared/index.js +13 -0
  29. package/dist/index.html +3 -3
  30. package/dist/index.js +103836 -56
  31. package/dist/{prompts-I4LK5NKX.js → lib-NAGYZHVV.js} +3 -3
  32. package/dist/{migrator-BQMHMHSG.js → migrator-KZLCVEIH.js} +117 -117
  33. package/dist/{plugin-creator-EUJNDFIB.js → plugin-creator-IC42XOHG.js} +3 -4
  34. package/dist/{registry-A4UYBEET.js → registry-XFOSZFU4.js} +4 -5
  35. package/dist/utils-DIZZ3HNZ.js +218 -0
  36. package/package.json +19 -12
  37. package/templates/plugin-starter/README.md +26 -9
  38. package/templates/plugin-starter/package.json +6 -2
  39. package/templates/plugin-starter/tsconfig.build.json +1 -3
  40. package/templates/plugin-starter/tsconfig.json +1 -2
  41. package/templates/plugin-starter/tsup.config.ts +1 -1
  42. package/templates/project-starter/README.md +15 -16
  43. package/templates/project-starter/package.json +6 -6
  44. package/templates/project-tee-starter/e2e/project.test.ts +1 -1
  45. package/templates/project-tee-starter/e2e/starter-plugin.test.ts +1 -1
  46. package/templates/project-tee-starter/package.json +6 -5
  47. package/dist/assets/index-BlgsVC9v.js.br +0 -0
  48. package/dist/assets/index-fZleA996.css +0 -1
  49. package/dist/assets/index-fZleA996.css.br +0 -0
  50. package/dist/assets/vendor-BiCY-iVm.js.br +0 -0
  51. package/dist/chunk-335PGADS.js +0 -207
  52. package/dist/chunk-4QRJ6FQC.js +0 -295
  53. package/dist/chunk-5J7S2CSH.js +0 -2771
  54. package/dist/chunk-APFJCFC6.js +0 -78
  55. package/dist/chunk-CR5NR6A6.js +0 -458
  56. package/dist/chunk-KB3JDWUI.js +0 -106
  57. package/dist/chunk-L64NPCT6.js +0 -604
  58. package/dist/chunk-LRSU7IN6.js +0 -4862
  59. package/dist/chunk-LXYNBPDV.js +0 -570
  60. package/dist/chunk-MAGJ4VCL.js +0 -95
  61. package/dist/chunk-O64SGQGU.js +0 -90048
  62. package/dist/chunk-PHLX32YJ.js +0 -7889
  63. package/dist/chunk-RGI5263U.js +0 -7443
  64. package/dist/chunk-VWWF4TGX.js +0 -684
  65. package/dist/chunk-YMKISDXM.js +0 -247
  66. package/dist/commands/agent.d.ts +0 -27
  67. package/dist/commands/agent.js +0 -22
  68. package/dist/commands/create.d.ts +0 -15
  69. package/dist/commands/create.js +0 -18
  70. package/dist/commands/dev.d.ts +0 -8
  71. package/dist/commands/dev.js +0 -17
  72. package/dist/commands/env.d.ts +0 -16
  73. package/dist/commands/env.js +0 -21
  74. package/dist/commands/plugins.d.ts +0 -19
  75. package/dist/commands/plugins.js +0 -25
  76. package/dist/commands/publish.d.ts +0 -5
  77. package/dist/commands/publish.js +0 -18
  78. package/dist/commands/setup-monorepo.d.ts +0 -5
  79. package/dist/commands/setup-monorepo.js +0 -17
  80. package/dist/commands/start.d.ts +0 -198
  81. package/dist/commands/start.js +0 -25
  82. package/dist/commands/tee.d.ts +0 -5
  83. package/dist/commands/tee.js +0 -13
  84. package/dist/commands/test.d.ts +0 -6
  85. package/dist/commands/test.js +0 -24
  86. package/dist/commands/update.d.ts +0 -14
  87. package/dist/commands/update.js +0 -23
  88. package/dist/{chunk-NHI4RJD2.js → chunk-CEE6RKN5.js} +58 -58
@@ -1,604 +0,0 @@
1
-
2
- import { createRequire } from 'module';
3
- const require = createRequire(import.meta.url);
4
-
5
- import {
6
- performCliUpdate
7
- } from "./chunk-4QRJ6FQC.js";
8
- import {
9
- REGISTRY_GITHUB_URL,
10
- detectDirectoryType,
11
- displayBanner,
12
- getDirectoryTypeDescription,
13
- getGitHubCredentials,
14
- getRegistrySettings,
15
- handleError,
16
- initializeDataDir,
17
- publishToGitHub,
18
- saveRegistrySettings,
19
- testPublishToGitHub,
20
- testPublishToNpm,
21
- validateDataDir
22
- } from "./chunk-RGI5263U.js";
23
- import {
24
- Command
25
- } from "./chunk-5J7S2CSH.js";
26
- import {
27
- require_prompts
28
- } from "./chunk-LRSU7IN6.js";
29
- import {
30
- __toESM
31
- } from "./chunk-567UPUC7.js";
32
-
33
- // src/commands/publish.ts
34
- var import_prompts = __toESM(require_prompts(), 1);
35
- import { execa } from "execa";
36
- import { promises as fs } from "node:fs";
37
- import path from "node:path";
38
- import { fileURLToPath } from "node:url";
39
- var REGISTRY_PACKAGES_PATH = "packages";
40
- var LOCAL_REGISTRY_PATH = "packages/registry";
41
- async function checkCliVersion() {
42
- try {
43
- const cliPackageJsonPath = path.resolve(
44
- path.dirname(fileURLToPath(import.meta.url)),
45
- "../package.json"
46
- );
47
- const cliPackageJsonContent = await fs.readFile(cliPackageJsonPath, "utf-8");
48
- const cliPackageJson = JSON.parse(cliPackageJsonContent);
49
- const currentVersion = cliPackageJson.version || "0.0.0";
50
- const { stdout } = await execa("npm", ["view", "@elizaos/cli", "time", "--json"]);
51
- const timeData = JSON.parse(stdout);
52
- delete timeData.created;
53
- delete timeData.modified;
54
- let latestVersion = "";
55
- let latestDate = /* @__PURE__ */ new Date(0);
56
- for (const [version, dateString] of Object.entries(timeData)) {
57
- const publishDate = new Date(dateString);
58
- if (publishDate > latestDate) {
59
- latestDate = publishDate;
60
- latestVersion = version;
61
- }
62
- }
63
- if (latestVersion && latestVersion !== currentVersion) {
64
- console.warn(`CLI update available: ${currentVersion} \u2192 ${latestVersion}`);
65
- const { update } = await (0, import_prompts.default)({
66
- type: "confirm",
67
- name: "update",
68
- message: "Update CLI before publishing?",
69
- initial: false
70
- });
71
- if (update) {
72
- console.info("Updating CLI...");
73
- try {
74
- await performCliUpdate();
75
- process.exit(0);
76
- } catch (updateError) {
77
- console.error("Failed to update CLI:", updateError);
78
- }
79
- }
80
- }
81
- return currentVersion;
82
- } catch (error) {
83
- console.warn("Could not check for CLI updates");
84
- return null;
85
- }
86
- }
87
- async function generatePackageMetadata(packageJson, cliVersion, username) {
88
- const metadata = {
89
- name: packageJson.name,
90
- version: packageJson.version,
91
- description: packageJson.description || "",
92
- type: packageJson.type || "plugin",
93
- // plugin or project
94
- platform: packageJson.platform || "universal",
95
- // node, browser, or universal
96
- runtimeVersion: cliVersion,
97
- // Compatible CLI/runtime version
98
- repository: packageJson.repository?.url || "",
99
- maintainers: packageJson.maintainers || [username],
100
- publishedAt: (/* @__PURE__ */ new Date()).toISOString(),
101
- publishedBy: username,
102
- dependencies: packageJson.dependencies || {},
103
- tags: packageJson.keywords || [],
104
- license: packageJson.license || "UNLICENSED"
105
- };
106
- if (packageJson.npmPackage) {
107
- metadata.npmPackage = packageJson.npmPackage;
108
- }
109
- if (packageJson.githubRepo) {
110
- metadata.githubRepo = packageJson.githubRepo;
111
- }
112
- if (metadata.type === "plugin" && !metadata.tags.includes("plugin")) {
113
- metadata.tags.push("plugin");
114
- } else if (metadata.type === "project" && !metadata.tags.includes("project")) {
115
- metadata.tags.push("project");
116
- }
117
- return metadata;
118
- }
119
- function isMaintainer(packageJson, username) {
120
- if (!packageJson.maintainers) {
121
- return true;
122
- }
123
- return packageJson.maintainers.includes(username);
124
- }
125
- async function updateRegistryIndex(packageMetadata, dryRun = false) {
126
- try {
127
- const indexPath = dryRun ? path.join(process.cwd(), LOCAL_REGISTRY_PATH, "index.json") : path.join(process.cwd(), "temp-registry", "index.json");
128
- try {
129
- await fs.access(path.dirname(indexPath));
130
- } catch {
131
- await fs.mkdir(path.dirname(indexPath), { recursive: true });
132
- try {
133
- await fs.access(indexPath);
134
- } catch {
135
- await fs.writeFile(
136
- indexPath,
137
- JSON.stringify(
138
- {
139
- v1: { packages: {} },
140
- v2: { packages: {} }
141
- },
142
- null,
143
- 2
144
- )
145
- );
146
- }
147
- }
148
- let indexContent;
149
- try {
150
- indexContent = await fs.readFile(indexPath, "utf-8");
151
- } catch (error) {
152
- indexContent = JSON.stringify({
153
- v1: { packages: {} },
154
- v2: { packages: {} }
155
- });
156
- }
157
- const index = JSON.parse(indexContent);
158
- if (!index.v2) {
159
- index.v2 = { packages: {} };
160
- }
161
- if (!index.v2.packages) {
162
- index.v2.packages = {};
163
- }
164
- if (!index.v2.packages[packageMetadata.name]) {
165
- index.v2.packages[packageMetadata.name] = {
166
- name: packageMetadata.name,
167
- description: packageMetadata.description,
168
- type: packageMetadata.type,
169
- versions: {}
170
- };
171
- }
172
- const packageInfo = index.v2.packages[packageMetadata.name];
173
- packageInfo.description = packageMetadata.description;
174
- packageInfo.type = packageMetadata.type;
175
- packageInfo.versions[packageMetadata.version] = {
176
- version: packageMetadata.version,
177
- runtimeVersion: packageMetadata.runtimeVersion,
178
- platform: packageMetadata.platform,
179
- publishedAt: packageMetadata.publishedAt,
180
- published: !dryRun
181
- };
182
- await fs.writeFile(indexPath, JSON.stringify(index, null, 2));
183
- console.info(
184
- `Registry index ${dryRun ? "(dry run) " : ""}updated with ${packageMetadata.name}@${packageMetadata.version}`
185
- );
186
- return true;
187
- } catch (error) {
188
- console.error(`Failed to update registry index: ${error.message}`);
189
- return false;
190
- }
191
- }
192
- async function savePackageToRegistry(packageMetadata, dryRun = false) {
193
- try {
194
- const packageDir = dryRun ? path.join(process.cwd(), LOCAL_REGISTRY_PATH, REGISTRY_PACKAGES_PATH, packageMetadata.name) : path.join(process.cwd(), "temp-registry", REGISTRY_PACKAGES_PATH, packageMetadata.name);
195
- const metadataPath = path.join(packageDir, `${packageMetadata.version}.json`);
196
- await fs.mkdir(packageDir, { recursive: true });
197
- await fs.writeFile(metadataPath, JSON.stringify(packageMetadata, null, 2));
198
- console.info(`Package metadata ${dryRun ? "(dry run) " : ""}saved to ${metadataPath}`);
199
- await updateRegistryIndex(packageMetadata, dryRun);
200
- return true;
201
- } catch (error) {
202
- console.error(`Failed to save package metadata: ${error.message}`);
203
- return false;
204
- }
205
- }
206
- async function getNpmUsername() {
207
- console.info(
208
- "NPM authentication required for registry compliance (package name must match potential NPM package)."
209
- );
210
- try {
211
- const { stdout } = await execa("npm", ["whoami"]);
212
- const currentUser = stdout.trim();
213
- console.info(`Found existing NPM login: ${currentUser}`);
214
- const { useExisting } = await (0, import_prompts.default)({
215
- type: "confirm",
216
- name: "useExisting",
217
- message: `Use NPM account "${currentUser}" for package naming?`,
218
- initial: true
219
- });
220
- if (useExisting) {
221
- return currentUser;
222
- } else {
223
- console.info("Please login with your desired NPM account...");
224
- await execa("npm", ["login"], { stdio: "inherit" });
225
- const { stdout: newStdout } = await execa("npm", ["whoami"]);
226
- const newUser = newStdout.trim();
227
- console.info(`Logged in as: ${newUser}`);
228
- return newUser;
229
- }
230
- } catch (error) {
231
- console.info("Not logged into NPM. Please login to continue...");
232
- try {
233
- await execa("npm", ["login"], { stdio: "inherit" });
234
- const { stdout } = await execa("npm", ["whoami"]);
235
- const username = stdout.trim();
236
- console.info(`Successfully logged in as: ${username}`);
237
- return username;
238
- } catch (loginError) {
239
- console.error("NPM login failed. Registry compliance requires a valid NPM account.");
240
- process.exit(1);
241
- }
242
- }
243
- }
244
- async function validatePluginRequirements(cwd, packageJson) {
245
- const errors = [];
246
- const warnings = [];
247
- const packageName = packageJson.name.split("/").pop() || packageJson.name;
248
- if (!packageName.startsWith("plugin-")) {
249
- errors.push(
250
- 'Plugin name must start with "plugin-". Please update your package name and try again.'
251
- );
252
- }
253
- const pluginDirName = path.basename(cwd);
254
- const expectedDefaultDesc = `ElizaOS plugin for ${pluginDirName.replace("plugin-", "")}`;
255
- if (packageJson.description === expectedDefaultDesc || packageJson.description === "${PLUGINDESCRIPTION}") {
256
- warnings.push(
257
- "Description appears to be the default generated description. Consider writing a custom description."
258
- );
259
- }
260
- const imagesDir = path.join(cwd, "images");
261
- const logoPath = path.join(imagesDir, "logo.jpg");
262
- const bannerPath = path.join(imagesDir, "banner.jpg");
263
- try {
264
- await fs.access(logoPath);
265
- } catch {
266
- warnings.push("Missing required logo.jpg in images/ directory (400x400px, max 500KB).");
267
- }
268
- try {
269
- await fs.access(bannerPath);
270
- } catch {
271
- warnings.push("Missing required banner.jpg in images/ directory (1280x640px, max 1MB).");
272
- }
273
- if (errors.length > 0) {
274
- console.error("Plugin validation failed:");
275
- errors.forEach((error) => console.error(` - ${error}`));
276
- console.error("\nPlease fix these issues and try publishing again.");
277
- process.exit(1);
278
- }
279
- if (warnings.length > 0) {
280
- console.warn("Plugin validation warnings:");
281
- warnings.forEach((warning) => console.warn(` - ${warning}`));
282
- console.warn("Your plugin may get rejected if you submit without addressing these issues.");
283
- const { proceed } = await (0, import_prompts.default)({
284
- type: "confirm",
285
- name: "proceed",
286
- message: "Do you wish to continue anyway?",
287
- initial: false
288
- });
289
- if (!proceed) {
290
- console.info("Publishing cancelled. Please address the warnings and try again.");
291
- process.exit(0);
292
- }
293
- }
294
- }
295
- var publish = new Command().name("publish").description("Publish a plugin to npm, GitHub, and the registry").option("-n, --npm", "publish to npm only (skip GitHub and registry)", false).option("-t, --test", "test publish process without making changes", false).option("-d, --dry-run", "generate registry files locally without publishing", false).option("-sr, --skip-registry", "skip publishing to the registry", false).hook("preAction", async () => {
296
- await displayBanner();
297
- }).action(async (opts) => {
298
- try {
299
- const cwd = process.cwd();
300
- const directoryInfo = detectDirectoryType(cwd);
301
- if (!directoryInfo.hasPackageJson) {
302
- console.error(
303
- `No package.json found in current directory. This directory is: ${getDirectoryTypeDescription(directoryInfo)}`
304
- );
305
- process.exit(1);
306
- }
307
- const cliVersion = await checkCliVersion();
308
- const pluginDirName = path.basename(process.cwd());
309
- if (!pluginDirName.startsWith("plugin-")) {
310
- console.error("This command must be run from a plugin directory (plugin-*)");
311
- process.exit(1);
312
- }
313
- const isValid = await validateDataDir();
314
- if (!isValid) {
315
- console.info("\nGitHub credentials required for publishing.");
316
- console.info("You'll need a GitHub Personal Access Token with these scopes:");
317
- console.info(" * repo (for repository access)");
318
- console.info(" * read:org (for organization access)");
319
- console.info(" * workflow (for workflow access)\n");
320
- await initializeDataDir();
321
- const credentials2 = await getGitHubCredentials();
322
- if (!credentials2) {
323
- console.error("GitHub credentials setup cancelled.");
324
- process.exit(1);
325
- }
326
- const revalidated = await validateDataDir();
327
- if (!revalidated) {
328
- console.error("Failed to validate credentials after saving.");
329
- process.exit(1);
330
- }
331
- }
332
- const packageJsonPath = path.join(cwd, "package.json");
333
- const packageJsonContent = await fs.readFile(packageJsonPath, "utf-8");
334
- const packageJson = JSON.parse(packageJsonContent);
335
- if (!packageJson.name || !packageJson.version) {
336
- console.error("Invalid package.json: missing name or version.");
337
- process.exit(1);
338
- }
339
- let detectedType;
340
- if (directoryInfo.type === "elizaos-plugin") {
341
- detectedType = "plugin";
342
- console.info("Detected ElizaOS plugin using standardized directory detection");
343
- } else if (directoryInfo.type === "elizaos-project") {
344
- detectedType = "project";
345
- console.info("Detected ElizaOS project using standardized directory detection");
346
- } else {
347
- detectedType = "plugin";
348
- if (packageJson.agentConfig?.pluginType) {
349
- const pluginType = packageJson.agentConfig.pluginType.toLowerCase();
350
- if (pluginType.includes("project")) {
351
- detectedType = "project";
352
- console.info("Detected project from package.json agentConfig.pluginType");
353
- }
354
- } else if (packageJson.eliza?.type === "project") {
355
- detectedType = "project";
356
- console.info("Detected project from package.json eliza.type (legacy format)");
357
- } else if (packageJson.packageType === "project") {
358
- detectedType = "project";
359
- console.info("Detected project from package.json packageType field");
360
- } else {
361
- console.info(
362
- `Defaulting to plugin type. Directory detected as: ${getDirectoryTypeDescription(directoryInfo)}`
363
- );
364
- }
365
- }
366
- packageJson.packageType = detectedType;
367
- packageJson.platform ??= "node";
368
- if (!packageJson.agentConfig) {
369
- packageJson.agentConfig = {
370
- pluginType: detectedType === "plugin" ? "elizaos:plugin:1.0.0" : "elizaos:project:1.0.0",
371
- pluginParameters: {}
372
- };
373
- } else if (!packageJson.agentConfig.pluginType) {
374
- packageJson.agentConfig.pluginType = detectedType === "plugin" ? "elizaos:plugin:1.0.0" : "elizaos:project:1.0.0";
375
- }
376
- if (detectedType === "plugin" && !packageJson.name.includes("plugin-")) {
377
- console.warn(
378
- "This doesn't appear to be an ElizaOS plugin. Package name should include 'plugin-'."
379
- );
380
- const { proceed } = await (0, import_prompts.default)({
381
- type: "confirm",
382
- name: "proceed",
383
- message: "Proceed anyway?",
384
- initial: false
385
- });
386
- if (!proceed) {
387
- process.exit(0);
388
- }
389
- }
390
- let credentials = await getGitHubCredentials();
391
- if (!credentials) {
392
- console.info("GitHub credentials required for publishing.");
393
- await new Promise((resolve) => setTimeout(resolve, 10));
394
- const newCredentials = await getGitHubCredentials();
395
- if (!newCredentials) {
396
- process.exit(1);
397
- }
398
- credentials = newCredentials;
399
- }
400
- const npmUsername = await getNpmUsername();
401
- console.info(`Using NPM username: ${npmUsername}`);
402
- console.info("Updating package.json with actual values...");
403
- const placeholderReplacements = {
404
- // Name placeholders
405
- "npm-username": {
406
- check: () => packageJson.name.includes("npm-username"),
407
- replace: () => {
408
- packageJson.name = packageJson.name.replace("npm-username", npmUsername);
409
- console.info(`Set package org: @${npmUsername}`);
410
- }
411
- },
412
- "plugin-name": {
413
- check: () => packageJson.name.includes("plugin-name"),
414
- replace: () => {
415
- packageJson.name = packageJson.name.replace("plugin-name", pluginDirName);
416
- console.info(`Set package name: ${packageJson.name}`);
417
- }
418
- },
419
- // Description placeholder
420
- "${PLUGINDESCRIPTION}": {
421
- check: () => packageJson.description === "${PLUGINDESCRIPTION}",
422
- replace: () => {
423
- const simpleName = pluginDirName.replace("plugin-", "");
424
- packageJson.description = `ElizaOS plugin for ${simpleName}`;
425
- console.info(`Set description: ${packageJson.description}`);
426
- }
427
- },
428
- // Repository URL placeholder
429
- "${REPO_URL}": {
430
- check: () => packageJson.repository && (packageJson.repository.url === "${REPO_URL}" || packageJson.repository.url === ""),
431
- replace: () => {
432
- if (!packageJson.repository) {
433
- packageJson.repository = { type: "git", url: "" };
434
- }
435
- packageJson.repository.url = `github:${credentials.username}/${pluginDirName}`;
436
- console.info(`Set repository: ${packageJson.repository.url}`);
437
- }
438
- },
439
- // Author placeholder
440
- "${GITHUB_USERNAME}": {
441
- check: () => packageJson.author === "${GITHUB_USERNAME}",
442
- replace: () => {
443
- packageJson.author = credentials.username;
444
- console.info(`Set author: ${packageJson.author}`);
445
- }
446
- },
447
- // Bugs URL placeholder
448
- "bugs-placeholder": {
449
- check: () => packageJson.bugs && packageJson.bugs.url && packageJson.bugs.url.includes("${GITHUB_USERNAME}"),
450
- replace: () => {
451
- packageJson.bugs.url = packageJson.bugs.url.replace("${GITHUB_USERNAME}", credentials.username).replace("${PLUGINNAME}", pluginDirName);
452
- console.info(`Set bugs URL: ${packageJson.bugs.url}`);
453
- }
454
- }
455
- };
456
- Object.entries(placeholderReplacements).forEach(([_, replacement]) => {
457
- if (replacement.check()) {
458
- replacement.replace();
459
- }
460
- });
461
- const finalPluginName = packageJson.name.startsWith("@") ? packageJson.name.split("/")[1] : packageJson.name;
462
- await fs.writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2), "utf-8");
463
- await validatePluginRequirements(cwd, packageJson);
464
- const settings = await getRegistrySettings();
465
- settings.publishConfig = {
466
- registry: settings.defaultRegistry,
467
- username: credentials.username,
468
- useNpm: opts.npm,
469
- platform: packageJson.platform
470
- };
471
- await saveRegistrySettings(settings);
472
- const packageMetadata = await generatePackageMetadata(
473
- packageJson,
474
- cliVersion,
475
- credentials.username
476
- );
477
- console.debug("Generated package metadata:", packageMetadata);
478
- const userIsMaintainer = isMaintainer(packageJson, credentials.username);
479
- console.info(
480
- `User ${credentials.username} is ${userIsMaintainer ? "a maintainer" : "not a maintainer"} of this package`
481
- );
482
- if (opts.dryRun) {
483
- console.info(`Running dry run for plugin registry publication...`);
484
- const success = await savePackageToRegistry(packageMetadata, true);
485
- if (success) {
486
- console.log(
487
- `[\u221A] Dry run successful: Registry metadata generated for ${packageJson.name}@${packageJson.version}`
488
- );
489
- console.info(`Files created in ${LOCAL_REGISTRY_PATH}`);
490
- } else {
491
- console.error("Dry run failed");
492
- process.exit(1);
493
- }
494
- return;
495
- }
496
- if (opts.test) {
497
- console.info(`Running plugin publish tests...`);
498
- if (opts.npm) {
499
- console.info("\nTesting npm publishing:");
500
- const npmTestSuccess = await testPublishToNpm(cwd);
501
- if (!npmTestSuccess) {
502
- console.error("npm publishing test failed");
503
- process.exit(1);
504
- }
505
- }
506
- console.info("\nTesting GitHub publishing:");
507
- const githubTestSuccess = await testPublishToGitHub(cwd, packageJson, credentials.username);
508
- if (!githubTestSuccess) {
509
- console.error("GitHub publishing test failed");
510
- process.exit(1);
511
- }
512
- if (!opts.skipRegistry) {
513
- console.info("\nTesting registry publishing:");
514
- const registryTestSuccess = await savePackageToRegistry(packageMetadata, true);
515
- if (!registryTestSuccess) {
516
- console.error("Registry publishing test failed");
517
- process.exit(1);
518
- }
519
- } else {
520
- console.info(
521
- "\nSkipping registry publishing test as requested with --skip-registry flag"
522
- );
523
- }
524
- console.log("All tests passed successfully!");
525
- return;
526
- }
527
- let publishResult = false;
528
- let registryPrUrl = null;
529
- console.info(`Publishing plugin to npm...`);
530
- if (!packageJson.npmPackage || packageJson.npmPackage === "${NPM_PACKAGE}") {
531
- packageJson.npmPackage = packageJson.name;
532
- console.info(`Set npmPackage to: ${packageJson.npmPackage}`);
533
- await fs.writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2), "utf-8");
534
- }
535
- console.info(`Publishing as npm user: ${npmUsername}`);
536
- console.info("Building package...");
537
- await execa("npm", ["run", "build"], { cwd, stdio: "inherit" });
538
- console.info("Publishing to npm...");
539
- await execa("npm", ["publish", "--ignore-scripts"], { cwd, stdio: "inherit" });
540
- console.log(`[\u221A] Successfully published ${packageJson.name}@${packageJson.version} to npm`);
541
- packageMetadata.npmPackage = packageJson.name;
542
- if (!opts.npm) {
543
- console.info("Publishing to GitHub and registry...");
544
- publishResult = await publishToGitHub(
545
- cwd,
546
- packageJson,
547
- cliVersion,
548
- credentials.username,
549
- opts.skipRegistry,
550
- false
551
- );
552
- if (!publishResult) {
553
- process.exit(1);
554
- }
555
- console.log(
556
- `[\u221A] Successfully published plugin ${packageJson.name}@${packageJson.version} to GitHub`
557
- );
558
- packageMetadata.githubRepo = `${credentials.username}/${finalPluginName}`;
559
- if (typeof publishResult === "object" && publishResult.prUrl) {
560
- registryPrUrl = publishResult.prUrl;
561
- console.log(`[\u221A] Registry pull request created: ${registryPrUrl}`);
562
- }
563
- }
564
- if (!opts.skipRegistry) {
565
- console.info("Publishing to registry...");
566
- if (userIsMaintainer) {
567
- if (!opts.npm) {
568
- console.info("Registry PR was created during GitHub publishing process.");
569
- } else {
570
- console.warn("NPM publishing currently does not update the registry.");
571
- console.info("To include this package in the registry:");
572
- console.info(`1. Fork the registry repository at ${REGISTRY_GITHUB_URL}`);
573
- console.info("2. Add your package metadata");
574
- console.info("3. Submit a pull request to the main repository");
575
- }
576
- } else {
577
- console.info("Package published, but you're not a maintainer of this package.");
578
- console.info("To include this package in the registry, please:");
579
- console.info(`1. Fork the registry repository at ${REGISTRY_GITHUB_URL}`);
580
- console.info("2. Add your package metadata");
581
- console.info("3. Submit a pull request to the main repository");
582
- }
583
- } else {
584
- console.info("Skipping registry publication as requested with --skip-registry flag");
585
- }
586
- console.log(`Successfully published plugin ${packageJson.name}@${packageJson.version}`);
587
- console.log("\nYour plugin is now available at:");
588
- console.log(`https://github.com/${credentials.username}/${finalPluginName}`);
589
- console.log("\n[\u{1F4DD}] Important: For future updates to your plugin:");
590
- console.log(" Use standard npm and git workflows, not the ElizaOS CLI:");
591
- console.log(" 1. Make your changes and test locally");
592
- console.log(" 2. Update version: npm version patch|minor|major");
593
- console.log(" 3. Publish to npm: npm publish");
594
- console.log(" 4. Push to GitHub: git push origin main && git push --tags");
595
- console.log("\n The ElizaOS registry will automatically sync with npm updates.");
596
- console.log(' Only use "elizaos publish" for initial publishing of new plugins.');
597
- } catch (error) {
598
- handleError(error);
599
- }
600
- });
601
-
602
- export {
603
- publish
604
- };