neuxnbcp 0.1.2 → 0.1.3

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 (2) hide show
  1. package/dist/index.js +91 -14
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env node
2
+ import { createInterface } from 'node:readline/promises';
2
3
  import { renderNbcpBanner, shouldShowBanner } from './banner.js';
3
4
  const LOTTERY_MCP_TOOLS = [
4
5
  'lottery.latest',
@@ -7,7 +8,17 @@ const LOTTERY_MCP_TOOLS = [
7
8
  'lottery.summary',
8
9
  ];
9
10
  const MCP_SERVER_TRANSPORT = 'stdio';
10
- const HELP_TEXT = `临时运行:
11
+ const TOKEN_PAGE_URL = 'https://www.neuxsbot.com/member/api-keys';
12
+ const MENU_TEXT = `请选择操作:
13
+ 1. 立即使用(启动 MCP 服务)
14
+ 2. 全局安装
15
+ 3. 获取 Token 页面
16
+ 4. 查看帮助
17
+ 0. 退出`;
18
+ const HELP_TEXT = `临时打开菜单:
19
+ npx --yes neuxnbcp@latest
20
+
21
+ 直接查看帮助:
11
22
  npx --yes neuxnbcp@latest --help
12
23
 
13
24
  全局安装:
@@ -31,19 +42,85 @@ const HELP_TEXT = `临时运行:
31
42
  传输方式: ${MCP_SERVER_TRANSPORT}
32
43
  工具列表: ${LOTTERY_MCP_TOOLS.join(', ')}
33
44
  `;
45
+ const QUICK_START_TEXT = `立即使用:
46
+ 临时运行:
47
+ npx --yes neuxnbcp@latest serve
48
+
49
+ 全局安装后:
50
+ nbcp serve
51
+ `;
52
+ const INSTALL_TEXT = `全局安装:
53
+ npm i -g neuxnbcp
54
+
55
+ 安装完成后:
56
+ nbcp --help
57
+ nbcp serve
58
+ `;
59
+ const TOKEN_TEXT = `获取 Token 页面:
60
+ ${TOKEN_PAGE_URL}
61
+ `;
62
+ const runScaffoldedCommand = (name) => {
63
+ console.log(`命令 "${name}" 已预留,下一阶段接入实际功能。`);
64
+ return 0;
65
+ };
66
+ const canShowInteractiveMenu = (stdin = process.stdin, stdout = process.stdout) => process.env.NBCP_FORCE_MENU === '1' || (Boolean(stdin.isTTY) && Boolean(stdout.isTTY));
67
+ const runStartupMenu = async () => {
68
+ console.log(MENU_TEXT);
69
+ if (!canShowInteractiveMenu()) {
70
+ console.log('\n当前为非交互环境,请追加 --help 查看完整帮助。');
71
+ return 0;
72
+ }
73
+ const rl = createInterface({
74
+ input: process.stdin,
75
+ output: process.stdout,
76
+ });
77
+ try {
78
+ const selection = (await rl.question('\n请输入数字: ')).trim();
79
+ console.log('');
80
+ switch (selection) {
81
+ case '1':
82
+ console.log(QUICK_START_TEXT);
83
+ return 0;
84
+ case '2':
85
+ console.log(INSTALL_TEXT);
86
+ return 0;
87
+ case '3':
88
+ console.log(TOKEN_TEXT);
89
+ return 0;
90
+ case '4':
91
+ console.log(HELP_TEXT);
92
+ return 0;
93
+ case '0':
94
+ console.log('已退出。');
95
+ return 0;
96
+ default:
97
+ console.error(`无效选择: ${selection || '(空)'}`);
98
+ return 1;
99
+ }
100
+ }
101
+ finally {
102
+ rl.close();
103
+ }
104
+ };
34
105
  const args = process.argv.slice(2);
35
106
  const command = args[0];
36
- if (shouldShowBanner(command)) {
37
- process.stdout.write(renderNbcpBanner());
38
- }
39
- if (!command || command === '--help' || command === '-h') {
107
+ const main = async () => {
108
+ if (shouldShowBanner(command)) {
109
+ process.stdout.write(renderNbcpBanner());
110
+ }
111
+ if (!command) {
112
+ return runStartupMenu();
113
+ }
114
+ if (command === '--help' || command === '-h') {
115
+ console.log(HELP_TEXT);
116
+ return 0;
117
+ }
118
+ if (['serve', 'init', 'doctor', 'login'].includes(command)) {
119
+ return runScaffoldedCommand(command);
120
+ }
121
+ console.error(`未知命令: ${command}`);
40
122
  console.log(HELP_TEXT);
41
- process.exit(0);
42
- }
43
- if (['serve', 'init', 'doctor', 'login'].includes(command)) {
44
- console.log(`命令 "${command}" 已预留,下一阶段接入实际功能。`);
45
- process.exit(0);
46
- }
47
- console.error(`未知命令: ${command}`);
48
- console.log(HELP_TEXT);
49
- process.exit(1);
123
+ return 1;
124
+ };
125
+ const exitCode = await main();
126
+ process.exit(exitCode);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neuxnbcp",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "NEUXSBOT lottery MCP command line entrypoint",