agentv 2.5.6 → 2.5.7

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.
@@ -1048,7 +1048,7 @@ var require_dist = __commonJS({
1048
1048
  });
1049
1049
 
1050
1050
  // src/index.ts
1051
- import { readFileSync as readFileSync4 } from "node:fs";
1051
+ import { readFileSync as readFileSync5 } from "node:fs";
1052
1052
 
1053
1053
  // ../../node_modules/.bun/chalk@5.6.2/node_modules/chalk/source/vendor/ansi-styles/index.js
1054
1054
  var ANSI_BACKGROUND_OFFSET = 10;
@@ -43038,10 +43038,10 @@ async function execFileWithStdinBun(argv, stdinPayload, options) {
43038
43038
  }
43039
43039
  }
43040
43040
  async function execFileWithStdinNode(argv, stdinPayload, options) {
43041
- const { spawn: spawn6 } = await import("node:child_process");
43041
+ const { spawn: spawn62 } = await import("node:child_process");
43042
43042
  return new Promise((resolve2, reject) => {
43043
43043
  const [cmd, ...args] = argv;
43044
- const child = spawn6(cmd, args, {
43044
+ const child = spawn62(cmd, args, {
43045
43045
  cwd: options.cwd,
43046
43046
  stdio: ["pipe", "pipe", "pipe"],
43047
43047
  // Merge additional env vars with process.env
@@ -43092,10 +43092,10 @@ async function execShellWithStdin(command2, stdinPayload, options = {}) {
43092
43092
  const stderrPath = path272.join(dir, "stderr.txt");
43093
43093
  await writeFile92(stdinPath, stdinPayload, "utf8");
43094
43094
  const wrappedCommand = process.platform === "win32" ? `(${command2}) < ${shellEscapePath(stdinPath)} > ${shellEscapePath(stdoutPath)} 2> ${shellEscapePath(stderrPath)}` : `(${command2}) < ${shellEscapePath(stdinPath)} > ${shellEscapePath(stdoutPath)} 2> ${shellEscapePath(stderrPath)}`;
43095
- const { spawn: spawn6 } = await import("node:child_process");
43095
+ const { spawn: spawn62 } = await import("node:child_process");
43096
43096
  try {
43097
43097
  const exitCode = await new Promise((resolve2, reject) => {
43098
- const child = spawn6(wrappedCommand, {
43098
+ const child = spawn62(wrappedCommand, {
43099
43099
  shell: true,
43100
43100
  cwd: options.cwd,
43101
43101
  stdio: ["ignore", "ignore", "ignore"],
@@ -49095,6 +49095,98 @@ var initCmdTsCommand = command({
49095
49095
  }
49096
49096
  });
49097
49097
 
49098
+ // src/commands/self/index.ts
49099
+ import { spawn as spawn6 } from "node:child_process";
49100
+ import { readFileSync as readFileSync4 } from "node:fs";
49101
+ var packageJson = JSON.parse(
49102
+ readFileSync4(new URL("../../../package.json", import.meta.url), "utf8")
49103
+ );
49104
+ function detectPackageManagerFromPath(scriptPath) {
49105
+ if (scriptPath.includes(".bun")) {
49106
+ return "bun";
49107
+ }
49108
+ return "npm";
49109
+ }
49110
+ function detectPackageManager() {
49111
+ return detectPackageManagerFromPath(process.argv[1] ?? "");
49112
+ }
49113
+ function runCommand(cmd, args) {
49114
+ return new Promise((resolve2, reject) => {
49115
+ const child = spawn6(cmd, args, { stdio: ["inherit", "pipe", "inherit"] });
49116
+ let stdout = "";
49117
+ child.stdout?.on("data", (data) => {
49118
+ process.stdout.write(data);
49119
+ stdout += data.toString();
49120
+ });
49121
+ child.on("error", reject);
49122
+ child.on("close", (code) => resolve2({ exitCode: code ?? 1, stdout }));
49123
+ });
49124
+ }
49125
+ var updateCommand = command({
49126
+ name: "update",
49127
+ description: "Update agentv to the latest version",
49128
+ args: {
49129
+ npm: flag({ long: "npm", description: "Force update using npm" }),
49130
+ bun: flag({ long: "bun", description: "Force update using bun" })
49131
+ },
49132
+ handler: async ({ npm, bun }) => {
49133
+ if (npm && bun) {
49134
+ console.error("Error: Cannot specify both --npm and --bun");
49135
+ process.exit(1);
49136
+ }
49137
+ let pm;
49138
+ if (npm) {
49139
+ pm = "npm";
49140
+ } else if (bun) {
49141
+ pm = "bun";
49142
+ } else {
49143
+ pm = detectPackageManager();
49144
+ }
49145
+ const currentVersion = packageJson.version;
49146
+ console.log(`Current version: ${currentVersion}`);
49147
+ console.log(`Updating agentv using ${pm}...
49148
+ `);
49149
+ const args = pm === "npm" ? ["install", "-g", "agentv@latest"] : ["add", "-g", "agentv@latest"];
49150
+ try {
49151
+ const result = await runCommand(pm, args);
49152
+ if (result.exitCode !== 0) {
49153
+ console.error("\nUpdate failed.");
49154
+ process.exit(1);
49155
+ }
49156
+ let newVersion;
49157
+ try {
49158
+ const versionResult = await runCommand("agentv", ["--version"]);
49159
+ newVersion = versionResult.stdout.trim();
49160
+ } catch {
49161
+ }
49162
+ if (newVersion) {
49163
+ console.log(`
49164
+ Update complete: ${currentVersion} \u2192 ${newVersion}`);
49165
+ } else {
49166
+ console.log("\nUpdate complete.");
49167
+ }
49168
+ } catch (error40) {
49169
+ if (error40 instanceof Error) {
49170
+ if (error40.message.includes("ENOENT") || error40.message.includes("not found")) {
49171
+ const alternative = pm === "npm" ? "bun" : "npm";
49172
+ console.error(`Error: ${pm} not found. Try using --${alternative} flag.`);
49173
+ } else {
49174
+ console.error(`Error: ${error40.message}`);
49175
+ }
49176
+ process.exit(1);
49177
+ }
49178
+ throw error40;
49179
+ }
49180
+ }
49181
+ });
49182
+ var selfCommand = subcommands({
49183
+ name: "self",
49184
+ description: "Manage the agentv installation",
49185
+ cmds: {
49186
+ update: updateCommand
49187
+ }
49188
+ });
49189
+
49098
49190
  // src/commands/validate/format-output.ts
49099
49191
  var ANSI_RED4 = "\x1B[31m";
49100
49192
  var ANSI_YELLOW9 = "\x1B[33m";
@@ -49300,17 +49392,18 @@ var validateCommand = command({
49300
49392
  });
49301
49393
 
49302
49394
  // src/index.ts
49303
- var packageJson = JSON.parse(readFileSync4(new URL("../package.json", import.meta.url), "utf8"));
49395
+ var packageJson2 = JSON.parse(readFileSync5(new URL("../package.json", import.meta.url), "utf8"));
49304
49396
  var app = subcommands({
49305
49397
  name: "agentv",
49306
49398
  description: "AgentV CLI",
49307
- version: packageJson.version,
49399
+ version: packageJson2.version,
49308
49400
  cmds: {
49309
49401
  compare: compareCommand,
49310
49402
  convert: convertCommand,
49311
49403
  eval: evalCommand,
49312
49404
  generate: generateCommand,
49313
49405
  init: initCmdTsCommand,
49406
+ self: selfCommand,
49314
49407
  validate: validateCommand
49315
49408
  }
49316
49409
  });
@@ -49322,4 +49415,4 @@ export {
49322
49415
  app,
49323
49416
  runCli
49324
49417
  };
49325
- //# sourceMappingURL=chunk-APKXUJF3.js.map
49418
+ //# sourceMappingURL=chunk-KM7W27VC.js.map