@agentuity/cli 0.0.12 → 0.0.15

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 (115) hide show
  1. package/dist/api.d.ts +5 -0
  2. package/dist/api.d.ts.map +1 -1
  3. package/dist/auth.d.ts +2 -0
  4. package/dist/auth.d.ts.map +1 -1
  5. package/dist/cli.d.ts.map +1 -1
  6. package/dist/cmd/auth/api.d.ts +8 -1
  7. package/dist/cmd/auth/api.d.ts.map +1 -1
  8. package/dist/cmd/auth/index.d.ts +1 -1
  9. package/dist/cmd/auth/index.d.ts.map +1 -1
  10. package/dist/cmd/auth/login.d.ts +1 -1
  11. package/dist/cmd/auth/login.d.ts.map +1 -1
  12. package/dist/cmd/auth/logout.d.ts +1 -1
  13. package/dist/cmd/auth/logout.d.ts.map +1 -1
  14. package/dist/cmd/auth/signup.d.ts +3 -0
  15. package/dist/cmd/auth/signup.d.ts.map +1 -0
  16. package/dist/cmd/bundle/index.d.ts +1 -1
  17. package/dist/cmd/bundle/index.d.ts.map +1 -1
  18. package/dist/cmd/dev/index.d.ts +1 -1
  19. package/dist/cmd/dev/index.d.ts.map +1 -1
  20. package/dist/cmd/example/create-user.d.ts +1 -1
  21. package/dist/cmd/example/create-user.d.ts.map +1 -1
  22. package/dist/cmd/example/create.d.ts +1 -1
  23. package/dist/cmd/example/create.d.ts.map +1 -1
  24. package/dist/cmd/example/deploy.d.ts +1 -1
  25. package/dist/cmd/example/deploy.d.ts.map +1 -1
  26. package/dist/cmd/example/index.d.ts +1 -1
  27. package/dist/cmd/example/index.d.ts.map +1 -1
  28. package/dist/cmd/example/list.d.ts +1 -1
  29. package/dist/cmd/example/list.d.ts.map +1 -1
  30. package/dist/cmd/example/optional-auth.d.ts +3 -0
  31. package/dist/cmd/example/optional-auth.d.ts.map +1 -0
  32. package/dist/cmd/example/run-command.d.ts +1 -1
  33. package/dist/cmd/example/run-command.d.ts.map +1 -1
  34. package/dist/cmd/example/spinner.d.ts +1 -1
  35. package/dist/cmd/example/spinner.d.ts.map +1 -1
  36. package/dist/cmd/example/steps.d.ts +1 -1
  37. package/dist/cmd/example/steps.d.ts.map +1 -1
  38. package/dist/cmd/example/version.d.ts +1 -1
  39. package/dist/cmd/example/version.d.ts.map +1 -1
  40. package/dist/cmd/profile/create.d.ts +1 -1
  41. package/dist/cmd/profile/create.d.ts.map +1 -1
  42. package/dist/cmd/profile/delete.d.ts +1 -1
  43. package/dist/cmd/profile/delete.d.ts.map +1 -1
  44. package/dist/cmd/profile/index.d.ts +1 -1
  45. package/dist/cmd/profile/index.d.ts.map +1 -1
  46. package/dist/cmd/profile/list.d.ts +1 -1
  47. package/dist/cmd/profile/list.d.ts.map +1 -1
  48. package/dist/cmd/profile/show.d.ts +1 -1
  49. package/dist/cmd/profile/show.d.ts.map +1 -1
  50. package/dist/cmd/profile/use.d.ts +1 -1
  51. package/dist/cmd/profile/use.d.ts.map +1 -1
  52. package/dist/cmd/project/create.d.ts +1 -1
  53. package/dist/cmd/project/create.d.ts.map +1 -1
  54. package/dist/cmd/project/delete.d.ts +1 -1
  55. package/dist/cmd/project/delete.d.ts.map +1 -1
  56. package/dist/cmd/project/download.d.ts +1 -1
  57. package/dist/cmd/project/download.d.ts.map +1 -1
  58. package/dist/cmd/project/index.d.ts +1 -1
  59. package/dist/cmd/project/index.d.ts.map +1 -1
  60. package/dist/cmd/project/list.d.ts +1 -1
  61. package/dist/cmd/project/list.d.ts.map +1 -1
  62. package/dist/cmd/project/show.d.ts +1 -1
  63. package/dist/cmd/project/show.d.ts.map +1 -1
  64. package/dist/cmd/project/template-flow.d.ts +1 -1
  65. package/dist/cmd/project/template-flow.d.ts.map +1 -1
  66. package/dist/cmd/version/index.d.ts +1 -1
  67. package/dist/cmd/version/index.d.ts.map +1 -1
  68. package/dist/config.d.ts.map +1 -1
  69. package/dist/index.d.ts +1 -0
  70. package/dist/index.d.ts.map +1 -1
  71. package/dist/tui.d.ts +22 -0
  72. package/dist/tui.d.ts.map +1 -1
  73. package/dist/types.d.ts +29 -4
  74. package/dist/types.d.ts.map +1 -1
  75. package/package.json +1 -1
  76. package/src/api.ts +16 -2
  77. package/src/auth.ts +79 -4
  78. package/src/cli.ts +51 -1
  79. package/src/cmd/auth/README.md +37 -3
  80. package/src/cmd/auth/api.ts +67 -3
  81. package/src/cmd/auth/index.ts +3 -2
  82. package/src/cmd/auth/login.ts +15 -7
  83. package/src/cmd/auth/logout.ts +3 -3
  84. package/src/cmd/auth/signup.ts +51 -0
  85. package/src/cmd/bundle/index.ts +1 -1
  86. package/src/cmd/dev/index.ts +137 -50
  87. package/src/cmd/example/create-user.ts +1 -1
  88. package/src/cmd/example/create.ts +1 -1
  89. package/src/cmd/example/deploy.ts +1 -1
  90. package/src/cmd/example/index.ts +3 -1
  91. package/src/cmd/example/list.ts +1 -1
  92. package/src/cmd/example/optional-auth.ts +38 -0
  93. package/src/cmd/example/run-command.ts +2 -2
  94. package/src/cmd/example/sound.ts +2 -2
  95. package/src/cmd/example/spinner.ts +2 -2
  96. package/src/cmd/example/steps.ts +2 -2
  97. package/src/cmd/example/version.ts +1 -1
  98. package/src/cmd/profile/create.ts +3 -3
  99. package/src/cmd/profile/delete.ts +3 -3
  100. package/src/cmd/profile/index.ts +1 -1
  101. package/src/cmd/profile/list.ts +3 -3
  102. package/src/cmd/profile/show.ts +3 -3
  103. package/src/cmd/profile/use.ts +3 -3
  104. package/src/cmd/project/create.ts +1 -1
  105. package/src/cmd/project/delete.ts +1 -1
  106. package/src/cmd/project/download.ts +3 -3
  107. package/src/cmd/project/index.ts +1 -1
  108. package/src/cmd/project/list.ts +1 -1
  109. package/src/cmd/project/show.ts +1 -1
  110. package/src/cmd/project/template-flow.ts +3 -3
  111. package/src/cmd/version/index.ts +3 -3
  112. package/src/config.ts +9 -2
  113. package/src/index.ts +1 -0
  114. package/src/tui.ts +121 -6
  115. package/src/types.ts +47 -2
