@lumyne/market-demand 0.0.0-stage → 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.
package/INSTALL.md ADDED
@@ -0,0 +1,7 @@
1
+ # 安装需求分析插件
2
+
3
+ 插件包含查询工具和伴生 Skill。当前使用的 Agent 需要能执行 Node.js 22 或更新版本,并能访问管理员提供的需求分析服务。
4
+
5
+ > 请安装 @lumyne/market-demand,安装并验证当前 Agent 的 market-demand Skill,检查需求分析服务连接。
6
+
7
+ 服务地址和访问凭据由部署管理员提供,通过运行环境配置。安装后,Agent 应确认宿主能够发现 Skill,并运行已安装的 CLI 查验版本、服务和日期范围。
package/UPDATE.md ADDED
@@ -0,0 +1,5 @@
1
+ # 更新需求分析插件
2
+
3
+ > 请检查 @lumyne/market-demand 的稳定版,并更新当前 Agent 的 market-demand Skill 和查询工具。请核对版本和服务连接。
4
+
5
+ 日常查询发现新版本时会提示。更新为选定 Agent 安装一份独立的运行时与 Skill,并验证二者版本。遇到本地修改时,更新会保留现有目录并报告冲突。
@@ -0,0 +1,8 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "agent": "generic",
4
+ "target": "Host-resolved absolute Skill directory",
5
+ "skill": "market-demand",
6
+ "runtimeEntry": ".runtime/bin/market-demand.mjs",
7
+ "hostDiscovery": "Verify through the selected host"
8
+ }
@@ -0,0 +1,53 @@
1
+ #!/usr/bin/env node
2
+ import { parseArgs } from 'node:util';
3
+ import { apiConfig, apiClient, CliError, query } from '../lib/query.mjs';
4
+ import { manifest, identity, source, manageSkill, checkUpdate, installUpdate, notifyUpdate } from '../lib/maintenance.mjs';
5
+
6
+ function usage(command) {
7
+ if (!command) return { ...manifest, usage: 'market-demand <command> [options]' };
8
+ return { usage: 'market-demand ' + command + ' [options]', ...manifest.commandContracts[command] };
9
+ }
10
+
11
+ async function main(args) {
12
+ if (!args.length || args[0] === '--help') return { command: 'help', ...usage() };
13
+ const first = args.shift();
14
+ const command = first === '--version' ? 'version' : ['skill', 'update'].includes(first) ? first + ' ' + args.shift() : first;
15
+ const contract = manifest.commandContracts[command];
16
+ if (!contract) throw new CliError('INVALID_COMMAND', '未知命令。使用 --help 查看帮助。');
17
+ let options;
18
+ try {
19
+ options = parseArgs({ args, options: Object.fromEntries(Object.entries(contract.options).map(([flag, spec]) =>
20
+ [flag.slice(2), { type: spec.type, multiple: Boolean(spec.repeatable) }])), allowPositionals: false }).values;
21
+ } catch {
22
+ throw new CliError('INVALID_INPUT', '命令参数无效。使用命令的 --help 查看参数。');
23
+ }
24
+ if (options.help) return { command, data: usage(command) };
25
+ if (command === 'version') return { command, ...identity };
26
+ if (command === 'capabilities') return { command, ...manifest };
27
+ if (command === 'install-notice') return { command, message: '安装需包含 CLI 与伴生 Skill。请参阅随包提供的 INSTALL.md。' };
28
+ if (command === 'doctor') {
29
+ const { minDate, maxDate } = (await query('dates', {}, apiClient(apiConfig()))).data;
30
+ return { command, ...identity, node: process.version, source: 'ready', minDate, maxDate };
31
+ }
32
+ if (command === 'skill source') return { command, ...source(options) };
33
+ if (first === 'skill') return { command, ...await manageSkill(command.split(' ')[1], options) };
34
+ if (command === 'update check') return { command, ...await checkUpdate() };
35
+ if (command === 'update install') return { command, ...await installUpdate(options) };
36
+ const result = await query(command, options, apiClient(apiConfig()));
37
+ return { command, ...result, updateNotice: await notifyUpdate() };
38
+ }
39
+
40
+ const args = process.argv.slice(2);
41
+ try {
42
+ const { updateNotice, ...result } = await main([...args]);
43
+ if (updateNotice) console.error(updateNotice);
44
+ if (result.message && !args.includes('--json')) console.log(result.message);
45
+ else if (args[0] === '--version' && !args.includes('--json')) console.log(result.version);
46
+ else console.log(JSON.stringify({ schemaVersion: 1, ok: true, ...result }, null, 2));
47
+ } catch (error) {
48
+ const issue = { code: error instanceof CliError ? error.code : 'INTERNAL_ERROR',
49
+ message: error instanceof CliError ? error.message : '命令执行失败。请检查本机配置及目标目录权限。' };
50
+ if (args.includes('--json')) console.log(JSON.stringify({ schemaVersion: 1, ok: false, error: issue }));
51
+ else console.error(issue.code + ' ' + issue.message);
52
+ process.exitCode = 1;
53
+ }
@@ -0,0 +1,534 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "package": "@lumyne/market-demand",
4
+ "version": "0.1.0",
5
+ "cli": "market-demand",
6
+ "skills": [
7
+ "market-demand"
8
+ ],
9
+ "target_platforms": [
10
+ "generic"
11
+ ],
12
+ "commandContracts": {
13
+ "version": {
14
+ "description": "查看 CLI 和包版本",
15
+ "sideEffects": "none",
16
+ "options": {
17
+ "--json": {
18
+ "type": "boolean"
19
+ },
20
+ "--help": {
21
+ "type": "boolean"
22
+ }
23
+ }
24
+ },
25
+ "capabilities": {
26
+ "description": "发现命令、参数和管理契约",
27
+ "sideEffects": "none",
28
+ "options": {
29
+ "--json": {
30
+ "type": "boolean"
31
+ },
32
+ "--help": {
33
+ "type": "boolean"
34
+ }
35
+ }
36
+ },
37
+ "doctor": {
38
+ "description": "验证配置和数据源可用性",
39
+ "sideEffects": "none",
40
+ "options": {
41
+ "--json": {
42
+ "type": "boolean"
43
+ },
44
+ "--help": {
45
+ "type": "boolean"
46
+ }
47
+ }
48
+ },
49
+ "dates": {
50
+ "description": "查询可用统计日期",
51
+ "sideEffects": "none",
52
+ "options": {
53
+ "--json": {
54
+ "type": "boolean"
55
+ },
56
+ "--help": {
57
+ "type": "boolean"
58
+ }
59
+ }
60
+ },
61
+ "categories": {
62
+ "description": "按父路径列出下一级类目",
63
+ "sideEffects": "none",
64
+ "options": {
65
+ "--json": {
66
+ "type": "boolean"
67
+ },
68
+ "--help": {
69
+ "type": "boolean"
70
+ },
71
+ "--category": {
72
+ "type": "string",
73
+ "repeatable": true
74
+ },
75
+ "--date": {
76
+ "type": "string"
77
+ },
78
+ "--start": {
79
+ "type": "string"
80
+ },
81
+ "--end": {
82
+ "type": "string"
83
+ }
84
+ }
85
+ },
86
+ "word-roots": {
87
+ "description": "查询词根排行",
88
+ "sideEffects": "none",
89
+ "options": {
90
+ "--json": {
91
+ "type": "boolean"
92
+ },
93
+ "--help": {
94
+ "type": "boolean"
95
+ },
96
+ "--category": {
97
+ "type": "string",
98
+ "repeatable": true
99
+ },
100
+ "--date": {
101
+ "type": "string"
102
+ },
103
+ "--start": {
104
+ "type": "string"
105
+ },
106
+ "--end": {
107
+ "type": "string"
108
+ },
109
+ "--search": {
110
+ "type": "string"
111
+ },
112
+ "--page": {
113
+ "type": "string"
114
+ },
115
+ "--page-size": {
116
+ "type": "string"
117
+ }
118
+ }
119
+ },
120
+ "keywords": {
121
+ "description": "查询搜索词指标,可筛选任一指定词根",
122
+ "sideEffects": "none",
123
+ "options": {
124
+ "--json": {
125
+ "type": "boolean"
126
+ },
127
+ "--help": {
128
+ "type": "boolean"
129
+ },
130
+ "--category": {
131
+ "type": "string",
132
+ "repeatable": true
133
+ },
134
+ "--date": {
135
+ "type": "string"
136
+ },
137
+ "--start": {
138
+ "type": "string"
139
+ },
140
+ "--end": {
141
+ "type": "string"
142
+ },
143
+ "--search": {
144
+ "type": "string"
145
+ },
146
+ "--page": {
147
+ "type": "string"
148
+ },
149
+ "--page-size": {
150
+ "type": "string"
151
+ },
152
+ "--root": {
153
+ "type": "string",
154
+ "repeatable": true
155
+ }
156
+ }
157
+ },
158
+ "keyword-trend": {
159
+ "description": "查询精确搜索词在指定类目中的趋势",
160
+ "sideEffects": "none",
161
+ "options": {
162
+ "--json": {
163
+ "type": "boolean"
164
+ },
165
+ "--help": {
166
+ "type": "boolean"
167
+ },
168
+ "--category": {
169
+ "type": "string",
170
+ "repeatable": true
171
+ },
172
+ "--date": {
173
+ "type": "string"
174
+ },
175
+ "--start": {
176
+ "type": "string"
177
+ },
178
+ "--end": {
179
+ "type": "string"
180
+ },
181
+ "--keyword": {
182
+ "type": "string"
183
+ },
184
+ "--metric": {
185
+ "type": "string"
186
+ },
187
+ "--granularity": {
188
+ "type": "string"
189
+ }
190
+ }
191
+ },
192
+ "products": {
193
+ "description": "按页查询商品,可按 ID、文本和关联词筛选",
194
+ "sideEffects": "none",
195
+ "options": {
196
+ "--json": {
197
+ "type": "boolean"
198
+ },
199
+ "--help": {
200
+ "type": "boolean"
201
+ },
202
+ "--category": {
203
+ "type": "string",
204
+ "repeatable": true
205
+ },
206
+ "--date": {
207
+ "type": "string"
208
+ },
209
+ "--start": {
210
+ "type": "string"
211
+ },
212
+ "--end": {
213
+ "type": "string"
214
+ },
215
+ "--search": {
216
+ "type": "string"
217
+ },
218
+ "--page": {
219
+ "type": "string"
220
+ },
221
+ "--page-size": {
222
+ "type": "string"
223
+ },
224
+ "--id": {
225
+ "type": "string"
226
+ },
227
+ "--term": {
228
+ "type": "string",
229
+ "repeatable": true
230
+ }
231
+ }
232
+ },
233
+ "skill source": {
234
+ "description": "定位随包提供的 Skill",
235
+ "sideEffects": "none",
236
+ "options": {
237
+ "--json": {
238
+ "type": "boolean"
239
+ },
240
+ "--help": {
241
+ "type": "boolean"
242
+ },
243
+ "--name": {
244
+ "type": "string"
245
+ },
246
+ "--all": {
247
+ "type": "boolean"
248
+ }
249
+ }
250
+ },
251
+ "skill status": {
252
+ "description": "核对指定 Agent 的 Skill 与运行时",
253
+ "sideEffects": "none",
254
+ "options": {
255
+ "--json": {
256
+ "type": "boolean"
257
+ },
258
+ "--help": {
259
+ "type": "boolean"
260
+ },
261
+ "--name": {
262
+ "type": "string"
263
+ },
264
+ "--agent": {
265
+ "type": "string"
266
+ },
267
+ "--target-dir": {
268
+ "type": "string"
269
+ }
270
+ }
271
+ },
272
+ "skill install": {
273
+ "description": "安装 Skill 和独立运行时",
274
+ "sideEffects": "local-write",
275
+ "options": {
276
+ "--json": {
277
+ "type": "boolean"
278
+ },
279
+ "--help": {
280
+ "type": "boolean"
281
+ },
282
+ "--name": {
283
+ "type": "string"
284
+ },
285
+ "--agent": {
286
+ "type": "string"
287
+ },
288
+ "--target-dir": {
289
+ "type": "string"
290
+ }
291
+ }
292
+ },
293
+ "skill update": {
294
+ "description": "从当前包同步 Skill 和独立运行时",
295
+ "sideEffects": "local-write",
296
+ "options": {
297
+ "--json": {
298
+ "type": "boolean"
299
+ },
300
+ "--help": {
301
+ "type": "boolean"
302
+ },
303
+ "--name": {
304
+ "type": "string"
305
+ },
306
+ "--agent": {
307
+ "type": "string"
308
+ },
309
+ "--target-dir": {
310
+ "type": "string"
311
+ }
312
+ }
313
+ },
314
+ "update check": {
315
+ "description": "检查 npm 稳定版",
316
+ "sideEffects": "none",
317
+ "options": {
318
+ "--json": {
319
+ "type": "boolean"
320
+ },
321
+ "--help": {
322
+ "type": "boolean"
323
+ }
324
+ }
325
+ },
326
+ "update install": {
327
+ "description": "安装 npm 稳定版并同步选定 Agent 的 Skill",
328
+ "sideEffects": "package-and-skill-update",
329
+ "options": {
330
+ "--json": {
331
+ "type": "boolean"
332
+ },
333
+ "--help": {
334
+ "type": "boolean"
335
+ },
336
+ "--name": {
337
+ "type": "string"
338
+ },
339
+ "--agent": {
340
+ "type": "string"
341
+ },
342
+ "--target-dir": {
343
+ "type": "string"
344
+ }
345
+ }
346
+ },
347
+ "install-notice": {
348
+ "description": "查看包安装提示",
349
+ "sideEffects": "none",
350
+ "options": {
351
+ "--json": {
352
+ "type": "boolean"
353
+ },
354
+ "--help": {
355
+ "type": "boolean"
356
+ }
357
+ }
358
+ }
359
+ },
360
+ "configuration": {
361
+ "apiUrl": "MARKET_DEMAND_API_URL",
362
+ "accessToken": "MARKET_DEMAND_TOKEN",
363
+ "authorization": "Read-only access to the configured deployment. Authentication is enforced by the deployment."
364
+ },
365
+ "defaults": {
366
+ "page": 1,
367
+ "pageSize": 50,
368
+ "maxPageSize": 100,
369
+ "listingDate": "latest_available",
370
+ "trendDays": 30
371
+ },
372
+ "discoveryContract": {
373
+ "schemaVersion": 1,
374
+ "commandsField": "commandContracts",
375
+ "entryPoints": [
376
+ {
377
+ "argv": [
378
+ "capabilities",
379
+ "--json"
380
+ ],
381
+ "result": "manifest"
382
+ },
383
+ {
384
+ "argv": [
385
+ "skill",
386
+ "source",
387
+ "--json"
388
+ ],
389
+ "result": "source"
390
+ }
391
+ ],
392
+ "version": {
393
+ "command": "version",
394
+ "argv": [
395
+ "version",
396
+ "--json"
397
+ ],
398
+ "fields": {
399
+ "package": {
400
+ "field": "package",
401
+ "type": "string"
402
+ },
403
+ "version": {
404
+ "field": "version",
405
+ "type": "string"
406
+ }
407
+ }
408
+ },
409
+ "skillCollection": {
410
+ "namesField": "skills",
411
+ "default": "market-demand",
412
+ "selector": {
413
+ "option": "--name",
414
+ "type": "string"
415
+ },
416
+ "enumeration": {
417
+ "argv": [
418
+ "skill",
419
+ "source",
420
+ "--all",
421
+ "--json"
422
+ ],
423
+ "itemsField": "items",
424
+ "completeField": "complete"
425
+ },
426
+ "namedSource": [
427
+ "skill",
428
+ "source",
429
+ "--name",
430
+ "{skill}",
431
+ "--json"
432
+ ]
433
+ }
434
+ },
435
+ "maintenanceContract": {
436
+ "schemaVersion": 1,
437
+ "source": {
438
+ "name": {
439
+ "field": "name",
440
+ "type": "string"
441
+ },
442
+ "package": {
443
+ "field": "package",
444
+ "type": "string"
445
+ },
446
+ "version": {
447
+ "field": "version",
448
+ "type": "string"
449
+ },
450
+ "path": {
451
+ "field": "path",
452
+ "type": "string"
453
+ }
454
+ },
455
+ "status": {
456
+ "name": {
457
+ "field": "name",
458
+ "type": "string"
459
+ },
460
+ "package": {
461
+ "field": "package",
462
+ "type": "string"
463
+ },
464
+ "version": {
465
+ "field": "version",
466
+ "type": "string"
467
+ },
468
+ "target": {
469
+ "field": "target",
470
+ "type": "string"
471
+ },
472
+ "installed": {
473
+ "field": "installed",
474
+ "type": "boolean"
475
+ },
476
+ "managed": {
477
+ "field": "managed",
478
+ "type": "boolean"
479
+ },
480
+ "current": {
481
+ "field": "current",
482
+ "type": "boolean"
483
+ },
484
+ "edited": {
485
+ "field": "edited",
486
+ "type": "boolean"
487
+ },
488
+ "verification": {
489
+ "field": "verification",
490
+ "type": "object"
491
+ },
492
+ "recovery": {
493
+ "field": "recovery",
494
+ "type": "object"
495
+ }
496
+ },
497
+ "targetOptions": {
498
+ "--target-dir": {
499
+ "kind": "skill-directory"
500
+ }
501
+ },
502
+ "agentEligibility": "valid-name-with-generic-fallback",
503
+ "hostDiscoveryAuthority": "host"
504
+ },
505
+ "installationLifecycle": {
506
+ "skillRequired": true,
507
+ "updateRequiresSkillSync": true,
508
+ "required_components": [
509
+ "cli",
510
+ "skill"
511
+ ],
512
+ "agentNeutral": true,
513
+ "installGuide": "INSTALL.md",
514
+ "updateGuide": "UPDATE.md",
515
+ "targetRequired": true,
516
+ "hostRegistrationRequired": true,
517
+ "installationMode": "copy",
518
+ "sharedLinksAllowed": false,
519
+ "isolatedRuntimeRequired": true,
520
+ "install": "Resolve the calling Agent Skill directory, install the exact target, then verify host discovery.",
521
+ "update": "Resolve the existing managed target, then update the isolated runtime and Skill together.",
522
+ "verification": "Verify content hashes, package version, actual entry point and host discovery."
523
+ },
524
+ "automaticUpdates": {
525
+ "enabledByDefault": true,
526
+ "intervalHours": 24,
527
+ "timeoutMs": 1000,
528
+ "defaultMode": "notify",
529
+ "trigger": "First successful data query during each UTC day",
530
+ "configuration": "Uses XDG_STATE_HOME when provided",
531
+ "disable": "MARKET_DEMAND_UPDATE_CHECK=0",
532
+ "recovery": "Use update check to retry without the advisory interval"
533
+ }
534
+ }