@agentver/cli 0.1.1 → 0.1.3
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/agentver.js +143 -37
- package/dist/agentver.js.map +1 -1
- package/package.json +1 -1
package/dist/agentver.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// bin/agentver.ts
|
|
4
|
-
import { createRequire } from "module";
|
|
5
|
-
import { dirname as
|
|
6
|
-
import { fileURLToPath } from "url";
|
|
4
|
+
import { createRequire as createRequire2 } from "module";
|
|
5
|
+
import { dirname as dirname6, join as join23 } from "path";
|
|
6
|
+
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
7
7
|
import { Command } from "commander";
|
|
8
|
+
import chalk28 from "chalk";
|
|
8
9
|
import updateNotifier from "update-notifier";
|
|
9
10
|
|
|
10
11
|
// src/commands/adopt.ts
|
|
@@ -1773,7 +1774,7 @@ function formatWithOptions(inspectOptions, ...args) {
|
|
|
1773
1774
|
const first = args[0];
|
|
1774
1775
|
let a = 0;
|
|
1775
1776
|
let str = "";
|
|
1776
|
-
let
|
|
1777
|
+
let join24 = "";
|
|
1777
1778
|
if (typeof first === "string") {
|
|
1778
1779
|
if (args.length === 1) {
|
|
1779
1780
|
return first;
|
|
@@ -1872,7 +1873,7 @@ function formatWithOptions(inspectOptions, ...args) {
|
|
|
1872
1873
|
}
|
|
1873
1874
|
if (lastPos !== 0) {
|
|
1874
1875
|
a++;
|
|
1875
|
-
|
|
1876
|
+
join24 = " ";
|
|
1876
1877
|
if (lastPos < first.length) {
|
|
1877
1878
|
str += first.slice(lastPos);
|
|
1878
1879
|
}
|
|
@@ -1880,9 +1881,9 @@ function formatWithOptions(inspectOptions, ...args) {
|
|
|
1880
1881
|
}
|
|
1881
1882
|
while (a < args.length) {
|
|
1882
1883
|
const value = args[a];
|
|
1883
|
-
str +=
|
|
1884
|
+
str += join24;
|
|
1884
1885
|
str += typeof value !== "string" ? inspect(value, inspectOptions) : value;
|
|
1885
|
-
|
|
1886
|
+
join24 = " ";
|
|
1886
1887
|
a++;
|
|
1887
1888
|
}
|
|
1888
1889
|
return str;
|
|
@@ -9708,8 +9709,109 @@ Upstream changes available (${updates.length}):
|
|
|
9708
9709
|
});
|
|
9709
9710
|
}
|
|
9710
9711
|
|
|
9711
|
-
// src/commands/
|
|
9712
|
+
// src/commands/upgrade.ts
|
|
9713
|
+
import { execFile as execFile2 } from "child_process";
|
|
9714
|
+
import { createRequire } from "module";
|
|
9715
|
+
import { dirname as dirname5, join as join21 } from "path";
|
|
9716
|
+
import { fileURLToPath } from "url";
|
|
9717
|
+
import { promisify as promisify2 } from "util";
|
|
9712
9718
|
import chalk24 from "chalk";
|
|
9719
|
+
var execFileAsync2 = promisify2(execFile2);
|
|
9720
|
+
var PACKAGE_NAME = "@agentver/cli";
|
|
9721
|
+
function getCurrentVersion() {
|
|
9722
|
+
const __dirname2 = dirname5(fileURLToPath(import.meta.url));
|
|
9723
|
+
const require3 = createRequire(import.meta.url);
|
|
9724
|
+
const pkg2 = require3(join21(__dirname2, "..", "package.json"));
|
|
9725
|
+
return pkg2.version;
|
|
9726
|
+
}
|
|
9727
|
+
async function getLatestVersion() {
|
|
9728
|
+
const response = await fetch(`https://registry.npmjs.org/${PACKAGE_NAME}/latest`);
|
|
9729
|
+
if (!response.ok) {
|
|
9730
|
+
throw new Error(`Failed to check for updates: ${response.statusText}`);
|
|
9731
|
+
}
|
|
9732
|
+
const data = await response.json();
|
|
9733
|
+
return data.version;
|
|
9734
|
+
}
|
|
9735
|
+
async function detectPackageManager() {
|
|
9736
|
+
const managers = ["bun", "pnpm", "yarn", "npm"];
|
|
9737
|
+
for (const pm of managers) {
|
|
9738
|
+
try {
|
|
9739
|
+
const { stdout } = await execFileAsync2(pm, ["--version"], { timeout: 5e3 });
|
|
9740
|
+
if (stdout.trim()) {
|
|
9741
|
+
const { stdout: listOut } = await execFileAsync2(
|
|
9742
|
+
pm,
|
|
9743
|
+
pm === "npm" ? ["list", "-g", PACKAGE_NAME, "--depth=0"] : ["pm", "ls", "-g"],
|
|
9744
|
+
{ timeout: 1e4 }
|
|
9745
|
+
).catch(() => ({ stdout: "" }));
|
|
9746
|
+
if (listOut.includes("agentver")) {
|
|
9747
|
+
return pm;
|
|
9748
|
+
}
|
|
9749
|
+
}
|
|
9750
|
+
} catch {
|
|
9751
|
+
continue;
|
|
9752
|
+
}
|
|
9753
|
+
}
|
|
9754
|
+
return "npm";
|
|
9755
|
+
}
|
|
9756
|
+
function getInstallArgs(pm) {
|
|
9757
|
+
switch (pm) {
|
|
9758
|
+
case "bun":
|
|
9759
|
+
return ["install", "-g", `${PACKAGE_NAME}@latest`];
|
|
9760
|
+
case "pnpm":
|
|
9761
|
+
return ["add", "-g", `${PACKAGE_NAME}@latest`];
|
|
9762
|
+
case "yarn":
|
|
9763
|
+
return ["global", "add", `${PACKAGE_NAME}@latest`];
|
|
9764
|
+
case "npm":
|
|
9765
|
+
return ["install", "-g", `${PACKAGE_NAME}@latest`];
|
|
9766
|
+
}
|
|
9767
|
+
}
|
|
9768
|
+
function registerUpgradeCommand(program2) {
|
|
9769
|
+
program2.command("upgrade").alias("self-update").description("Upgrade Agentver CLI to the latest version").action(async () => {
|
|
9770
|
+
const json = isJSONMode();
|
|
9771
|
+
const spinner = createSpinner("Checking for updates\u2026");
|
|
9772
|
+
spinner.start();
|
|
9773
|
+
try {
|
|
9774
|
+
const currentVersion = getCurrentVersion();
|
|
9775
|
+
const latestVersion = await getLatestVersion();
|
|
9776
|
+
if (currentVersion === latestVersion) {
|
|
9777
|
+
if (json) {
|
|
9778
|
+
outputSuccess({ current: currentVersion, latest: latestVersion, upToDate: true });
|
|
9779
|
+
} else {
|
|
9780
|
+
spinner.succeed(`Already on the latest version ${chalk24.green(`v${currentVersion}`)}`);
|
|
9781
|
+
}
|
|
9782
|
+
return;
|
|
9783
|
+
}
|
|
9784
|
+
spinner.text = `Upgrading ${chalk24.dim(`v${currentVersion}`)} \u2192 ${chalk24.green(`v${latestVersion}`)}\u2026`;
|
|
9785
|
+
const pm = await detectPackageManager();
|
|
9786
|
+
const args = getInstallArgs(pm);
|
|
9787
|
+
await execFileAsync2(pm, args, { timeout: 6e4 });
|
|
9788
|
+
if (json) {
|
|
9789
|
+
const result = {
|
|
9790
|
+
previous: currentVersion,
|
|
9791
|
+
latest: latestVersion,
|
|
9792
|
+
packageManager: pm
|
|
9793
|
+
};
|
|
9794
|
+
outputSuccess(result);
|
|
9795
|
+
} else {
|
|
9796
|
+
spinner.succeed(
|
|
9797
|
+
`Upgraded ${chalk24.green(`v${currentVersion}`)} \u2192 ${chalk24.green(`v${latestVersion}`)} via ${pm}`
|
|
9798
|
+
);
|
|
9799
|
+
}
|
|
9800
|
+
} catch (error) {
|
|
9801
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
9802
|
+
if (json) {
|
|
9803
|
+
outputError("UPGRADE_FAILED", message);
|
|
9804
|
+
process.exit(1);
|
|
9805
|
+
} else {
|
|
9806
|
+
spinner.fail(`Upgrade failed: ${message}`);
|
|
9807
|
+
process.exit(1);
|
|
9808
|
+
}
|
|
9809
|
+
}
|
|
9810
|
+
});
|
|
9811
|
+
}
|
|
9812
|
+
|
|
9813
|
+
// src/commands/verify.ts
|
|
9814
|
+
import chalk25 from "chalk";
|
|
9713
9815
|
var FALLBACK_SOURCE2 = {
|
|
9714
9816
|
host: "github.com",
|
|
9715
9817
|
owner: "local",
|
|
@@ -9776,8 +9878,8 @@ function registerVerifyCommand(program2) {
|
|
|
9776
9878
|
outputError("NO_SKILL", "No skill name provided and no packages installed");
|
|
9777
9879
|
return;
|
|
9778
9880
|
}
|
|
9779
|
-
process.stderr.write(
|
|
9780
|
-
process.stderr.write(
|
|
9881
|
+
process.stderr.write(chalk25.red("No skill name provided and no packages installed.\n"));
|
|
9882
|
+
process.stderr.write(chalk25.dim("Usage: agentver verify @org/skill-name\n"));
|
|
9781
9883
|
process.exitCode = 1;
|
|
9782
9884
|
return;
|
|
9783
9885
|
}
|
|
@@ -9792,10 +9894,10 @@ function registerVerifyCommand(program2) {
|
|
|
9792
9894
|
return;
|
|
9793
9895
|
}
|
|
9794
9896
|
process.stderr.write(
|
|
9795
|
-
|
|
9897
|
+
chalk25.red("Multiple packages installed. Please specify which to verify:\n")
|
|
9796
9898
|
);
|
|
9797
9899
|
for (const pkg2 of packageNames) {
|
|
9798
|
-
process.stderr.write(` ${
|
|
9900
|
+
process.stderr.write(` ${chalk25.cyan(pkg2)}
|
|
9799
9901
|
`);
|
|
9800
9902
|
}
|
|
9801
9903
|
process.exitCode = 1;
|
|
@@ -9812,7 +9914,7 @@ function registerVerifyCommand(program2) {
|
|
|
9812
9914
|
return;
|
|
9813
9915
|
}
|
|
9814
9916
|
process.stderr.write(
|
|
9815
|
-
|
|
9917
|
+
chalk25.red(`Invalid skill name "${skillName}". Expected format: @org/skill-name
|
|
9816
9918
|
`)
|
|
9817
9919
|
);
|
|
9818
9920
|
process.exitCode = 1;
|
|
@@ -9820,7 +9922,7 @@ function registerVerifyCommand(program2) {
|
|
|
9820
9922
|
}
|
|
9821
9923
|
if (!jsonMode) {
|
|
9822
9924
|
process.stderr.write(`
|
|
9823
|
-
${
|
|
9925
|
+
${chalk25.bold(`Verifying @${parsed.org}/${parsed.skill}...`)}
|
|
9824
9926
|
|
|
9825
9927
|
`);
|
|
9826
9928
|
}
|
|
@@ -9962,9 +10064,9 @@ ${chalk24.bold(`Verifying @${parsed.org}/${parsed.skill}...`)}
|
|
|
9962
10064
|
}
|
|
9963
10065
|
process.stderr.write("\n");
|
|
9964
10066
|
if (overallPassed) {
|
|
9965
|
-
process.stderr.write(
|
|
10067
|
+
process.stderr.write(chalk25.green.bold("Skill is verified and safe to use.\n"));
|
|
9966
10068
|
} else {
|
|
9967
|
-
process.stderr.write(
|
|
10069
|
+
process.stderr.write(chalk25.red.bold("Skill verification failed.\n"));
|
|
9968
10070
|
process.exitCode = 1;
|
|
9969
10071
|
}
|
|
9970
10072
|
});
|
|
@@ -9972,13 +10074,13 @@ ${chalk24.bold(`Verifying @${parsed.org}/${parsed.skill}...`)}
|
|
|
9972
10074
|
|
|
9973
10075
|
// src/commands/version.ts
|
|
9974
10076
|
import { existsSync as existsSync18, readFileSync as readFileSync14 } from "fs";
|
|
9975
|
-
import { basename as basename6, join as
|
|
9976
|
-
import
|
|
10077
|
+
import { basename as basename6, join as join22 } from "path";
|
|
10078
|
+
import chalk26 from "chalk";
|
|
9977
10079
|
import ora8 from "ora";
|
|
9978
10080
|
var SEMVER_REGEX2 = /^\d+\.\d+\.\d+(-[\w.]+)?$/;
|
|
9979
10081
|
function resolveSkillIdentity3() {
|
|
9980
10082
|
const cwd = process.cwd();
|
|
9981
|
-
const skillMdPath =
|
|
10083
|
+
const skillMdPath = join22(cwd, "SKILL.md");
|
|
9982
10084
|
let skillName = null;
|
|
9983
10085
|
if (existsSync18(skillMdPath)) {
|
|
9984
10086
|
const content = readFileSync14(skillMdPath, "utf-8");
|
|
@@ -10009,7 +10111,7 @@ function registerVersionCommand(program2) {
|
|
|
10009
10111
|
version.command("create <semver>").description("Create a version tag for the current skill").option("--notes <text>", "Release notes").option("--json", "Output as JSON").action(async (semver, options) => {
|
|
10010
10112
|
if (!SEMVER_REGEX2.test(semver)) {
|
|
10011
10113
|
process.stderr.write(
|
|
10012
|
-
|
|
10114
|
+
chalk26.red(`Invalid semver "${semver}". Expected format: 1.0.0 or 1.0.0-beta.1
|
|
10013
10115
|
`)
|
|
10014
10116
|
);
|
|
10015
10117
|
process.exit(1);
|
|
@@ -10017,7 +10119,7 @@ function registerVersionCommand(program2) {
|
|
|
10017
10119
|
const identity = resolveSkillIdentity3();
|
|
10018
10120
|
if (!identity) {
|
|
10019
10121
|
process.stderr.write(
|
|
10020
|
-
|
|
10122
|
+
chalk26.red("Could not determine skill identity. Run this from a skill directory.\n")
|
|
10021
10123
|
);
|
|
10022
10124
|
process.exit(1);
|
|
10023
10125
|
}
|
|
@@ -10025,7 +10127,7 @@ function registerVersionCommand(program2) {
|
|
|
10025
10127
|
const lockEntry = lockfile.packages[identity.name];
|
|
10026
10128
|
const commitSha = lockEntry?.source.type === "git" ? lockEntry.source.commit : void 0;
|
|
10027
10129
|
if (!commitSha || commitSha === "unknown") {
|
|
10028
|
-
process.stderr.write(
|
|
10130
|
+
process.stderr.write(chalk26.red("No commit SHA found in lockfile. Save changes first.\n"));
|
|
10029
10131
|
process.exit(1);
|
|
10030
10132
|
}
|
|
10031
10133
|
const spinner = ora8(`Creating version ${semver}...`).start();
|
|
@@ -10057,7 +10159,7 @@ function registerVersionCommand(program2) {
|
|
|
10057
10159
|
);
|
|
10058
10160
|
} else {
|
|
10059
10161
|
spinner.succeed(
|
|
10060
|
-
`Version ${
|
|
10162
|
+
`Version ${chalk26.cyan(semver)} created ${chalk26.dim(`(${result.commitSha.slice(0, 7)})`)}`
|
|
10061
10163
|
);
|
|
10062
10164
|
}
|
|
10063
10165
|
} catch (error) {
|
|
@@ -10071,7 +10173,7 @@ function registerVersionCommand(program2) {
|
|
|
10071
10173
|
const identity = resolveSkillIdentity3();
|
|
10072
10174
|
if (!identity) {
|
|
10073
10175
|
process.stderr.write(
|
|
10074
|
-
|
|
10176
|
+
chalk26.red("Could not determine skill identity. Run this from a skill directory.\n")
|
|
10075
10177
|
);
|
|
10076
10178
|
process.exit(1);
|
|
10077
10179
|
}
|
|
@@ -10086,16 +10188,16 @@ function registerVersionCommand(program2) {
|
|
|
10086
10188
|
return;
|
|
10087
10189
|
}
|
|
10088
10190
|
if (versions.length === 0) {
|
|
10089
|
-
process.stdout.write(
|
|
10191
|
+
process.stdout.write(chalk26.dim("No versions found.\n"));
|
|
10090
10192
|
return;
|
|
10091
10193
|
}
|
|
10092
|
-
process.stdout.write(
|
|
10194
|
+
process.stdout.write(chalk26.bold(`
|
|
10093
10195
|
Versions for @${identity.org}/${identity.name}:
|
|
10094
10196
|
|
|
10095
10197
|
`));
|
|
10096
10198
|
for (const v of versions) {
|
|
10097
10199
|
process.stdout.write(
|
|
10098
|
-
` ${
|
|
10200
|
+
` ${chalk26.cyan(v.name)} ${chalk26.dim(`(${v.commitSha.slice(0, 7)})`)} ${chalk26.dim(v.message)}
|
|
10099
10201
|
`
|
|
10100
10202
|
);
|
|
10101
10203
|
}
|
|
@@ -10110,7 +10212,7 @@ Versions for @${identity.org}/${identity.name}:
|
|
|
10110
10212
|
}
|
|
10111
10213
|
|
|
10112
10214
|
// src/commands/whoami.ts
|
|
10113
|
-
import
|
|
10215
|
+
import chalk27 from "chalk";
|
|
10114
10216
|
function registerWhoamiCommand(program2) {
|
|
10115
10217
|
program2.command("whoami").description("Show authentication state").action(async () => {
|
|
10116
10218
|
const credentials = await getCredentials();
|
|
@@ -10119,15 +10221,15 @@ function registerWhoamiCommand(program2) {
|
|
|
10119
10221
|
outputSuccess({ authenticated: false });
|
|
10120
10222
|
return;
|
|
10121
10223
|
}
|
|
10122
|
-
console.log(
|
|
10224
|
+
console.log(chalk27.dim("Not authenticated. Run `agentver login` to sign in."));
|
|
10123
10225
|
return;
|
|
10124
10226
|
}
|
|
10125
10227
|
if (!isJSONMode()) {
|
|
10126
10228
|
if (credentials.apiKey) {
|
|
10127
10229
|
const prefix = credentials.apiKey.slice(0, 8);
|
|
10128
|
-
console.log(`Authenticated via API key: ${
|
|
10230
|
+
console.log(`Authenticated via API key: ${chalk27.green(`${prefix}...`)}`);
|
|
10129
10231
|
} else {
|
|
10130
|
-
console.log(
|
|
10232
|
+
console.log(chalk27.green("Authenticated via OAuth."));
|
|
10131
10233
|
}
|
|
10132
10234
|
}
|
|
10133
10235
|
const platformUrl = getPlatformUrl();
|
|
@@ -10136,11 +10238,11 @@ function registerWhoamiCommand(program2) {
|
|
|
10136
10238
|
outputSuccess({ authenticated: true });
|
|
10137
10239
|
return;
|
|
10138
10240
|
}
|
|
10139
|
-
console.log(
|
|
10241
|
+
console.log(chalk27.dim("Platform: not connected (run `agentver login <url>` to connect)"));
|
|
10140
10242
|
return;
|
|
10141
10243
|
}
|
|
10142
10244
|
if (!isJSONMode()) {
|
|
10143
|
-
console.log(`Platform: ${
|
|
10245
|
+
console.log(`Platform: ${chalk27.cyan(platformUrl)}`);
|
|
10144
10246
|
}
|
|
10145
10247
|
const me = await platformFetchSilent("/me");
|
|
10146
10248
|
if (isJSONMode()) {
|
|
@@ -10167,10 +10269,13 @@ function registerWhoamiCommand(program2) {
|
|
|
10167
10269
|
}
|
|
10168
10270
|
|
|
10169
10271
|
// bin/agentver.ts
|
|
10170
|
-
var __dirname =
|
|
10171
|
-
var require2 =
|
|
10172
|
-
var pkg = require2(
|
|
10173
|
-
updateNotifier({ pkg }).notify(
|
|
10272
|
+
var __dirname = dirname6(fileURLToPath2(import.meta.url));
|
|
10273
|
+
var require2 = createRequire2(import.meta.url);
|
|
10274
|
+
var pkg = require2(join23(__dirname, "..", "package.json"));
|
|
10275
|
+
updateNotifier({ pkg }).notify({
|
|
10276
|
+
message: `Update available: {currentVersion} \u2192 {latestVersion}
|
|
10277
|
+
Run ${chalk28.cyan("agentver upgrade")} to update`
|
|
10278
|
+
});
|
|
10174
10279
|
var program = new Command();
|
|
10175
10280
|
program.name("agentver").description("Agent skill registry \u2014 store, version, and distribute AI agent skills").version(pkg.version).option("--json", "Output results as structured JSON");
|
|
10176
10281
|
registerAdoptCommand(program);
|
|
@@ -10193,6 +10298,7 @@ registerSuggestionsCommand(program);
|
|
|
10193
10298
|
registerSaveCommand(program);
|
|
10194
10299
|
registerPublishCommand(program);
|
|
10195
10300
|
registerDraftCommand(program);
|
|
10301
|
+
registerUpgradeCommand(program);
|
|
10196
10302
|
registerVerifyCommand(program);
|
|
10197
10303
|
registerVersionCommand(program);
|
|
10198
10304
|
registerLogCommand(program);
|