package/src/tui.ts CHANGED
@@ -82,6 +82,16 @@ export function error(message: string): void {
82
82
  console.error(`${color}${ICONS.error} ${message}${reset}`);
83
83
  }
84
84
 
85
+ /**
86
+ * Print an error message with a red X and then exit
87
+ */
88
+ export function fatal(message: string): never {
89
+ const color = getColor('error');
90
+ const reset = COLORS.reset;
91
+ console.error(`${color}${ICONS.error} ${message}${reset}`);
92
+ process.exit(1);
93
+ }
94
+
85
95
  /**
86
96
  * Print a warning message with a yellow warning icon
87
97
  */
@@ -200,9 +210,13 @@ export function padLeft(str: string, length: number, pad = ' '): string {
200
210
  * Creates a bordered box around the content
201
211
  *
202
212
  * Uses Bun.stringWidth() for accurate width calculation with ANSI codes and unicode
213
+ * Responsive to terminal width - adapts to narrow terminals
203
214
  */
204
215
  export function banner(title: string, body: string): void {
205
- const maxWidth = 80;
216
+ // Get terminal width, default to 80 if not available, minimum 40
217
+ const termWidth = process.stdout.columns || 80;
218
+ const maxWidth = Math.max(40, Math.min(termWidth - 2, 80)); // Between 40 and 80, with 2 char margin
219
+
206
220
  const border = {
207
221
  topLeft: '╭',
208
222
  topRight: '╮',
@@ -377,6 +391,33 @@ export async function confirm(message: string, defaultValue = true): Promise<boo
377
391
  });
378
392
  }
