incur 0.4.1 → 0.4.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.
@@ -350,9 +350,16 @@ export type CommandMeta<options extends z.ZodObject<any> | undefined = undefined
350
350
  options?: options | undefined
351
351
  }
352
352
 
353
+ /** @internal Metadata for a built-in subcommand. */
354
+ type BuiltinSubcommandMeta<options extends z.ZodObject<any> | undefined = undefined> =
355
+ CommandMeta<options> & {
356
+ /** Alternative names for this built-in subcommand. */
357
+ aliases?: string[] | undefined
358
+ }
359
+
353
360
  /** @internal Creates a builtin subcommand with typesafe alias inference. */
354
361
  function subcommand<const options extends z.ZodObject<any> | undefined = undefined>(
355
- def: CommandMeta<options> & { name: string },
362
+ def: BuiltinSubcommandMeta<options> & { name: string },
356
363
  ) {
357
364
  return def
358
365
  }
@@ -425,6 +432,7 @@ export const builtinCommands = [
425
432
  }),
426
433
  subcommand({
427
434
  name: 'list',
435
+ aliases: ['ls'],
428
436
  description: 'List skills',
429
437
  }),
430
438
  ],
@@ -435,7 +443,7 @@ export const builtinCommands = [
435
443
  args?: z.ZodObject<any> | undefined
436
444
  description: string
437
445
  hint?: ((name: string) => string) | undefined
438
- subcommands?: (CommandMeta<z.ZodObject<any>> & { name: string })[] | undefined
446
+ subcommands?: (BuiltinSubcommandMeta<z.ZodObject<any>> & { name: string })[] | undefined
439
447
  }[]
440
448
 
441
449
  /** @internal Finds a builtin command by its name or alias. */
@@ -443,6 +451,11 @@ export function findBuiltin(token: string) {
443
451
  return builtinCommands.find((b) => b.name === token || b.aliases?.includes(token))
444
452
  }
445
453
 
454
+ /** @internal Finds a builtin subcommand by its name or alias. */
455
+ export function findBuiltinSubcommand(builtin: (typeof builtinCommands)[number], token: string) {
456
+ return builtin.subcommands?.find((sub) => sub.name === token || sub.aliases?.includes(token))
457
+ }
458
+
446
459
  /** @internal Checks if a token matches a builtin command by name or alias. */
447
460
  export function isBuiltin(token: string) {
448
461
  return builtinCommands.some((b) => b.name === token || b.aliases?.includes(token))