@agentforge/cli 0.16.65 → 0.16.66
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.cjs +144 -108
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +144 -108
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/templates/api/package.json +2 -2
- package/templates/cli/package.json +2 -2
- package/templates/full/package.json +2 -2
- package/templates/minimal/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1221,123 +1221,27 @@ async function toolTestCommand(name, options) {
|
|
|
1221
1221
|
return exitWithCommandError(error, { spinnerFailureText: "Tests failed" });
|
|
1222
1222
|
}
|
|
1223
1223
|
}
|
|
1224
|
-
async function toolPublishCommand(name, options) {
|
|
1225
|
-
try {
|
|
1226
|
-
logger.header("\u{1F4E6} Publish Tool");
|
|
1227
|
-
logger.info(`Tool: ${chalk4__default.default.cyan(name)}`);
|
|
1228
|
-
logger.info(`Tag: ${chalk4__default.default.cyan(options.tag || "latest")}`);
|
|
1229
|
-
logger.info(`Dry run: ${options.dryRun ? "Yes" : "No"}`);
|
|
1230
|
-
logger.newLine();
|
|
1231
|
-
if (options.dryRun) {
|
|
1232
|
-
logger.warn("Dry run mode - no actual publishing will occur");
|
|
1233
|
-
logger.newLine();
|
|
1234
|
-
}
|
|
1235
|
-
const { toolPath, hasTestScript, hasBuildScript } = await resolveToolPath(name);
|
|
1236
|
-
const packageManager = await detectPackageManager(toolPath);
|
|
1237
|
-
if (hasTestScript) {
|
|
1238
|
-
logger.startSpinner("Running tests...");
|
|
1239
|
-
try {
|
|
1240
|
-
await runScript(toolPath, "test", packageManager);
|
|
1241
|
-
logger.succeedSpinner("Tests passed");
|
|
1242
|
-
} catch (error) {
|
|
1243
|
-
return exitWithCommandError(error, {
|
|
1244
|
-
spinnerFailureText: "Tests failed",
|
|
1245
|
-
message: "Cannot publish tool with failing tests"
|
|
1246
|
-
});
|
|
1247
|
-
}
|
|
1248
|
-
} else {
|
|
1249
|
-
logger.info("\u26A0\uFE0F Skipping tests (no test script found)");
|
|
1250
|
-
}
|
|
1251
|
-
if (hasBuildScript) {
|
|
1252
|
-
logger.startSpinner("Building tool...");
|
|
1253
|
-
try {
|
|
1254
|
-
await runScript(toolPath, "build", packageManager);
|
|
1255
|
-
logger.succeedSpinner("Build completed");
|
|
1256
|
-
} catch (error) {
|
|
1257
|
-
return exitWithCommandError(error, { spinnerFailureText: "Build failed" });
|
|
1258
|
-
}
|
|
1259
|
-
} else {
|
|
1260
|
-
logger.info("\u26A0\uFE0F Skipping build (no build script found)");
|
|
1261
|
-
}
|
|
1262
|
-
logger.startSpinner(options.dryRun ? "Running dry-run publish..." : "Publishing to npm...");
|
|
1263
|
-
try {
|
|
1264
|
-
await publishPackage(toolPath, {
|
|
1265
|
-
tag: options.tag,
|
|
1266
|
-
access: "public",
|
|
1267
|
-
dryRun: options.dryRun
|
|
1268
|
-
});
|
|
1269
|
-
if (options.dryRun) {
|
|
1270
|
-
logger.succeedSpinner("Dry-run completed - no actual publishing occurred");
|
|
1271
|
-
} else {
|
|
1272
|
-
logger.succeedSpinner("Published to npm");
|
|
1273
|
-
}
|
|
1274
|
-
} catch (error) {
|
|
1275
|
-
const errorMessage = getErrorMessage(error);
|
|
1276
|
-
logger.failSpinner("Publishing failed");
|
|
1277
|
-
if (errorMessage.includes("ENEEDAUTH") || errorMessage.includes("E401")) {
|
|
1278
|
-
logger.error("Not authenticated with npm");
|
|
1279
|
-
logger.info("Run: npm login");
|
|
1280
|
-
} else if (errorMessage.includes("E403")) {
|
|
1281
|
-
logger.error("Permission denied - you may not have access to publish this package");
|
|
1282
|
-
logger.info("Check package name and npm organization permissions");
|
|
1283
|
-
} else if (errorMessage.includes("EPUBLISHCONFLICT") || errorMessage.includes("E409")) {
|
|
1284
|
-
logger.error("Version already published");
|
|
1285
|
-
logger.info("Update the version in package.json before publishing");
|
|
1286
|
-
} else {
|
|
1287
|
-
logger.error(errorMessage);
|
|
1288
|
-
}
|
|
1289
|
-
return exitWithCommandError(error, {
|
|
1290
|
-
logError: false
|
|
1291
|
-
});
|
|
1292
|
-
}
|
|
1293
|
-
logger.newLine();
|
|
1294
|
-
if (options.dryRun) {
|
|
1295
|
-
logger.success(chalk4__default.default.bold.green("\u2728 Dry-run completed successfully!"));
|
|
1296
|
-
logger.newLine();
|
|
1297
|
-
logger.info("No changes were made. Remove --dry-run to publish for real.");
|
|
1298
|
-
} else {
|
|
1299
|
-
logger.success(chalk4__default.default.bold.green("\u2728 Tool published successfully!"));
|
|
1300
|
-
logger.newLine();
|
|
1301
|
-
logger.info(`Published ${chalk4__default.default.cyan(name)} with tag ${chalk4__default.default.cyan(options.tag || "latest")}`);
|
|
1302
|
-
logger.info("Users can now install with: npm install " + name);
|
|
1303
|
-
}
|
|
1304
|
-
} catch (error) {
|
|
1305
|
-
return exitWithCommandError(error, { spinnerFailureText: "Publishing failed" });
|
|
1306
|
-
}
|
|
1307
|
-
}
|
|
1308
1224
|
async function resolveToolPath(name) {
|
|
1309
1225
|
const cwd = process.cwd();
|
|
1310
1226
|
const isScopedPackage = /^@[^/]+\/[^/]+$/.test(name);
|
|
1311
1227
|
const isPath = !isScopedPackage && (name.includes("/") || name.includes("\\"));
|
|
1312
1228
|
if (isPath) {
|
|
1313
1229
|
const absolutePath = path12__default.default.isAbsolute(name) ? name : path12__default.default.resolve(cwd, name);
|
|
1314
|
-
return
|
|
1230
|
+
return validateToolPath(absolutePath, name);
|
|
1315
1231
|
}
|
|
1316
1232
|
const cwdPackageJsonPath = path12__default.default.join(cwd, "package.json");
|
|
1317
1233
|
if (await fs__default.default.pathExists(cwdPackageJsonPath)) {
|
|
1318
1234
|
const cwdPackageJson = await fs__default.default.readJson(cwdPackageJsonPath);
|
|
1319
1235
|
if (cwdPackageJson.name === name || cwdPackageJson.name === `@agentforge/${name}`) {
|
|
1320
|
-
return
|
|
1236
|
+
return validateToolPath(cwd, name);
|
|
1321
1237
|
}
|
|
1322
1238
|
}
|
|
1323
|
-
const
|
|
1324
|
-
const possiblePaths = [
|
|
1325
|
-
path12__default.default.join(cwd, "tools", name),
|
|
1326
|
-
path12__default.default.join(cwd, "packages", name),
|
|
1327
|
-
path12__default.default.join(cwd, name)
|
|
1328
|
-
];
|
|
1329
|
-
if (isScopedPackage) {
|
|
1330
|
-
possiblePaths.push(
|
|
1331
|
-
path12__default.default.join(cwd, "tools", unscopedName),
|
|
1332
|
-
path12__default.default.join(cwd, "packages", unscopedName),
|
|
1333
|
-
path12__default.default.join(cwd, unscopedName)
|
|
1334
|
-
);
|
|
1335
|
-
}
|
|
1239
|
+
const possiblePaths = buildPossiblePaths(cwd, name, isScopedPackage);
|
|
1336
1240
|
for (const possiblePath of possiblePaths) {
|
|
1337
1241
|
if (await fs__default.default.pathExists(possiblePath)) {
|
|
1338
1242
|
const packageJsonPath = path12__default.default.join(possiblePath, "package.json");
|
|
1339
1243
|
if (await fs__default.default.pathExists(packageJsonPath)) {
|
|
1340
|
-
return
|
|
1244
|
+
return validateToolPath(possiblePath, name);
|
|
1341
1245
|
}
|
|
1342
1246
|
}
|
|
1343
1247
|
}
|
|
@@ -1346,7 +1250,7 @@ async function resolveToolPath(name) {
|
|
|
1346
1250
|
logger.info("Tried the following locations:");
|
|
1347
1251
|
logger.list([
|
|
1348
1252
|
`Current directory (${cwd})`,
|
|
1349
|
-
...possiblePaths.map((
|
|
1253
|
+
...possiblePaths.map((possiblePath) => path12__default.default.relative(cwd, possiblePath) || ".")
|
|
1350
1254
|
]);
|
|
1351
1255
|
logger.newLine();
|
|
1352
1256
|
logger.info("Make sure you are either:");
|
|
@@ -1357,6 +1261,22 @@ async function resolveToolPath(name) {
|
|
|
1357
1261
|
]);
|
|
1358
1262
|
return exitWithCommandError(`Could not find tool package: ${name}`, { logError: false });
|
|
1359
1263
|
}
|
|
1264
|
+
function buildPossiblePaths(cwd, name, isScopedPackage) {
|
|
1265
|
+
const possiblePaths = [
|
|
1266
|
+
path12__default.default.join(cwd, "tools", name),
|
|
1267
|
+
path12__default.default.join(cwd, "packages", name),
|
|
1268
|
+
path12__default.default.join(cwd, name)
|
|
1269
|
+
];
|
|
1270
|
+
if (isScopedPackage) {
|
|
1271
|
+
const unscopedName = name.split("/")[1];
|
|
1272
|
+
possiblePaths.push(
|
|
1273
|
+
path12__default.default.join(cwd, "tools", unscopedName),
|
|
1274
|
+
path12__default.default.join(cwd, "packages", unscopedName),
|
|
1275
|
+
path12__default.default.join(cwd, unscopedName)
|
|
1276
|
+
);
|
|
1277
|
+
}
|
|
1278
|
+
return possiblePaths;
|
|
1279
|
+
}
|
|
1360
1280
|
async function validateToolPath(toolPath, expectedName) {
|
|
1361
1281
|
if (!await fs__default.default.pathExists(toolPath)) {
|
|
1362
1282
|
return exitWithCommandError(`Tool directory not found: ${toolPath}`);
|
|
@@ -1375,20 +1295,136 @@ async function validateToolPath(toolPath, expectedName) {
|
|
|
1375
1295
|
if (!packageJson.name) {
|
|
1376
1296
|
return exitWithCommandError('package.json must have a "name" field');
|
|
1377
1297
|
}
|
|
1378
|
-
|
|
1298
|
+
logPackageNameMismatch(expectedName, packageJson.name);
|
|
1299
|
+
return {
|
|
1300
|
+
toolPath,
|
|
1301
|
+
hasTestScript: !!packageJson.scripts?.test,
|
|
1302
|
+
hasBuildScript: !!packageJson.scripts?.build
|
|
1303
|
+
};
|
|
1304
|
+
}
|
|
1305
|
+
function logPackageNameMismatch(expectedName, packageName) {
|
|
1379
1306
|
const nameMatches = packageName === expectedName || packageName === `@agentforge/${expectedName}` || packageName.endsWith(`/${expectedName}`);
|
|
1380
1307
|
if (!nameMatches) {
|
|
1381
1308
|
logger.warn(`Package name mismatch: expected ${chalk4__default.default.cyan(expectedName)}, found ${chalk4__default.default.cyan(packageName)}`);
|
|
1382
1309
|
logger.info(`Publishing package: ${chalk4__default.default.cyan(packageName)}`);
|
|
1383
1310
|
logger.newLine();
|
|
1384
1311
|
}
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1312
|
+
}
|
|
1313
|
+
|
|
1314
|
+
// src/commands/tool/publish-preflight.ts
|
|
1315
|
+
async function runPublishPreflight(toolPath, packageManager, toolInfo) {
|
|
1316
|
+
await runOptionalScript({
|
|
1317
|
+
enabled: toolInfo.hasTestScript,
|
|
1318
|
+
skipMessage: "\u26A0\uFE0F Skipping tests (no test script found)",
|
|
1319
|
+
startMessage: "Running tests...",
|
|
1320
|
+
successMessage: "Tests passed",
|
|
1321
|
+
scriptName: "test",
|
|
1388
1322
|
toolPath,
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1323
|
+
packageManager,
|
|
1324
|
+
failureOptions: {
|
|
1325
|
+
spinnerFailureText: "Tests failed",
|
|
1326
|
+
message: "Cannot publish tool with failing tests"
|
|
1327
|
+
}
|
|
1328
|
+
});
|
|
1329
|
+
await runOptionalScript({
|
|
1330
|
+
enabled: toolInfo.hasBuildScript,
|
|
1331
|
+
skipMessage: "\u26A0\uFE0F Skipping build (no build script found)",
|
|
1332
|
+
startMessage: "Building tool...",
|
|
1333
|
+
successMessage: "Build completed",
|
|
1334
|
+
scriptName: "build",
|
|
1335
|
+
toolPath,
|
|
1336
|
+
packageManager,
|
|
1337
|
+
failureOptions: {
|
|
1338
|
+
spinnerFailureText: "Build failed"
|
|
1339
|
+
}
|
|
1340
|
+
});
|
|
1341
|
+
}
|
|
1342
|
+
async function runOptionalScript(options) {
|
|
1343
|
+
if (!options.enabled) {
|
|
1344
|
+
logger.info(options.skipMessage);
|
|
1345
|
+
return;
|
|
1346
|
+
}
|
|
1347
|
+
logger.startSpinner(options.startMessage);
|
|
1348
|
+
try {
|
|
1349
|
+
await runScript(options.toolPath, options.scriptName, options.packageManager);
|
|
1350
|
+
logger.succeedSpinner(options.successMessage);
|
|
1351
|
+
} catch (error) {
|
|
1352
|
+
return exitWithCommandError(error, options.failureOptions);
|
|
1353
|
+
}
|
|
1354
|
+
}
|
|
1355
|
+
async function publishToolPackage(toolPath, options) {
|
|
1356
|
+
logger.startSpinner(options.dryRun ? "Running dry-run publish..." : "Publishing to npm...");
|
|
1357
|
+
try {
|
|
1358
|
+
await publishPackage(toolPath, {
|
|
1359
|
+
tag: options.tag,
|
|
1360
|
+
access: "public",
|
|
1361
|
+
dryRun: options.dryRun
|
|
1362
|
+
});
|
|
1363
|
+
logger.succeedSpinner(
|
|
1364
|
+
options.dryRun ? "Dry-run completed - no actual publishing occurred" : "Published to npm"
|
|
1365
|
+
);
|
|
1366
|
+
} catch (error) {
|
|
1367
|
+
const errorMessage = getErrorMessage(error);
|
|
1368
|
+
logger.failSpinner("Publishing failed");
|
|
1369
|
+
logPublishError(errorMessage);
|
|
1370
|
+
return exitWithCommandError(error, { logError: false });
|
|
1371
|
+
}
|
|
1372
|
+
}
|
|
1373
|
+
function logPublishSummary(name, options) {
|
|
1374
|
+
logger.newLine();
|
|
1375
|
+
if (options.dryRun) {
|
|
1376
|
+
logger.success(chalk4__default.default.bold.green("\u2728 Dry-run completed successfully!"));
|
|
1377
|
+
logger.newLine();
|
|
1378
|
+
logger.info("No changes were made. Remove --dry-run to publish for real.");
|
|
1379
|
+
return;
|
|
1380
|
+
}
|
|
1381
|
+
logger.success(chalk4__default.default.bold.green("\u2728 Tool published successfully!"));
|
|
1382
|
+
logger.newLine();
|
|
1383
|
+
logger.info(`Published ${chalk4__default.default.cyan(name)} with tag ${chalk4__default.default.cyan(options.tag || "latest")}`);
|
|
1384
|
+
logger.info("Users can now install with: npm install " + name);
|
|
1385
|
+
}
|
|
1386
|
+
function logPublishError(errorMessage) {
|
|
1387
|
+
if (errorMessage.includes("ENEEDAUTH") || errorMessage.includes("E401")) {
|
|
1388
|
+
logger.error("Not authenticated with npm");
|
|
1389
|
+
logger.info("Run: npm login");
|
|
1390
|
+
return;
|
|
1391
|
+
}
|
|
1392
|
+
if (errorMessage.includes("E403")) {
|
|
1393
|
+
logger.error("Permission denied - you may not have access to publish this package");
|
|
1394
|
+
logger.info("Check package name and npm organization permissions");
|
|
1395
|
+
return;
|
|
1396
|
+
}
|
|
1397
|
+
if (errorMessage.includes("EPUBLISHCONFLICT") || errorMessage.includes("E409")) {
|
|
1398
|
+
logger.error("Version already published");
|
|
1399
|
+
logger.info("Update the version in package.json before publishing");
|
|
1400
|
+
return;
|
|
1401
|
+
}
|
|
1402
|
+
logger.error(errorMessage);
|
|
1403
|
+
}
|
|
1404
|
+
|
|
1405
|
+
// src/commands/tool/publish.ts
|
|
1406
|
+
async function toolPublishCommand(name, options) {
|
|
1407
|
+
try {
|
|
1408
|
+
logPublishHeader(name, options);
|
|
1409
|
+
const toolInfo = await resolveToolPath(name);
|
|
1410
|
+
const packageManager = await detectPackageManager(toolInfo.toolPath);
|
|
1411
|
+
await runPublishPreflight(toolInfo.toolPath, packageManager, toolInfo);
|
|
1412
|
+
await publishToolPackage(toolInfo.toolPath, options);
|
|
1413
|
+
logPublishSummary(name, options);
|
|
1414
|
+
} catch (error) {
|
|
1415
|
+
return exitWithCommandError(error, { spinnerFailureText: "Publishing failed" });
|
|
1416
|
+
}
|
|
1417
|
+
}
|
|
1418
|
+
function logPublishHeader(name, options) {
|
|
1419
|
+
logger.header("\u{1F4E6} Publish Tool");
|
|
1420
|
+
logger.info(`Tool: ${chalk4__default.default.cyan(name)}`);
|
|
1421
|
+
logger.info(`Tag: ${chalk4__default.default.cyan(options.tag || "latest")}`);
|
|
1422
|
+
logger.info(`Dry run: ${options.dryRun ? "Yes" : "No"}`);
|
|
1423
|
+
logger.newLine();
|
|
1424
|
+
if (options.dryRun) {
|
|
1425
|
+
logger.warn("Dry run mode - no actual publishing will occur");
|
|
1426
|
+
logger.newLine();
|
|
1427
|
+
}
|
|
1392
1428
|
}
|
|
1393
1429
|
|
|
1394
1430
|
// src/index.ts
|