379
393
 
394
+ /**
395
+ * Display a signup benefits box with cyan border
396
+ * Shows the value proposition for creating an Agentuity account
397
+ */
398
+ export function showSignupBenefits(): void {
399
+ const CYAN = Bun.color('cyan', 'ansi-16m');
400
+ const TEXT =
401
+ currentColorScheme === 'dark' ? Bun.color('white', 'ansi') : Bun.color('black', 'ansi');
402
+ const RESET = '\x1b[0m';
403
+
404
+ const lines = [
405
+ '╔════════════════════════════════════════════╗',
406
+ `║ ⨺ Signup for Agentuity ${muted('free')}${CYAN} ║`,
407
+ '║ ║',
408
+ `║ ✓ ${TEXT}Cloud deployment, previews and CI/CD${CYAN} ║`,
409
+ `║ ✓ ${TEXT}AI Gateway, KV, Vector and more${CYAN} ║`,
410
+ `║ ✓ ${TEXT}Observability, Tracing and Logging${CYAN} ║`,
411
+ `║ ✓ ${TEXT}Organization and Team support${CYAN} ║`,
412
+ `║ ✓ ${TEXT}And much more!${CYAN} ║`,
413
+ '╚════════════════════════════════════════════╝',
414
+ ];
415
+
416
+ console.log('');
417
+ lines.forEach((line) => console.log(CYAN + line + RESET));
418
+ console.log('');
419
+ }
420
+
380
421
  /**
381
422
  * Copy text to clipboard
382
423
  * Returns true if successful, false otherwise
@@ -443,9 +484,36 @@ function getDisplayWidth(str: string): number {
443
484
  return Bun.stringWidth(withoutOSC8);
444
485
  }
445
486
 
487
+ /**
488
+ * Extract ANSI codes from the beginning of a string
489
+ */
490
+ function extractLeadingAnsiCodes(str: string): string {
491
+ // Match ANSI escape sequences at the start of the string
492
+ // eslint-disable-next-line no-control-regex
493
+ const match = str.match(/^(\x1b\[[0-9;]*m)+/);
494
+ return match ? match[0] : '';
495
+ }
496
+
497
+ /**
498
+ * Strip ANSI codes from a string
499
+ */
500
+ function stripAnsiCodes(str: string): string {
501
+ // Remove all ANSI escape sequences
502
+ // eslint-disable-next-line no-control-regex
503
+ return str.replace(/\x1b\[[0-9;]*m/g, '');
504
+ }
505
+
506
+ /**
507
+ * Check if a string ends with ANSI reset code
508
+ */
509
+ function endsWithReset(str: string): boolean {
510
+ return str.endsWith('\x1b[0m') || str.endsWith(COLORS.reset);
511
+ }
512
+
446
513
  /**
447
514
  * Wrap text to a maximum width
448
515
  * Handles explicit newlines and word wrapping
516
+ * Preserves ANSI color codes across wrapped lines
449
517
  */
450
518
  function wrapText(text: string, maxWidth: number): string[] {
451
519
  const allLines: string[] = [];
@@ -460,6 +528,13 @@ function wrapText(text: string, maxWidth: number): string[] {
460
528
  continue;
461
529
  }
462
530
 
531
+ // Record starting index for this paragraph's lines
532
+ const paragraphStart = allLines.length;
533
+
534
+ // Extract any leading ANSI codes from the paragraph
535
+ const leadingCodes = extractLeadingAnsiCodes(paragraph);
536
+ const hasReset = endsWithReset(paragraph);
537
+
463
538
  // Wrap each paragraph
464
539
  const words = paragraph.split(' ');
465
540
  let currentLine = '';
@@ -477,13 +552,30 @@ function wrapText(text: string, maxWidth: number): string[] {
477
552
  }
478
553
  // If the word itself is longer than maxWidth, just use it as is
479
554
  // (better to have a long line than break in the middle)
480
- currentLine = word;
555
+ // But if we have leading codes and this isn't the first line, apply them
556
+ if (leadingCodes && currentLine) {
557
+ // Strip any existing codes from the word to avoid duplication
558
+ const strippedWord = stripAnsiCodes(word);
559
+ currentLine = leadingCodes + strippedWord;
560
+ } else {
561
+ currentLine = word;
562
+ }
481
563
  }
482
564
  }
483
565
 
484
566
  if (currentLine) {
485
567
  allLines.push(currentLine);
486
568
  }
569
+
570
+ // If the original paragraph had ANSI codes and ended with reset,
571
+ // ensure each wrapped line ends with reset (only for this paragraph's lines)
572
+ if (leadingCodes && hasReset) {
573
+ for (let i = paragraphStart; i < allLines.length; i++) {
574
+ if (!endsWithReset(allLines[i])) {
575
+ allLines[i] += COLORS.reset;
576
+ }
577
+ }
578
+ }
487
579
  }
