/** * @author jasonHzq * @description Spec 作用域命令注册 + 轻量级 spec 信息加载 * * 架构设计: * - loadSpecInfos: 优先从 completion manifest 缓存读取 spec 名称和 hasTags 信息(~5ms), * fallback 到静默加载 PontxManager * - registerSpecCommands: 在给定的 Commander 父命令下注册所有 spec 作用域子命令 * (call, show-api, gen, show-schema, search, list-cases, list) */ import type { Command } from "commander"; import type { CliContext } from "./context.d.ts"; /** * Tag 摘要信息 */ export interface TagSummary { name: string; description?: string; apiCount: number; } /** * API 摘要信息 */ export interface ApiSummary { /** 如 "pet/getPetById" 或 "getPetById" */ key: string; /** 纯 API 名 */ name: string; tag?: string; description?: string; method?: string; apiPath?: string; params?: ParamSummary[]; } /** * API 参数摘要 */ export interface ParamSummary { name: string; type: string; required: boolean; description?: string; enum?: string[]; in?: string; } /** * Spec 基本信息(用于动态注册子命令) */ export interface SpecInfo { name: string; hasTags: boolean; description?: string; /** 预加载的 tag 摘要(用于 -h 上下文帮助) */ tags?: TagSummary[]; /** 预加载的 API 摘要(用于 -h 上下文帮助) */ apis?: ApiSummary[]; } /** * 轻量级加载 spec 信息 * 优先从 completion manifest 缓存读取,fallback 到静默加载 manager */ export declare function loadSpecInfos(rootDir: string): Promise; export interface RegisterSpecCommandsOptions { /** 跳过 list 命令注册(用于单 spec 根级别,避免与全局 list 冲突) */ skipList?: boolean; } /** * 在给定的 Commander 父命令下注册所有 spec 作用域命令 */ export declare function registerSpecCommands(parent: Command, specInfo: SpecInfo, ctx: CliContext, options?: RegisterSpecCommandsOptions): void;