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.
- package/dist/Cli.d.ts +9 -1
- package/dist/Cli.d.ts.map +1 -1
- package/dist/Cli.js +69 -35
- package/dist/Cli.js.map +1 -1
- package/dist/Completions.d.ts +3 -1
- package/dist/Completions.d.ts.map +1 -1
- package/dist/Completions.js +8 -1
- package/dist/Completions.js.map +1 -1
- package/dist/Mcp.d.ts.map +1 -1
- package/dist/Mcp.js +2 -0
- package/dist/Mcp.js.map +1 -1
- package/dist/Openapi.d.ts.map +1 -1
- package/dist/Openapi.js +2 -2
- package/dist/Openapi.js.map +1 -1
- package/dist/internal/command.d.ts +48 -0
- package/dist/internal/command.d.ts.map +1 -1
- package/dist/internal/command.js +9 -0
- package/dist/internal/command.js.map +1 -1
- package/dist/internal/dereference.d.ts +12 -0
- package/dist/internal/dereference.d.ts.map +1 -0
- package/dist/internal/dereference.js +71 -0
- package/dist/internal/dereference.js.map +1 -0
- package/package.json +1 -2
- package/src/Cli.test.ts +67 -0
- package/src/Cli.ts +88 -37
- package/src/Completions.ts +8 -2
- package/src/Mcp.ts +1 -0
- package/src/Openapi.ts +2 -2
- package/src/internal/command.ts +12 -0
- package/src/internal/dereference.test.ts +695 -0
- package/src/internal/dereference.ts +75 -0
package/src/Completions.ts
CHANGED
|
@@ -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
|
|
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
|
-
|
|
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 =
|
|
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
|
|
package/src/internal/command.ts
CHANGED
|
@@ -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
|
+
}
|