488
580
 
489
581
  return allLines.length > 0 ? allLines : [''];
@@ -658,6 +750,20 @@ export interface CommandRunnerOptions {
658
750
  * Defaults to false
659
751
  */
660
752
  clearOnSuccess?: boolean;
753
+ /**
754
+ * If true or undefined, will truncate each line of output
755
+ */
756
+ truncate?: boolean;
757
+
758
+ /**
759
+ * If undefined, will show up to 3 last lines of output while running. Customize the number with this property.
760
+ */
761
+ maxLinesOutput?: number;
762
+
763
+ /**
764
+ * If undefined, will show up to 10 last lines on failure. Customize the number with this property.
765
+ */
766
+ maxLinesOnFailure?: number;
661
767
  }
662
768
 
663
769
  /**
@@ -671,7 +777,16 @@ export interface CommandRunnerOptions {
671
777
  * Shows the last 3 lines of output as it streams.
672
778
  */
673
779
  export async function runCommand(options: CommandRunnerOptions): Promise<number> {
674
- const { command, cmd, cwd, env, clearOnSuccess = false } = options;
780
+ const {
781
+ command,
782
+ cmd,
783
+ cwd,
784
+ env,
785
+ clearOnSuccess = false,
786
+ truncate = true,
787
+ maxLinesOutput = 3,
788
+ maxLinesOnFailure = 10,
789
+ } = options;
675
790
  const isTTY = process.stdout.isTTY;
676
791
 
677
792
  // If not a TTY, just run the command normally and log output
@@ -746,7 +861,7 @@ export async function runCommand(options: CommandRunnerOptions): Promise<number>
746
861
  };
747
862
 
748
863
  // Initial display
749
- renderOutput(3);
864
+ renderOutput(maxLinesOutput);
750
865
 
751
866
  try {
752
867
  // Spawn the command
@@ -810,7 +925,7 @@ export async function runCommand(options: CommandRunnerOptions): Promise<number>
810
925
  );
