incur 0.3.22 → 0.3.24

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.
@@ -12,14 +12,16 @@ export type Candidate = {
12
12
  value: string
13
13
  }
14
14
 
15
- /** @internal Entry stored in a command map — either a leaf definition or a group. */
15
+ /** @internal Entry stored in a command map — either a leaf definition, a group, or an alias. */
16
16
  type CommandEntry = {
17
+ _alias?: true | undefined
17
18
  _group?: true | undefined
18
19
  alias?: Record<string, string | undefined> | undefined
19
20
  args?: z.ZodObject<any> | undefined
20
21
  commands?: Map<string, CommandEntry> | undefined
21
22
  description?: string | undefined
22
23
  options?: z.ZodObject<any> | undefined
24
+ target?: string | undefined
23
25
  }
24
26
 
25
27
  /**
@@ -61,7 +63,10 @@ export function complete(
61
63
  for (let i = 0; i < index; i++) {
62
64
  const token = argv[i]!
63
65
  if (token.startsWith('-')) continue
64
- const entry = scope.commands.get(token)
66
+ let entry = scope.commands.get(token)
67
+ if (!entry) continue
68
+ // Follow alias to canonical entry
69
+ if (entry._alias && entry.target) entry = scope.commands.get(entry.target)
65
70
  if (!entry) continue
66
71
  if (entry._group && entry.commands) {
67
72
  scope = { commands: entry.commands }
@@ -116,6 +121,7 @@ export function complete(
116
121
 
117
122
  // Suggest subcommands (groups get noSpace so user can keep typing subcommand)
118
123
  for (const [name, entry] of scope.commands) {
124
+ if (entry._alias) continue
119
125
  if (name.startsWith(current))
120
126
  candidates.push({
121
127
  value: name,
package/src/Mcp.ts CHANGED
@@ -173,6 +173,7 @@ export function collectTools(
173
173
  ): ToolEntry[] {
174
174
  const result: ToolEntry[] = []
175
175
  for (const [name, entry] of commands) {
176
+ if ('_alias' in entry) continue
176
177
  const path = [...prefix, name]
177
178
  if ('_group' in entry && entry._group) {
178
179
  const groupMw = [
package/src/Openapi.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { dereference } from '@readme/openapi-parser'
2
1
  import { z } from 'zod'
3
2
 
4
3
  import * as Fetch from './Fetch.js'
4
+ import { dereference } from './internal/dereference.js'
5
5
 
6
6
  /** A minimal OpenAPI 3.x spec shape. Accepts both hand-written specs and generated ones (e.g. from `@hono/zod-openapi`). */
7
7
  export type OpenAPISpec = { paths?: {} | undefined }
@@ -46,7 +46,7 @@ export async function generateCommands(
46
46
  fetch: FetchHandler,
47
47
  options: { basePath?: string | undefined } = {},
48
48
  ): Promise<Map<string, GeneratedCommand>> {
49
- const resolved = (await dereference(structuredClone(spec) as any)) as unknown as OpenAPISpec
49
+ const resolved = dereference(structuredClone(spec)) as OpenAPISpec
50
50
  const commands = new Map<string, GeneratedCommand>()
51
51
  const paths = (resolved.paths ?? {}) as Record<string, Record<string, unknown>>
52
52
 
@@ -412,6 +412,7 @@ export const builtinCommands = [
412
412
  },
413
413
  {
414
414
  name: 'skills',
415
+ aliases: ['skill'],
415
416
  description: 'Sync skill files to agents',
416
417
  subcommands: [
417
418
  subcommand({
@@ -430,8 +431,19 @@ export const builtinCommands = [
430
431
  },
431
432
  ] satisfies {
432
433
  name: string
434
+ aliases?: string[] | undefined
433
435
  args?: z.ZodObject<any> | undefined
434
436
  description: string
435
437
  hint?: ((name: string) => string) | undefined
436
438
  subcommands?: (CommandMeta<z.ZodObject<any>> & { name: string })[] | undefined
437
439
  }[]
440
+
441
+ /** @internal Finds a builtin command by its name or alias. */
442
+ export function findBuiltin(token: string) {
443
+ return builtinCommands.find((b) => b.name === token || b.aliases?.includes(token))
444
+ }
445
+
446
+ /** @internal Checks if a token matches a builtin command by name or alias. */
447
+ export function isBuiltin(token: string) {
448
+ return builtinCommands.some((b) => b.name === token || b.aliases?.includes(token))
449
+ }