@an-sdk/cli 0.0.6 → 0.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 (2) hide show
  1. package/dist/index.js +54 -11
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -46,6 +46,7 @@ async function login() {
46
46
  if (existing) {
47
47
  p.log.info("Already logged in. Continuing will re-authenticate.");
48
48
  }
49
+ p.log.info("Get your API key at https://an.dev/api-keys");
49
50
  const apiKey = await p.text({
50
51
  message: "Enter your API key",
51
52
  validate: (val) => {
@@ -63,7 +64,7 @@ async function login() {
63
64
  });
64
65
  if (!res.ok) {
65
66
  s.stop("Invalid API key");
66
- p.log.error("The API key could not be verified. Check it and try again.");
67
+ p.log.error("Invalid API key. Get a new one at https://an.dev/api-keys");
67
68
  process.exit(1);
68
69
  }
69
70
  const { user, team } = await res.json();
@@ -80,7 +81,7 @@ async function findAgentEntryPoints() {
80
81
  const { existsSync, readdirSync, statSync } = await import("fs");
81
82
  const { join: join2, basename: basename2, extname } = await import("path");
82
83
  if (!existsSync("agents") || !statSync("agents").isDirectory()) {
83
- throw new Error("No agents found. Create agents in the `agents/` directory.");
84
+ throw new Error("No agents/ directory found. See https://an.dev/docs to get started.");
84
85
  }
85
86
  const entries = [];
86
87
  const items = readdirSync("agents");
@@ -103,7 +104,7 @@ async function findAgentEntryPoints() {
103
104
  }
104
105
  }
105
106
  if (entries.length === 0) {
106
- throw new Error("No agents found. Create agents in the `agents/` directory.");
107
+ throw new Error("No agents found in agents/ directory. See https://an.dev/docs to get started.");
107
108
  }
108
109
  return entries;
109
110
  }
@@ -260,20 +261,62 @@ Deployed before failure:`);
260
261
  console.log(` ${agent.slug} \u2192 ${AN_BASE}/a/${projectSlug}/${agent.slug}`);
261
262
  }
262
263
  console.log();
263
- console.log(` Dashboard \u2192 ${AN_BASE}/an/deployments`);
264
+ p2.log.info("Next steps:");
265
+ console.log(" \xB7 Open the link above to test your agent");
266
+ console.log(" \xB7 Run `an deploy` again after changes");
267
+ console.log(` \xB7 View all deployments: ${AN_BASE}/an/deployments`);
264
268
  p2.outro("Done");
265
269
  }
266
270
 
267
271
  // src/index.ts
272
+ import { createRequire } from "module";
273
+ var require2 = createRequire(import.meta.url);
274
+ var { version } = require2("../package.json");
268
275
  var command = process.argv[2];
276
+ var args = process.argv.slice(3);
277
+ var hasFlag = (flag) => args.includes(flag);
278
+ function showHelp() {
279
+ console.log(`AN CLI v${version} \u2014 deploy AI agents
280
+ `);
281
+ console.log("Usage: an <command>\n");
282
+ console.log("Commands:");
283
+ console.log(" an login Authenticate with AN platform");
284
+ console.log(" an deploy Bundle and deploy your agent");
285
+ console.log("\nOptions:");
286
+ console.log(" --help, -h Show help");
287
+ console.log(" --version, -v Show version");
288
+ console.log("\nGet started: an login");
289
+ console.log("Docs: https://an.dev/docs");
290
+ }
291
+ function showLoginHelp() {
292
+ console.log("Usage: an login\n");
293
+ console.log("Authenticate with the AN platform using an API key.");
294
+ console.log("Get your API key at https://an.dev/api-keys");
295
+ }
296
+ function showDeployHelp() {
297
+ console.log("Usage: an deploy\n");
298
+ console.log("Bundle and deploy agents from the ./agents/ directory.\n");
299
+ console.log("Agent structure:");
300
+ console.log(" agents/");
301
+ console.log(" my-agent/");
302
+ console.log(" index.ts agent entry point");
303
+ console.log(" another.ts single-file agent");
304
+ console.log("\nDocs: https://an.dev/docs");
305
+ }
269
306
  if (command === "login") {
270
- await login();
307
+ if (hasFlag("--help") || hasFlag("-h")) {
308
+ showLoginHelp();
309
+ } else {
310
+ await login();
311
+ }
271
312
  } else if (command === "deploy") {
272
- await deploy();
313
+ if (hasFlag("--help") || hasFlag("-h")) {
314
+ showDeployHelp();
315
+ } else {
316
+ await deploy();
317
+ }
318
+ } else if (command === "--version" || command === "-v") {
319
+ console.log(version);
273
320
  } else {
274
- console.log("AN CLI \u2014 deploy AI agents\n");
275
- console.log("Commands:");
276
- console.log(" an login Authenticate with AN platform");
277
- console.log(" an deploy Bundle and deploy your agent");
278
- console.log("\nGet started: an login");
321
+ showHelp();
279
322
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@an-sdk/cli",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "description": "AN CLI — deploy AI agents",
5
5
  "type": "module",
6
6
  "bin": {