811
926
  } else {
812
927
  // Determine how many lines to show in final output
813
- const finalLinesToShow = exitCode === 0 ? 3 : 10;
928
+ const finalLinesToShow = exitCode === 0 ? maxLinesOutput : maxLinesOnFailure;
814
929
 
815
930
  // Show final status with appropriate color
816
931
  const statusColor = exitCode === 0 ? green : red;
@@ -820,7 +935,7 @@ export async function runCommand(options: CommandRunnerOptions): Promise<number>
820
935
  const finalOutputLines = allOutputLines.slice(-finalLinesToShow);
821
936
  for (const line of finalOutputLines) {
822
937
  let displayLine = line;
823
- if (getDisplayWidth(displayLine) > maxLineWidth) {
938
+ if (truncate && getDisplayWidth(displayLine) > maxLineWidth) {
824
939
  displayLine = displayLine.slice(0, maxLineWidth - 3) + '...';
825
940
  }
826
941
  process.stdout.write(`\r\x1b[K${mutedColor}${displayLine}${reset}\n`);
package/src/types.ts CHANGED
@@ -150,6 +150,7 @@ export type CommandContext<
150
150
  // Helper to create subcommands with proper type inference
151
151
  export function createSubcommand<
152
152
  TRequiresAuth extends boolean,
153
+ TOptionalAuth extends boolean | string,
153
154
  TArgsSchema extends z.ZodType | undefined,
154
155
  TOptionsSchema extends z.ZodType | undefined,
155
156
  >(definition: {
@@ -158,6 +159,7 @@ export function createSubcommand<
158
159
  aliases?: string[];
159
160
  toplevel?: boolean;
160
161
  requiresAuth?: TRequiresAuth;
162
+ optionalAuth?: TOptionalAuth;
161
163
  schema?: TArgsSchema extends z.ZodType
162
164
  ? TOptionsSchema extends z.ZodType
163
165
  ? { args: TArgsSchema; options: TOptionsSchema }
@@ -166,7 +168,15 @@ export function createSubcommand<
166
168
  ? { options: TOptionsSchema }
167
169
  : never;
168
170
  handler(
169
- ctx: CommandContext<TRequiresAuth extends true ? true : false, TArgsSchema, TOptionsSchema>
171
+ ctx: CommandContext<
172
+ TRequiresAuth extends true
173
+ ? true
174
+ : TOptionalAuth extends true | string
175
+ ? true | false
176
+ : false,
177
+ TArgsSchema,
178
+ TOptionsSchema
179
+ >
170
180
  ): void | Promise<void>;
171
181
  }): SubcommandDefinition {
172
182
  return definition as unknown as SubcommandDefinition;
@@ -175,6 +185,7 @@ export function createSubcommand<
175
185
  // Helper to create commands with proper type inference
176
186
  export function createCommand<
177
187
  TRequiresAuth extends boolean,
188
+ TOptionalAuth extends boolean | string,
178
189
  TArgsSchema extends z.ZodType | undefined,
179
190
  TOptionsSchema extends z.ZodType | undefined,
180
191
  >(definition: {
@@ -183,6 +194,7 @@ export function createCommand<
183
194
  aliases?: string[];
184
195
  hidden?: boolean;
185
196
  requiresAuth?: TRequiresAuth;
197
+ optionalAuth?: TOptionalAuth;
186
198
  schema?: TArgsSchema extends z.ZodType
187
199
  ? TOptionsSchema extends z.ZodType
188
200
  ? { args: TArgsSchema; options: TOptionsSchema }
@@ -191,7 +203,15 @@ export function createCommand<
191
203
  ? { options: TOptionsSchema }
192
204
  : never;
193
205
  handler?(
194
- ctx: CommandContext<TRequiresAuth extends true ? true : false, TArgsSchema, TOptionsSchema>
206
+ ctx: CommandContext<
207
+ TRequiresAuth extends true
208
+ ? true
209
+ : TOptionalAuth extends true | string
210
+ ? true | false
211
+ : false,
212
+ TArgsSchema,
213
+ TOptionsSchema
214
+ >
195
215
  ): void | Promise<void>;
196
216
  subcommands?: SubcommandDefinition[];
197
217
  }): CommandDefinition {
@@ -206,6 +226,7 @@ export type SubcommandDefinition =
206
226
  aliases?: string[];
207
227
  toplevel?: boolean;
208
228
  requiresAuth: true;
229
+ optionalAuth?: false | string;
209
230
  schema?: CommandSchemas;
210
231
  handler(ctx: CommandContext): void | Promise<void>;
211
232
  }
@@ -215,6 +236,17 @@ export type SubcommandDefinition =
215
236
  aliases?: string[];
216
237
  toplevel?: boolean;
217
238
  requiresAuth?: false;
239
+ optionalAuth: true | string;
240
+ schema?: CommandSchemas;
241
+ handler(ctx: CommandContext): void | Promise<void>;
242
+ }
243
+ | {
244
+ name: string;
245
+ description: string;
246
+ aliases?: string[];
247
+ toplevel?: boolean;
248
+ requiresAuth?: false;
249
+ optionalAuth?: false;
218
250
  schema?: CommandSchemas;
219
251
  handler(ctx: CommandContext): void | Promise<void>;
220
252
  };
@@ -227,6 +259,18 @@ export type CommandDefinition =
227
259
  aliases?: string[];
228
260
  hidden?: boolean;
229
261
  requiresAuth: true;
262
+ optionalAuth?: false | string;
263
+ schema?: CommandSchemas;
264
+ handler?(ctx: CommandContext): void | Promise<void>;
265
+ subcommands?: SubcommandDefinition[];
266
+ }
267
+ | {
268
+ name: string;
269
+ description: string;
270
+ aliases?: string[];
271
+ hidden?: boolean;
272
+ requiresAuth?: false;
273
+ optionalAuth: true | string;
230
274
  schema?: CommandSchemas;
231
275
  handler?(ctx: CommandContext): void | Promise<void>;
232
276
  subcommands?: SubcommandDefinition[];
@@ -237,6 +281,7 @@ export type CommandDefinition =
237
281
  aliases?: string[];
238
282
  hidden?: boolean;
239
283
  requiresAuth?: false;
284
+ optionalAuth?: false;
240
285
  schema?: CommandSchemas;
241
286
  handler?(ctx: CommandContext): void | Promise<void>;
242
287
  subcommands?: SubcommandDefinition[];