@hithink-tech/hithink-finance-cli 0.1.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.
Files changed (203) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/LICENSE +21 -0
  3. package/README.md +161 -0
  4. package/SECURITY.md +3 -0
  5. package/dist/application/config.d.ts +44 -0
  6. package/dist/application/config.js +111 -0
  7. package/dist/application/ports/auth-provider.d.ts +23 -0
  8. package/dist/application/ports/auth-provider.js +2 -0
  9. package/dist/application/source-policy.d.ts +13 -0
  10. package/dist/application/source-policy.js +31 -0
  11. package/dist/application/use-cases/data-clean.d.ts +2 -0
  12. package/dist/application/use-cases/data-clean.js +18 -0
  13. package/dist/application/use-cases/data-init.d.ts +4 -0
  14. package/dist/application/use-cases/data-init.js +9 -0
  15. package/dist/application/use-cases/data-remove.d.ts +2 -0
  16. package/dist/application/use-cases/data-remove.js +27 -0
  17. package/dist/application/use-cases/data-repair.d.ts +5 -0
  18. package/dist/application/use-cases/data-repair.js +5 -0
  19. package/dist/application/use-cases/data-sync.d.ts +25 -0
  20. package/dist/application/use-cases/data-sync.js +55 -0
  21. package/dist/application/use-cases/local-query.d.ts +4 -0
  22. package/dist/application/use-cases/local-query.js +88 -0
  23. package/dist/application/use-cases/market-history.d.ts +8 -0
  24. package/dist/application/use-cases/market-history.js +16 -0
  25. package/dist/application/use-cases/market-panel.d.ts +3 -0
  26. package/dist/application/use-cases/market-panel.js +5 -0
  27. package/dist/application/use-cases/remote-query.d.ts +4 -0
  28. package/dist/application/use-cases/remote-query.js +66 -0
  29. package/dist/cli/context.d.ts +17 -0
  30. package/dist/cli/context.js +52 -0
  31. package/dist/cli/i18n.d.ts +23 -0
  32. package/dist/cli/i18n.js +150 -0
  33. package/dist/cli/main.d.ts +3 -0
  34. package/dist/cli/main.js +80 -0
  35. package/dist/cli/program.d.ts +20 -0
  36. package/dist/cli/program.js +111 -0
  37. package/dist/commands/auth/index.d.ts +10 -0
  38. package/dist/commands/auth/index.js +131 -0
  39. package/dist/commands/config/index.d.ts +13 -0
  40. package/dist/commands/config/index.js +26 -0
  41. package/dist/commands/data/index.d.ts +10 -0
  42. package/dist/commands/data/index.js +185 -0
  43. package/dist/commands/db/index.d.ts +4 -0
  44. package/dist/commands/db/index.js +72 -0
  45. package/dist/commands/financials/index.d.ts +5 -0
  46. package/dist/commands/financials/index.js +6 -0
  47. package/dist/commands/index/index.d.ts +5 -0
  48. package/dist/commands/index/index.js +6 -0
  49. package/dist/commands/market/index.d.ts +5 -0
  50. package/dist/commands/market/index.js +6 -0
  51. package/dist/commands/market/local.d.ts +4 -0
  52. package/dist/commands/market/local.js +97 -0
  53. package/dist/commands/remote.d.ts +11 -0
  54. package/dist/commands/remote.js +195 -0
  55. package/dist/commands/skills/index.d.ts +4 -0
  56. package/dist/commands/skills/index.js +43 -0
  57. package/dist/commands/special/index.d.ts +5 -0
  58. package/dist/commands/special/index.js +6 -0
  59. package/dist/commands/symbol/index.d.ts +5 -0
  60. package/dist/commands/symbol/index.js +6 -0
  61. package/dist/commands/system/capabilities.d.ts +4 -0
  62. package/dist/commands/system/capabilities.js +24 -0
  63. package/dist/commands/system/doctor.d.ts +4 -0
  64. package/dist/commands/system/doctor.js +15 -0
  65. package/dist/commands/system/schema.d.ts +4 -0
  66. package/dist/commands/system/schema.js +47 -0
  67. package/dist/commands/system/uninstall.d.ts +11 -0
  68. package/dist/commands/system/uninstall.js +68 -0
  69. package/dist/commands/system/update.d.ts +11 -0
  70. package/dist/commands/system/update.js +72 -0
  71. package/dist/contracts/envelope.d.ts +37 -0
  72. package/dist/contracts/envelope.js +36 -0
  73. package/dist/contracts/errors.d.ts +23 -0
  74. package/dist/contracts/errors.js +33 -0
  75. package/dist/contracts/local-capabilities.d.ts +13 -0
  76. package/dist/contracts/local-capabilities.js +37 -0
  77. package/dist/contracts/registry.d.ts +9 -0
  78. package/dist/contracts/registry.js +4 -0
  79. package/dist/contracts/remote-capabilities.d.ts +24 -0
  80. package/dist/contracts/remote-capabilities.js +667 -0
  81. package/dist/domains/financials/types.d.ts +6 -0
  82. package/dist/domains/financials/types.js +2 -0
  83. package/dist/domains/index/types.d.ts +6 -0
  84. package/dist/domains/index/types.js +2 -0
  85. package/dist/domains/market/types.d.ts +6 -0
  86. package/dist/domains/market/types.js +2 -0
  87. package/dist/domains/special/types.d.ts +5 -0
  88. package/dist/domains/special/types.js +2 -0
  89. package/dist/domains/symbol/types.d.ts +6 -0
  90. package/dist/domains/symbol/types.js +2 -0
  91. package/dist/infrastructure/credentials/api-key-provider.d.ts +14 -0
  92. package/dist/infrastructure/credentials/api-key-provider.js +102 -0
  93. package/dist/infrastructure/credentials/keyring.d.ts +15 -0
  94. package/dist/infrastructure/credentials/keyring.js +21 -0
  95. package/dist/infrastructure/credentials/redact.d.ts +3 -0
  96. package/dist/infrastructure/credentials/redact.js +26 -0
  97. package/dist/infrastructure/duckdb/connection.d.ts +8 -0
  98. package/dist/infrastructure/duckdb/connection.js +18 -0
  99. package/dist/infrastructure/duckdb/dump-client.d.ts +20 -0
  100. package/dist/infrastructure/duckdb/dump-client.js +66 -0
  101. package/dist/infrastructure/duckdb/factors.d.ts +3 -0
  102. package/dist/infrastructure/duckdb/factors.js +83 -0
  103. package/dist/infrastructure/duckdb/importer.d.ts +11 -0
  104. package/dist/infrastructure/duckdb/importer.js +105 -0
  105. package/dist/infrastructure/duckdb/migrations.d.ts +17 -0
  106. package/dist/infrastructure/duckdb/migrations.js +92 -0
  107. package/dist/infrastructure/duckdb/quality.d.ts +12 -0
  108. package/dist/infrastructure/duckdb/quality.js +56 -0
  109. package/dist/infrastructure/duckdb/schema.d.ts +4 -0
  110. package/dist/infrastructure/duckdb/schema.js +14 -0
  111. package/dist/infrastructure/filesystem/atomic-file.d.ts +2 -0
  112. package/dist/infrastructure/filesystem/atomic-file.js +38 -0
  113. package/dist/infrastructure/filesystem/platform-paths.d.ts +15 -0
  114. package/dist/infrastructure/filesystem/platform-paths.js +42 -0
  115. package/dist/infrastructure/filesystem/process-lock.d.ts +6 -0
  116. package/dist/infrastructure/filesystem/process-lock.js +56 -0
  117. package/dist/infrastructure/filesystem/stdin.d.ts +5 -0
  118. package/dist/infrastructure/filesystem/stdin.js +9 -0
  119. package/dist/infrastructure/fuyao/client.d.ts +31 -0
  120. package/dist/infrastructure/fuyao/client.js +145 -0
  121. package/dist/infrastructure/fuyao/envelope.d.ts +9 -0
  122. package/dist/infrastructure/fuyao/envelope.js +8 -0
  123. package/dist/infrastructure/fuyao/pagination.d.ts +16 -0
  124. package/dist/infrastructure/fuyao/pagination.js +44 -0
  125. package/dist/infrastructure/fuyao/retry.d.ts +5 -0
  126. package/dist/infrastructure/fuyao/retry.js +18 -0
  127. package/dist/infrastructure/fuyao/windowing.d.ts +8 -0
  128. package/dist/infrastructure/fuyao/windowing.js +25 -0
  129. package/dist/infrastructure/skills/drift.d.ts +3 -0
  130. package/dist/infrastructure/skills/drift.js +8 -0
  131. package/dist/infrastructure/skills/installer.d.ts +13 -0
  132. package/dist/infrastructure/skills/installer.js +48 -0
  133. package/dist/infrastructure/skills/manifest.d.ts +11 -0
  134. package/dist/infrastructure/skills/manifest.js +62 -0
  135. package/dist/infrastructure/updater/cache.d.ts +15 -0
  136. package/dist/infrastructure/updater/cache.js +76 -0
  137. package/dist/infrastructure/updater/check.d.ts +13 -0
  138. package/dist/infrastructure/updater/check.js +51 -0
  139. package/dist/infrastructure/updater/install.d.ts +4 -0
  140. package/dist/infrastructure/updater/install.js +39 -0
  141. package/dist/output/json.d.ts +3 -0
  142. package/dist/output/json.js +16 -0
  143. package/dist/output/renderer.d.ts +4 -0
  144. package/dist/output/renderer.js +47 -0
  145. package/dist/output/table.d.ts +2 -0
  146. package/dist/output/table.js +31 -0
  147. package/migrations/001-initial.sql +95 -0
  148. package/migrations/manifest.json +12 -0
  149. package/package.json +66 -0
  150. package/schemas/capabilities.json +290 -0
  151. package/schemas/command-envelope.schema.json +12 -0
  152. package/scripts/postinstall.mjs +27 -0
  153. package/scripts/update-check.mjs +23 -0
  154. package/skills/hithink-finance-data/SKILL.md +74 -0
  155. package/skills/hithink-finance-data/references/data-clean.md +33 -0
  156. package/skills/hithink-finance-data/references/data-init.md +35 -0
  157. package/skills/hithink-finance-data/references/data-migrate.md +33 -0
  158. package/skills/hithink-finance-data/references/data-remove.md +33 -0
  159. package/skills/hithink-finance-data/references/data-repair.md +33 -0
  160. package/skills/hithink-finance-data/references/data-status.md +33 -0
  161. package/skills/hithink-finance-data/references/data-sync.md +34 -0
  162. package/skills/hithink-finance-data/references/data-validate.md +33 -0
  163. package/skills/hithink-finance-data/references/db-describe.md +33 -0
  164. package/skills/hithink-finance-data/references/db-export.md +33 -0
  165. package/skills/hithink-finance-data/references/db-query.md +33 -0
  166. package/skills/hithink-finance-financials/SKILL.md +59 -0
  167. package/skills/hithink-finance-financials/references/financials-balance-sheet.md +40 -0
  168. package/skills/hithink-finance-financials/references/financials-cash-flow.md +40 -0
  169. package/skills/hithink-finance-financials/references/financials-income.md +40 -0
  170. package/skills/hithink-finance-financials/references/financials-indicators.md +37 -0
  171. package/skills/hithink-finance-index/SKILL.md +59 -0
  172. package/skills/hithink-finance-index/references/index-catalog.md +36 -0
  173. package/skills/hithink-finance-index/references/index-constituents.md +36 -0
  174. package/skills/hithink-finance-index/references/index-history.md +38 -0
  175. package/skills/hithink-finance-index/references/index-snapshot.md +37 -0
  176. package/skills/hithink-finance-market/SKILL.md +63 -0
  177. package/skills/hithink-finance-market/references/market-adjustment-factors.md +33 -0
  178. package/skills/hithink-finance-market/references/market-calendar.md +35 -0
  179. package/skills/hithink-finance-market/references/market-corporate-actions.md +38 -0
  180. package/skills/hithink-finance-market/references/market-history.md +39 -0
  181. package/skills/hithink-finance-market/references/market-panel.md +33 -0
  182. package/skills/hithink-finance-market/references/market-snapshot.md +39 -0
  183. package/skills/hithink-finance-research/SKILL.md +58 -0
  184. package/skills/hithink-finance-research/references/research-workflow.md +34 -0
  185. package/skills/hithink-finance-shared/SKILL.md +55 -0
  186. package/skills/hithink-finance-shared/references/auth-and-config.md +31 -0
  187. package/skills/hithink-finance-shared/references/global-rules.md +21 -0
  188. package/skills/hithink-finance-shared/references/lifecycle.md +23 -0
  189. package/skills/hithink-finance-shared/references/skills-management.md +22 -0
  190. package/skills/hithink-finance-special-data/SKILL.md +68 -0
  191. package/skills/hithink-finance-special-data/references/special-anomaly-list.md +36 -0
  192. package/skills/hithink-finance-special-data/references/special-anomaly-stock.md +37 -0
  193. package/skills/hithink-finance-special-data/references/special-dragon-tiger.md +37 -0
  194. package/skills/hithink-finance-special-data/references/special-hot-stock-history.md +36 -0
  195. package/skills/hithink-finance-special-data/references/special-hot-stock-trend.md +38 -0
  196. package/skills/hithink-finance-special-data/references/special-hot-stock.md +36 -0
  197. package/skills/hithink-finance-special-data/references/special-limit-up-ladder.md +35 -0
  198. package/skills/hithink-finance-special-data/references/special-limit-up-pool.md +40 -0
  199. package/skills/hithink-finance-special-data/references/special-skyrocket.md +36 -0
  200. package/skills/hithink-finance-symbol/SKILL.md +56 -0
  201. package/skills/hithink-finance-symbol/references/symbol-list.md +39 -0
  202. package/skills/hithink-finance-symbol/references/symbol-search.md +39 -0
  203. package/skills/manifest.json +55 -0
