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