@xihan-ui/cli 0.0.0-stage → 5.0.0

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.
@@ -0,0 +1,213 @@
1
+ import { Readable, Writable } from "node:stream";
2
+ //#region src/cli.d.ts
3
+ /** 命令行的输入输出环境,缺省为当前进程。 */
4
+ interface CliEnvironment {
5
+ readonly stdout: (text: string) => void;
6
+ readonly stderr: (text: string) => void;
7
+ /** 离线数据目录,缺省为包内 data/。 */
8
+ readonly dataDir?: string;
9
+ /** 识别项目所用的目录,缺省为 process.cwd()。 */
10
+ readonly cwd?: string;
11
+ }
12
+ /** 运行一次命令行,返回退出码;mcp 命令在输入流结束后返回。 */
13
+ declare function runCli(argv: readonly string[], environment?: Partial<CliEnvironment>): Promise<number>;
14
+ //#endregion
15
+ //#region src/knowledge.d.ts
16
+ /** 示例与文档可选的三种写法。 */
17
+ type Framework = 'vue' | 'react' | 'web-components';
18
+ interface FieldRow {
19
+ readonly name: string;
20
+ readonly type: string;
21
+ readonly optional: boolean;
22
+ readonly doc: string;
23
+ }
24
+ interface AttributeRow {
25
+ readonly part: string;
26
+ readonly attr: string;
27
+ readonly value: string;
28
+ }
29
+ interface ComponentToken {
30
+ readonly name: string;
31
+ readonly part: readonly string[];
32
+ readonly property: readonly string[];
33
+ readonly state: readonly string[];
34
+ readonly defaultToken: readonly string[];
35
+ readonly description: string;
36
+ }
37
+ interface DemoEntry {
38
+ readonly src: string;
39
+ readonly title: string;
40
+ readonly description: string;
41
+ }
42
+ interface ComponentEntry {
43
+ readonly id: string;
44
+ readonly name: string;
45
+ readonly title: string;
46
+ readonly category: string;
47
+ readonly categoryLabel: string;
48
+ readonly status: string | null;
49
+ readonly overview: string | null;
50
+ readonly guidance: Readonly<Record<string, string>>;
51
+ readonly artifacts: {
52
+ readonly components: readonly string[];
53
+ readonly composable: string | null;
54
+ readonly tag: string | null;
55
+ readonly machine: string | null;
56
+ readonly skin: string | null;
57
+ };
58
+ readonly parts: readonly string[];
59
+ readonly requiredParts: readonly string[];
60
+ readonly props: readonly FieldRow[];
61
+ readonly nodes: readonly {
62
+ readonly name: string;
63
+ readonly via: string;
64
+ readonly fields: readonly FieldRow[];
65
+ }[];
66
+ readonly events: readonly {
67
+ readonly name: string;
68
+ readonly type: string;
69
+ readonly description: string;
70
+ }[];
71
+ readonly slots: readonly {
72
+ readonly component: string;
73
+ readonly name: string;
74
+ readonly optional: boolean;
75
+ readonly payload: string;
76
+ readonly doc: string;
77
+ }[];
78
+ readonly reactProps: readonly (FieldRow & {
79
+ readonly component: string;
80
+ })[];
81
+ readonly machine: {
82
+ readonly states: readonly string[] | null;
83
+ readonly events: readonly string[] | null;
84
+ readonly guards: readonly string[] | null;
85
+ };
86
+ readonly api: readonly {
87
+ readonly name: string;
88
+ readonly type: string;
89
+ readonly doc: string;
90
+ }[];
91
+ readonly keyboard: {
92
+ readonly source: string;
93
+ readonly rows: readonly {
94
+ readonly keys: readonly string[];
95
+ readonly when: string;
96
+ readonly does: string;
97
+ }[];
98
+ };
99
+ readonly aria: readonly AttributeRow[];
100
+ readonly dataAttributes: readonly AttributeRow[];
101
+ readonly componentTokens: readonly ComponentToken[];
102
+ readonly demos: readonly DemoEntry[];
103
+ }
104
+ interface CategoryEntry {
105
+ readonly id: string;
106
+ readonly label: string;
107
+ readonly description: string;
108
+ }
109
+ interface PageEntry {
110
+ /** 站内路径,不带扩展名,如 `guide/theme`、`components/select`。 */
111
+ readonly path: string;
112
+ readonly title: string;
113
+ readonly summary: string;
114
+ readonly markdown: string;
115
+ }
116
+ interface TokenEntry {
117
+ readonly name: string;
118
+ readonly type: string;
119
+ /** tokens.json 里的原始取值,可能引用别的令牌。 */
120
+ readonly value: string;
121
+ /** 沿 var() 展开后的取值。 */
122
+ readonly resolved: string;
123
+ /** 除缺省档外还改写过它的令牌源。 */
124
+ readonly layers: readonly string[];
125
+ }
126
+ interface TokenData {
127
+ readonly tokens: readonly TokenEntry[];
128
+ /** 只在 data-tone 作用域里有取值的语气族令牌。 */
129
+ readonly tone: readonly string[];
130
+ }
131
+ interface Meta {
132
+ readonly version: string;
133
+ readonly site: string;
134
+ }
135
+ /** 示例源码:键是示例路径(如 `select/01-basic`),值是各写法的源码。 */
136
+ type DemoSources = Readonly<Record<string, Partial<Record<Framework, string>>>>;
137
+ interface Knowledge {
138
+ readonly meta: Meta;
139
+ readonly categories: readonly CategoryEntry[];
140
+ readonly components: readonly ComponentEntry[];
141
+ pages: () => readonly PageEntry[];
142
+ demos: () => DemoSources;
143
+ tokens: () => TokenData;
144
+ designMd: () => string;
145
+ changelog: () => string;
146
+ }
147
+ /** 从数据目录读出全部知识;大文件在首次用到时才读。 */
148
+ declare function loadKnowledge(dataDir?: string): Knowledge;
149
+ //#endregion
150
+ //#region src/tools.d.ts
151
+ interface ToolContext {
152
+ readonly knowledge: Knowledge;
153
+ /** 未指定写法时使用的写法:项目里识别到的适配器,识别不到时是 Vue。 */
154
+ readonly framework: Framework;
155
+ }
156
+ type Args = Readonly<Record<string, unknown>>;
157
+ interface JsonSchema {
158
+ readonly type: 'object';
159
+ readonly properties: Readonly<Record<string, Readonly<Record<string, unknown>>>>;
160
+ readonly required?: readonly string[];
161
+ readonly additionalProperties: false;
162
+ }
163
+ interface ToolDefinition {
164
+ readonly name: string;
165
+ readonly title: string;
166
+ readonly description: string;
167
+ readonly inputSchema: JsonSchema;
168
+ readonly run: (args: Args, context: ToolContext) => string;
169
+ }
170
+ declare const TOOLS: readonly ToolDefinition[];
171
+ interface PromptArgument {
172
+ readonly name: string;
173
+ readonly description: string;
174
+ readonly required: boolean;
175
+ }
176
+ interface PromptDefinition {
177
+ readonly name: string;
178
+ readonly title: string;
179
+ readonly description: string;
180
+ readonly arguments: readonly PromptArgument[];
181
+ readonly render: (args: Readonly<Record<string, string>>, context: ToolContext) => string;
182
+ }
183
+ declare const PROMPTS: readonly PromptDefinition[];
184
+ //#endregion
185
+ //#region src/mcp.d.ts
186
+ /** 按新到旧排列的受支持协议版本。 */
187
+ declare const PROTOCOL_VERSIONS: readonly ["2025-11-25", "2025-06-18", "2025-03-26", "2024-11-05"];
188
+ type Id = string | number;
189
+ type Response = {
190
+ jsonrpc: '2.0';
191
+ id: Id | null;
192
+ result: unknown;
193
+ } | {
194
+ jsonrpc: '2.0';
195
+ id: Id | null;
196
+ error: {
197
+ code: number;
198
+ message: string;
199
+ };
200
+ };
201
+ interface McpServerOptions {
202
+ readonly context: ToolContext;
203
+ readonly version: string;
204
+ /** 写进 initialize 结果的使用说明。 */
205
+ readonly instructions: string;
206
+ }
207
+ /** 处理一条请求;通知(不带 id)返回 undefined。 */
208
+ declare function handleMessage(message: unknown, options: McpServerOptions): Response | undefined;
209
+ /** 在给定的输入输出流上运行服务端,输入结束时返回。 */
210
+ declare function serveStdio(options: McpServerOptions, input?: Readable, output?: Writable): Promise<void>;
211
+ //#endregion
212
+ export { type CliEnvironment, type ComponentEntry, type Framework, type Knowledge, type McpServerOptions, PROMPTS, PROTOCOL_VERSIONS, type PageEntry, type PromptDefinition, TOOLS, type TokenEntry, type ToolContext, type ToolDefinition, handleMessage, loadKnowledge, runCli, serveStdio };
213
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/cli.ts","../src/knowledge.ts","../src/tools.ts","../src/mcp.ts"],"mappings":";;;UAiDiB;WACN,SAAS;WACT,SAAS;;WAET;;WAEA;;;iBA6GW,OAAO,yBAAyB,cAAa,QAAQ,kBAAuB;;;;KCxJtF;UAIK;WACN;WACA;WACA;WACA;;UAGM;WACN;WACA;WACA;;UAGM;WACN;WACA;WACA;WACA;WACA;WACA;;UAGM;WACN;WACA;WACA;;UAGM;WACN;WACA;WACA;WACA;WACA;WACA;WACA;WACA,UAAU,SAAS;WACnB;aACE;aACA;aACA;aACA;aACA;;WAEF;WACA;WACA,gBAAgB;WAChB;aAA2B;aAAuB;aAAsB,iBAAiB;;WACzF;aAA4B;aAAuB;a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