@@ -0,0 +1,667 @@
1
+ import { z } from 'zod';
2
+ const isoDate = z.string().regex(/^\d{4}-\d{2}-\d{2}$/u);
3
+ const aShareCode = z.string().regex(/^\d{6}\.(SH|SZ|BJ)$/iu);
4
+ const indexCode = z.string().regex(/^\d{6}\.(SH|SZ|BJ|TI)$/iu);
5
+ const commaCodes = z.string().min(1);
6
+ const record = z.record(z.string(), z.unknown());
7
+ const itemOutput = z.object({ item: z.array(record) }).passthrough();
8
+ const objectOutput = z.object({}).passthrough();
9
+ const historyInput = z
10
+ .object({
11
+ thscode: aShareCode,
12
+ startMs: z.number().int().nonnegative(),
13
+ endMs: z.number().int().nonnegative(),
14
+ adjust: z.enum(['none', 'forward', 'backward']).default('forward'),
15
+ })
16
+ .strict()
17
+ .refine((value) => value.endMs >= value.startMs, { message: 'end-ms must be >= start-ms' });
18
+ const indexHistoryInput = z
19
+ .object({
20
+ thscode: indexCode,
21
+ startMs: z.number().int().nonnegative(),
22
+ endMs: z.number().int().nonnegative(),
23
+ })
24
+ .strict()
25
+ .refine((value) => value.endMs >= value.startMs, { message: 'end-ms must be >= start-ms' });
26
+ const financialInput = z
27
+ .object({
28
+ thscode: aShareCode,
29
+ period: z.enum(['annual', 'quarterly']).default('annual'),
30
+ limit: z.number().int().min(1).max(20).optional(),
31
+ startMs: z.number().int().nonnegative().optional(),
32
+ endMs: z.number().int().nonnegative().optional(),
33
+ })
34
+ .strict()
35
+ .superRefine((value, context) => {
36
+ const hasStart = value.startMs !== undefined;
37
+ const hasEnd = value.endMs !== undefined;
38
+ if (hasStart !== hasEnd) {
39
+ context.addIssue({
40
+ code: 'custom',
41
+ message: 'start-ms and end-ms must be provided together',
42
+ });
43
+ }
44
+ if ((hasStart || hasEnd) && value.limit !== undefined) {
45
+ context.addIssue({ code: 'custom', message: 'limit and date range are mutually exclusive' });
46
+ }
47
+ if (hasStart && hasEnd && value.endMs < value.startMs) {
48
+ context.addIssue({ code: 'custom', message: 'end-ms must be >= start-ms' });
49
+ }
50
+ });
51
+ const financialOptions = [
52
+ {
53
+ flags: '--thscode <code>',
54
+ description: 'single A-share thscode',
55
+ type: 'string',
56
+ required: true,
57
+ },
58
+ {
59
+ flags: '--period <period>',
60
+ description: 'financial period',
61
+ type: 'string',
62
+ choices: ['annual', 'quarterly'],
63
+ defaultValue: 'annual',
64
+ },
65
+ { flags: '--limit <number>', description: 'recent report count (1-20)', type: 'integer' },
66
+ {
67
+ flags: '--start-ms <milliseconds>',
68
+ description: 'range start in milliseconds',
69
+ type: 'integer',
70
+ queryName: 'start',
71
+ },
72
+ {
73
+ flags: '--end-ms <milliseconds>',
74
+ description: 'range end in milliseconds',
75
+ type: 'integer',
76
+ queryName: 'end',
77
+ },
78
+ ];
79
+ function financial(id, command, endpoint) {
80
+ return {
81
+ id,
82
+ command: ['financials', command],
83
+ description: `Query ${command} financial statements`,
84
+ endpoint,
85
+ method: 'GET',
86
+ inputSchema: financialInput,
87
+ outputSchema: itemOutput,
88
+ options: financialOptions,
89
+ paging: 'none',
90
+ window: 'ten-years',
91
+ };
92
+ }
93
+ export const remoteCapabilities = [
94
+ {
95
+ id: 'symbol.search',
96
+ command: ['symbol', 'search'],
97
+ description: 'Resolve a name or code to thscode',
98
+ endpoint: '/api/meta/tickers/search',
99
+ method: 'GET',
100
+ inputSchema: z
101
+ .object({
102
+ q: z.string().min(1),
103
+ exchange: z.enum(['SH', 'SZ', 'BJ']).optional(),
104
+ assetType: z.enum(['a-share', 'a-share-index']).optional(),
105
+ limit: z.number().int().min(1).max(50).default(10),
106
+ })
107
+ .strict(),
108
+ outputSchema: itemOutput,
109
+ options: [
110
+ {
111
+ flags: '--q <query>',
112
+ description: 'name, ticker, or thscode',
113
+ type: 'string',
114
+ required: true,
115
+ },
116
+ {
117
+ flags: '--exchange <exchange>',
118
+ description: 'exchange filter',
119
+ type: 'string',
120
+ choices: ['SH', 'SZ', 'BJ'],
121
+ },
122
+ {
123
+ flags: '--asset-type <type>',
124
+ description: 'asset type',
125
+ type: 'string',
126
+ choices: ['a-share', 'a-share-index'],
127
+ queryName: 'asset_type',
128
+ },
129
+ {
130
+ flags: '--limit <number>',
131
+ description: 'maximum matches (1-50)',
132
+ type: 'integer',
133
+ defaultValue: 10,
134
+ },
135
+ ],
136
+ paging: 'none',
137
+ window: 'none',
138
+ },
139
+ {
140
+ id: 'symbol.list',
141
+ command: ['symbol', 'list'],
142
+ description: 'List symbols with bounded pagination',
143
+ endpoint: '/api/meta/tickers/list',
144
+ method: 'GET',
145
+ inputSchema: z
146
+ .object({
147
+ exchange: z.string().default('SH,SZ'),
148
+ assetType: z.enum(['a-share', 'a-share-index']).default('a-share'),
149
+ limit: z.number().int().min(1).max(10000).default(1000),
150
+ offset: z.number().int().nonnegative().default(0),
151
+ })
152
+ .strict(),
153
+ outputSchema: itemOutput,
154
+ options: [
155
+ {
156
+ flags: '--exchange <exchanges>',
157
+ description: 'comma-separated exchanges',
158
+ type: 'string',
159
+ defaultValue: 'SH,SZ',
160
+ },
161
+ {
162
+ flags: '--asset-type <type>',
163
+ description: 'asset type',
164
+ type: 'string',
165
+ choices: ['a-share', 'a-share-index'],
166
+ defaultValue: 'a-share',
167
+ queryName: 'asset_type',
168
+ },
169
+ {
170
+ flags: '--limit <number>',
171
+ description: 'page size (1-10000)',
172
+ type: 'integer',
173
+ defaultValue: 1000,
174
+ },
175
+ { flags: '--offset <number>', description: 'row offset', type: 'integer', defaultValue: 0 },
176
+ ],
177
+ paging: 'offset',
178
+ window: 'none',
179
+ },
180
+ {
181
+ id: 'market.snapshot',
182
+ command: ['market', 'snapshot'],
183
+ description: 'Query A-share price snapshots',
184
+ endpoint: '/api/a-share/prices/snapshot',
185
+ method: 'GET',
186
+ inputSchema: z
187
+ .object({
188
+ thscodes: commaCodes.optional(),
189
+ limit: z.number().int().min(1).max(10000).default(100),
190
+ offset: z.number().int().nonnegative().default(0),
191
+ })
192
+ .strict(),
193
+ outputSchema: itemOutput,
194
+ options: [
195
+ {
196
+ flags: '--thscodes <codes>',
197
+ description: 'comma-separated A-share thscodes',
198
+ type: 'string',
199
+ },
200
+ { flags: '--limit <number>', description: 'page size', type: 'integer', defaultValue: 100 },
201
+ { flags: '--offset <number>', description: 'row offset', type: 'integer', defaultValue: 0 },
202
+ ],
203
+ paging: 'offset',
204
+ window: 'none',
205
+ },
206
+ {
207
+ id: 'market.history',
208
+ command: ['market', 'history'],
209
+ description: 'Query daily A-share history',
210
+ endpoint: '/api/a-share/prices/historical',
211
+ method: 'GET',
212
+ inputSchema: historyInput,
213
+ outputSchema: itemOutput,
214
+ options: [
215
+ {
216
+ flags: '--thscode <code>',
217
+ description: 'single A-share thscode',
218
+ type: 'string',
219
+ required: true,
220
+ },
221
+ {
222
+ flags: '--start-ms <milliseconds>',
223
+ description: 'start timestamp',
224
+ type: 'integer',
225
+ required: true,
226
+ queryName: 'start',
227
+ },
228
+ {
229
+ flags: '--end-ms <milliseconds>',
230
+ description: 'end timestamp',
231
+ type: 'integer',
232
+ required: true,
233
+ queryName: 'end',
234
+ },
235
+ {
236
+ flags: '--adjust <mode>',
237
+ description: 'adjustment mode',
238
+ type: 'string',
239
+ choices: ['none', 'forward', 'backward'],
240
+ defaultValue: 'forward',
241
+ },
242
+ ],
243
+ paging: 'none',
244
+ window: 'ten-years',
245
+ },
246
+ {
247
+ id: 'market.corporate-actions',
248
+ command: ['market', 'corporate-actions'],
249
+ description: 'Query adjustment events',
250
+ endpoint: '/api/a-share/corporate-actions/adjustment-factors',
251
+ method: 'GET',
252
+ inputSchema: z
253
+ .object({ thscode: aShareCode, fromDate: isoDate.optional(), toDate: isoDate.optional() })
254
+ .strict(),
255
+ outputSchema: itemOutput,
256
+ options: [
257
+ {
258
+ flags: '--thscode <code>',
259
+ description: 'single A-share thscode',
260
+ type: 'string',
261
+ required: true,
262
+ },
263
+ {
264
+ flags: '--from-date <date>',
265
+ description: 'first ex-date YYYY-MM-DD',
266
+ type: 'string',
267
+ queryName: 'from',
268
+ },
269
+ {
270
+ flags: '--to-date <date>',
271
+ description: 'last ex-date YYYY-MM-DD',
272
+ type: 'string',
273
+ queryName: 'to',
274
+ },
275
+ ],
276
+ paging: 'none',
277
+ window: 'none',
278
+ },
279
+ financial('financials.income', 'income', '/api/a-share/financials/income-statements'),
280
+ financial('financials.balance-sheet', 'balance-sheet', '/api/a-share/financials/balance-sheets'),
281
+ financial('financials.cash-flow', 'cash-flow', '/api/a-share/financials/cash-flow-statements'),
282
+ {
283
+ id: 'financials.indicators',
284
+ command: ['financials', 'indicators'],
285
+ description: 'Query financial indicators for a report',
286
+ endpoint: '/api/a-share/financials/indicators',
287
+ method: 'GET',
288
+ inputSchema: z
289
+ .object({ thscode: aShareCode, report: z.string().regex(/^\d{4}-[1-4]$/u) })
290
+ .strict(),
291
+ outputSchema: z.object({ abilities: z.array(record) }).passthrough(),
292
+ options: [
293
+ {
294
+ flags: '--thscode <code>',
295
+ description: 'single A-share thscode',
296
+ type: 'string',
297
+ required: true,
298
+ },
299
+ {
300
+ flags: '--report <period>',
301
+ description: 'report quarter YYYY-[1-4]',
302
+ type: 'string',
303
+ required: true,
304
+ },
305
+ ],
306
+ paging: 'none',
307
+ window: 'none',
308
+ },
309
+ {
310
+ id: 'market.calendar',
311
+ command: ['market', 'calendar'],
312
+ description: 'Query the one-year A-share trading calendar',
313
+ endpoint: '/api/a-share/calendar/trading-days',
314
+ method: 'GET',
315
+ inputSchema: z.object({}).strict(),
316
+ outputSchema: itemOutput,
317
+ options: [],
318
+ paging: 'none',
319
+ window: 'one-year',
320
+ },
321
+ {
322
+ id: 'index.catalog',
323
+ command: ['index', 'catalog'],
324
+ description: 'List THS indices by category',
325
+ endpoint: '/api/a-share-index/catalog/ths-index-list',
326
+ method: 'GET',
327
+ inputSchema: z
328
+ .object({ tag: z.enum(['cn_concept', 'region', 'tszs', 'industry']).default('cn_concept') })
329
+ .strict(),
330
+ outputSchema: itemOutput,
331
+ options: [
332
+ {
333
+ flags: '--tag <tag>',
334
+ description: 'index category',
335
+ type: 'string',
336
+ choices: ['cn_concept', 'region', 'tszs', 'industry'],
337
+ defaultValue: 'cn_concept',
338
+ },
339
+ ],
340
+ paging: 'none',
341
+ window: 'none',
342
+ },
343
+ {
344
+ id: 'index.constituents',
345
+ command: ['index', 'constituents'],
346
+ description: 'Query index constituents',
347
+ endpoint: '/api/a-share-index/constituents/ths-stock-list',
348
+ method: 'GET',
349
+ inputSchema: z.object({ thscode: indexCode }).strict(),
350
+ outputSchema: itemOutput,
351
+ options: [
352
+ {
353
+ flags: '--thscode <code>',
354
+ description: 'single index thscode',
355
+ type: 'string',
356
+ required: true,
357
+ },
358
+ ],
359
+ paging: 'none',
360
+ window: 'none',
361
+ },
362
+ {
363
+ id: 'index.snapshot',
364
+ command: ['index', 'snapshot'],
365
+ description: 'Query index price snapshots',
366
+ endpoint: '/api/a-share-index/prices/snapshot',
367
+ method: 'GET',
368
+ inputSchema: z.object({ thscodes: commaCodes }).strict(),
369
+ outputSchema: itemOutput,
370
+ options: [
371
+ {
372
+ flags: '--thscodes <codes>',
373
+ description: 'comma-separated index thscodes',
374
+ type: 'string',
375
+ required: true,
376
+ },
377
+ ],
378
+ paging: 'none',
379
+ window: 'none',
380
+ },
381
+ {
382
+ id: 'index.history',
383
+ command: ['index', 'history'],
384
+ description: 'Query daily index history',
385
+ endpoint: '/api/a-share-index/prices/historical',
386
+ method: 'GET',
387
+ inputSchema: indexHistoryInput,
388
+ outputSchema: itemOutput,
389
+ options: [
390
+ {
391
+ flags: '--thscode <code>',
392
+ description: 'single index thscode',
393
+ type: 'string',
394
+ required: true,
395
+ },
396
+ {
397
+ flags: '--start-ms <milliseconds>',
398
+ description: 'start timestamp',
399
+ type: 'integer',
400
+ required: true,
401
+ queryName: 'start',
402
+ },
403
+ {
404
+ flags: '--end-ms <milliseconds>',
405
+ description: 'end timestamp',
406
+ type: 'integer',
407
+ required: true,
408
+ queryName: 'end',
409
+ },
410
+ ],
411
+ paging: 'none',
412
+ window: 'ten-years',
413
+ },
414
+ {
415
+ id: 'special.limit-up-pool',
416
+ command: ['special', 'limit-up-pool'],
417
+ description: 'Query the limit-up stock pool',
418
+ endpoint: '/api/a-share/special-data/limit-up-pool',
419
+ method: 'GET',
420
+ inputSchema: z
421
+ .object({
422
+ dateMs: z.number().int().nonnegative().optional(),
423
+ page: z.number().int().min(1).default(1),
424
+ size: z.number().int().min(1).max(200).default(50),
425
+ sortField: z
426
+ .enum(['last_price', 'continue_day_cnt', 'seal_money', 'limit_up_time'])
427
+ .default('last_price'),
428
+ sortDir: z.enum(['asc', 'desc']).default('desc'),
429
+ })
430
+ .strict(),
431
+ outputSchema: itemOutput,
432
+ options: [
433
+ {
434
+ flags: '--date-ms <milliseconds>',
435
+ description: 'trade date at Asia/Shanghai midnight',
436
+ type: 'integer',
437
+ queryName: 'date_ms',
438
+ },
439
+ { flags: '--page <number>', description: 'page number', type: 'integer', defaultValue: 1 },
440
+ {
441
+ flags: '--size <number>',
442
+ description: 'page size (1-200)',
443
+ type: 'integer',
444
+ defaultValue: 50,
445
+ },
446
+ {
447
+ flags: '--sort-field <field>',
448
+ description: 'sort field',
449
+ type: 'string',
450
+ choices: ['last_price', 'continue_day_cnt', 'seal_money', 'limit_up_time'],
451
+ defaultValue: 'last_price',
452
+ queryName: 'sort_field',
453
+ },
454
+ {
455
+ flags: '--sort-dir <direction>',
456
+ description: 'sort direction',
457
+ type: 'string',
458
+ choices: ['asc', 'desc'],
459
+ defaultValue: 'desc',
460
+ queryName: 'sort_dir',
461
+ },
462
+ ],
463
+ paging: 'page',
464
+ window: 'none',
465
+ },
466
+ {
467
+ id: 'special.limit-up-ladder',
468
+ command: ['special', 'limit-up-ladder'],
469
+ description: 'Query the 30-day limit-up ladder',
470
+ endpoint: '/api/a-share/special-data/limit-up-ladder',
471
+ method: 'GET',
472
+ inputSchema: z.object({}).strict(),
473
+ outputSchema: itemOutput,
474
+ options: [],
475
+ paging: 'none',
476
+ window: 'none',
477
+ },
478
+ {
479
+ id: 'special.anomaly-list',
480
+ command: ['special', 'anomaly-list'],
481
+ description: 'Query today-only anomaly analysis rows',
482
+ endpoint: '/api/a-share/special-data/anomaly-analysis-list',
483
+ method: 'GET',
484
+ inputSchema: z
485
+ .object({
486
+ tagCodes: z
487
+ .string()
488
+ .refine((value) => value
489
+ .split(',')
490
+ .every((token) => [
491
+ 'LIMIT_UP',
492
+ 'LIMIT_DOWN',
493
+ 'SHARP_RISE',
494
+ 'SHARP_FALL',
495
+ 'RAPID_RALLY',
496
+ 'RAPID_DECLINE',
497
+ ].includes(token.toUpperCase()) && token.length > 0))
498
+ .optional(),
499
+ })
500
+ .strict(),
501
+ outputSchema: itemOutput,
502
+ options: [
503
+ {
504
+ flags: '--tag-codes <codes>',
505
+ description: 'comma-separated anomaly tags',
506
+ type: 'string',
507
+ queryName: 'tag_codes',
508
+ },
509
+ ],
510
+ paging: 'none',
511
+ window: 'today-only',
512
+ },
513
+ {
514
+ id: 'special.anomaly-stock',
515
+ command: ['special', 'anomaly-stock'],
516
+ description: 'Query today-only anomalies for up to 50 raw code tokens',
517
+ endpoint: '/api/a-share/special-data/anomaly-analysis-stock',
518
+ method: 'GET',
519
+ inputSchema: z
520
+ .object({
521
+ thscodes: z.string().superRefine((value, context) => {
522
+ const tokens = value.split(',');
523
+ if (tokens.length > 50)
524
+ context.addIssue({ code: 'custom', message: 'at most 50 raw tokens' });
525
+ if (tokens.some((token) => !/^\d{6}\.(SH|SZ|BJ)$/iu.test(token)))
526
+ context.addIssue({ code: 'custom', message: 'invalid or empty A-share token' });
527
+ }),
528
+ })
529
+ .strict(),
530
+ outputSchema: itemOutput,
531
+ options: [
532
+ {
533
+ flags: '--thscodes <codes>',
534
+ description: '1-50 comma-separated A-share thscodes',
535
+ type: 'string',
536
+ required: true,
537
+ },
538
+ ],
539
+ paging: 'none',
540
+ window: 'today-only',
541
+ },
542
+ {
543
+ id: 'special.skyrocket',
544
+ command: ['special', 'skyrocket'],
545
+ description: 'Query the skyrocket ranking',
546
+ endpoint: '/api/a-share/special-data/skyrocket-list',
547
+ method: 'GET',
548
+ inputSchema: z.object({ period: z.enum(['day', 'hour']).default('day') }).strict(),
549
+ outputSchema: itemOutput,
550
+ options: [
551
+ {
552
+ flags: '--period <period>',
553
+ description: 'ranking period',
554
+ type: 'string',
555
+ choices: ['day', 'hour'],
556
+ defaultValue: 'day',
557
+ },
558
+ ],
559
+ paging: 'none',
560
+ window: 'none',
561
+ },
562
+ {
563
+ id: 'special.hot-stock',
564
+ command: ['special', 'hot-stock'],
565
+ description: 'Query the current hot-stock ranking',
566
+ endpoint: '/api/a-share/special-data/hot-stock-list',
567
+ method: 'GET',
568
+ inputSchema: z.object({ period: z.enum(['day', 'hour']).default('day') }).strict(),
569
+ outputSchema: itemOutput,
570
+ options: [
571
+ {
572
+ flags: '--period <period>',
573
+ description: 'ranking period',
574
+ type: 'string',
575
+ choices: ['day', 'hour'],
576
+ defaultValue: 'day',
577
+ },
578
+ ],
579
+ paging: 'none',
580
+ window: 'none',
581
+ },
582
+ {
583
+ id: 'special.hot-stock-history',
584
+ command: ['special', 'hot-stock-history'],
585
+ description: 'Query a historical hot-stock ranking',
586
+ endpoint: '/api/a-share/special-data/hot-stock-list-history',
587
+ method: 'GET',
588
+ inputSchema: z.object({ date: isoDate }).strict(),
589
+ outputSchema: itemOutput,
590
+ options: [
591
+ {
592
+ flags: '--date <date>',
593
+ description: 'trade date YYYY-MM-DD',
594
+ type: 'string',
595
+ required: true,
596
+ },
597
+ ],
598
+ paging: 'none',
599
+ window: 'one-year',
600
+ },
601
+ {
602
+ id: 'special.hot-stock-trend',
603
+ command: ['special', 'hot-stock-trend'],
604
+ description: 'Query one stock hot-rank trend',
605
+ endpoint: '/api/a-share/special-data/hot-stock-rank-trend',
606
+ method: 'GET',
607
+ inputSchema: z
608
+ .object({ thscode: aShareCode, startDate: isoDate, endDate: isoDate })
609
+ .strict()
610
+ .refine((value) => value.startDate <= value.endDate, {
611
+ message: 'start-date must be <= end-date',
612
+ }),
613
+ outputSchema: itemOutput,
614
+ options: [
615
+ {
616
+ flags: '--thscode <code>',
617
+ description: 'single A-share thscode',
618
+ type: 'string',
619
+ required: true,
620
+ },
621
+ {
622
+ flags: '--start-date <date>',
623
+ description: 'start date YYYY-MM-DD',
624
+ type: 'string',
625
+ required: true,
626
+ queryName: 'start_date',
627
+ },
628
+ {
629
+ flags: '--end-date <date>',
630
+ description: 'end date YYYY-MM-DD',
631
+ type: 'string',
632
+ required: true,
633
+ queryName: 'end_date',
634
+ },
635
+ ],
636
+ paging: 'none',
637
+ window: 'one-year',
638
+ },
639
+ {
640
+ id: 'special.dragon-tiger',
641
+ command: ['special', 'dragon-tiger'],
642
+ description: 'Query dragon-tiger board records',
643
+ endpoint: '/api/a-share/special-data/dragon-tiger-list',
644
+ method: 'GET',
645
+ inputSchema: z
646
+ .object({
647
+ boardType: z.enum(['all', 'org', 'hot_money']).default('all'),
648
+ date: isoDate.optional(),
649
+ })
650
+ .strict(),
651
+ outputSchema: objectOutput,
652
+ options: [
653
+ {
654
+ flags: '--board-type <type>',
655
+ description: 'board category',
656
+ type: 'string',
657
+ choices: ['all', 'org', 'hot_money'],
658
+ defaultValue: 'all',
659
+ queryName: 'board_type',
660
+ },
661
+ { flags: '--date <date>', description: 'optional trade date YYYY-MM-DD', type: 'string' },
662
+ ],
663
+ paging: 'none',
664
+ window: 'one-year',
665
+ },
666
+ ];
667
+ //# sourceMappingURL=remote-capabilities.js.map
@@ -0,0 +1,6 @@
1
+ export interface FinancialRecord {
2
+ thscode?: string;
3
+ period_end_ms?: number;
4
+ [field: string]: unknown;
5
+ }
6
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1,6 @@
1
+ export interface IndexRecord {
2
+ thscode: string;
3
+ name?: string;
4
+ [field: string]: unknown;
5
+ }
6
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1,6 @@
1
+ export interface MarketBar {
2
+ thscode?: string;
3
+ date_ms?: number;
4
+ [field: string]: unknown;
5
+ }
6
+ //# sourceMappingURL=types.d.ts.map