@napuketto/cli 0.7.4 → 0.8.1

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 (3) hide show
  1. package/README.md +1 -1
  2. package/dist/index.mjs +27 -47
  3. package/package.json +9 -10
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @napuketto/cli
2
2
 
3
- NapukettoQQ 命令行入口。
3
+ Napuketto 命令行入口。
4
4
 
5
5
  ```bash
6
6
  napuketto # 启动:自动登录(快速/扫码)→ 按账号配置装配协议服务
package/dist/index.mjs CHANGED
@@ -181,11 +181,11 @@ function parseCliConfig(input) {
181
181
  }
182
182
  // src/config/inline.ts
183
183
  /**
184
- * 内联配置(NAPKETTO_CONFIG_JSON 旧前缀,2026-11 起规范前缀 NAPUKETTO_CONFIG_JSON)。
184
+ * 内联配置(`NAPUKETTO_CONFIG_JSON`,2026-11 起唯一规范拼写)。
185
185
  *
186
186
  * KuroBridge 等嵌入式宿主每次拉起前整体生成配置,经环境变量喂 JSON 文本
187
187
  * (与 napuketto.toml 同构:parseCliConfig 直接吃 JSON.parse 产物),消除托管
188
- * toml 文件本体。优先级 NAPKETTO_CONFIG_JSON > NAPKETTO_CONFIG > 缺省模板生成;
188
+ * toml 文件本体。优先级 NAPUKETTO_CONFIG_JSON > NAPUKETTO_CONFIG > 缺省模板生成;
189
189
  * 内联生效时不读 / 不写 / 不校验任何 toml 文件。Windows 单环境变量上限 32767
190
190
  * 字符(约 32KB),嵌入式配置形状远小于该限(超限宿主退回文件形态)。
191
191
  *
@@ -199,37 +199,18 @@ function parseCliConfig(input) {
199
199
  * 错误文案指明来源为「内联配置」且不含任何 toml 文件路径。本模块不 import
200
200
  * logger(logger.ts 反向依赖本模块判内联来源)。
201
201
  */
202
- /** 内联配置 env 键(规范前缀;读取为精确键访问,Windows 上 process.env 本身大小写不敏感)。 */
202
+ /** 内联配置 env 键(唯一规范拼写;读取为精确键访问,Windows 上 process.env 本身大小写不敏感)。 */
203
203
  const INLINE_CONFIG_ENV = "NAPUKETTO_CONFIG_JSON";
204
- /** 旧前缀兼容键(2026-11 前缀统一前已发布,双读回退)。 */
205
- const LEGACY_INLINE_CONFIG_ENV = "NAPKETTO_CONFIG_JSON";
206
204
  /**
207
- * 读取内联配置文本(新前缀优先、旧前缀回退;未设置 / 空串 / 纯空白 → undefined,
208
- * 回退文件形态)。
205
+ * 读取内联配置文本(未设置 / 空串 / 纯空白 → undefined,回退文件形态)。
209
206
  */
210
207
  function readInlineConfigText() {
211
- return readInlineEnvEntry()?.text;
208
+ const text = process$1.env[INLINE_CONFIG_ENV];
209
+ return text === void 0 || text.trim() === "" ? void 0 : text;
212
210
  }
213
- /**
214
- * 实际命中的内联配置 env 键名(新前缀优先、旧前缀回退;未生效 → undefined)。
215
- * 来源日志据此输出真实键名,避免旧前缀兼容期日志写死新名误导排查。
216
- */
211
+ /** 实际命中的内联配置 env 键名(未生效 → undefined)。来源日志据此标注来源键。 */
217
212
  function inlineConfigEnvName() {
218
- return readInlineEnvEntry()?.key;
219
- }
220
- /** 内联 env 决议(精确键读取;新前缀存在但为空时不回退旧前缀,与历史口径一致)。 */
221
- function readInlineEnvEntry() {
222
- const primary = process$1.env[INLINE_CONFIG_ENV];
223
- if (primary !== void 0) return primary.trim() === "" ? void 0 : {
224
- key: INLINE_CONFIG_ENV,
225
- text: primary
226
- };
227
- const legacy = process$1.env[LEGACY_INLINE_CONFIG_ENV];
228
- if (legacy === void 0 || legacy.trim() === "") return;
229
- return {
230
- key: LEGACY_INLINE_CONFIG_ENV,
231
- text: legacy
232
- };
213
+ return readInlineConfigText() === void 0 ? void 0 : INLINE_CONFIG_ENV;
233
214
  }
234
215
  /** 内联是否生效(boot/装配链决定「不碰文件」的判定口径,与 readInlineConfigText 同源)。 */
235
216
  function isInlineConfigActive() {
@@ -348,7 +329,7 @@ function validateSandboxConfigPaths(config, dataDir) {
348
329
  */
349
330
  function configTemplate() {
350
331
  return `# ============================================================
351
- # NapukettoQQ 全局配置文件
332
+ # Napuketto 全局配置文件
352
333
  # ============================================================
353
334
  # 本文件由 \`napuketto config init\` 生成(或首次启动自动生成)。
354
335
  # 本机配置不入库(.gitignore);修改后重启生效。
@@ -401,7 +382,7 @@ nativeMediaPatch = true
401
382
  # # level = "debug"
402
383
  #
403
384
  # 环境变量覆盖(优先级高于本文件):NAPUKETTO_LOG_LEVEL / NAPUKETTO_LOG_FORMAT /
404
- # NAPUKETTO_NO_BANNER(兼容旧拼写 NAPKETTO_LOG_LEVEL)。
385
+ # NAPUKETTO_NO_BANNER。
405
386
 
406
387
  # ------------------------------------------------------------
407
388
  # 账号(至少一个,qq 必填)
@@ -495,7 +476,7 @@ port = 3001
495
476
  # [accounts.kurobot]
496
477
  # url = "ws://127.0.0.1:25580" # 必填:KuroBot 服务端地址(ws:// 或 wss://)
497
478
  # # token = "" # 可选:鉴权 token(服务端配了则必填,错 token 拒连)
498
- # # client = "napukettoqq" # 可选:自报身份(缺省 napukettoqq/<版本>)
479
+ # # client = "napuketto" # 可选:自报身份(缺省 napuketto/<版本>)
499
480
  # # commandPrefix = "/" # 可选:群命令前缀
500
481
  # # pingIntervalMs = 15000 # 可选:应用层心跳间隔(毫秒,须 < 30000)
501
482
  # # chatTemplate = "[{player}] {content}" # 游戏聊天渲染模板
@@ -527,7 +508,7 @@ port = 3001
527
508
  *
528
509
  * 从 config-cmds.ts 拆出(2026-10-25 模块收拢):
529
510
  * - `CliConfigStore` 只负责 napuketto.toml 的读写/校验(kernel ConfigBase);
530
- * - `loadCliConfigWithSource` 负责来源决议(NAPKETTO_CONFIG_JSON 优先)与来源日志;
511
+ * - `loadCliConfigWithSource` 负责来源决议(NAPUKETTO_CONFIG_JSON 优先)与来源日志;
531
512
  * - 4 个 config 子命令留在 commands/config.ts,不反向依赖本文件的私有实现。
532
513
  */
533
514
  /** 主配置默认值(dataRoot 为当前解析的数据根 = 项目根/.napuketto)。 */
@@ -629,8 +610,7 @@ async function loadCliConfigWithSource(opts = {}) {
629
610
  * 缓存配置构造;未初始化时兜底用缺省数据根解析(-d 生效前的极早期日志)。
630
611
  *
631
612
  * 环境变量(优先级高于 toml,见 kernel parseLogConfig):NAPUKETTO_LOG_LEVEL /
632
- * NAPUKETTO_LOG_FORMAT / NAPUKETTO_NO_BANNER / NAPUKETTO_LOG_COLORIZE,
633
- * 兼容旧拼写 NAPKETTO_LOG_LEVEL。
613
+ * NAPUKETTO_LOG_FORMAT / NAPUKETTO_NO_BANNER / NAPUKETTO_LOG_COLORIZE。
634
614
  */
635
615
  /** 已解析日志配置缓存(同一数据根复用;显式传入不同数据根时重新解析)。 */
636
616
  let cachedConfig = null;
@@ -912,7 +892,7 @@ async function cmdConfigValidate(opts) {
912
892
  /**
913
893
  * state.ts:账号运行时状态文件 + 进程控制原语(2026-09-08 T8)。
914
894
  *
915
- * 跨进程通信选型(决策记录):现有 IPC 为 stdio JSON 行协议(NAPUTO_IPC=1,
895
+ * 跨进程通信选型(决策记录):现有 IPC 为 stdio JSON 行协议(NAPUKETTO_IPC=1,
916
896
  * koishi 插件专用),supervisor 子进程不在此模式;引入独立通道(socket/pipe)
917
897
  * 复杂度高。采用 **PID 状态文件**:supervisor/单账号 boot 启动时把进程信息写
918
898
  * `<数据根>/<uin>/runtime.json`,supervisor 自身写 `<数据根>/supervisor.json`;
@@ -926,7 +906,7 @@ async function cmdConfigValidate(opts) {
926
906
  * `kind`/`restartCount`/启动时间与 boot pid,受管 boot 只补充 `selfHost*`。
927
907
  * boot 读到该标记即走合并写入(`patchAccountRuntime`),不再整文件覆盖。
928
908
  */
929
- const SUPERVISOR_CHILD_ENV = "NAPUTO_SUPERVISOR_CHILD";
909
+ const SUPERVISOR_CHILD_ENV = "NAPUKETTO_SUPERVISOR_CHILD";
930
910
  /** POSIX 强杀升级宽限(毫秒):SIGTERM 后仍未退出则补 SIGKILL。 */
931
911
  const FORCE_KILL_GRACE_MS = 1500;
932
912
  /** runtime.json 文件名。 */
@@ -1576,9 +1556,9 @@ async function resolvePackageEntries() {
1576
1556
  networkEntry: await packageEntry("@napuketto/network")
1577
1557
  };
1578
1558
  }
1579
- /** stub QQNT.dll 目录(--stub-dir > NAPUKETTO_STUB_DIR > NAPUTO_STUB_DIR > loader 包内闭源 submodule 默认)。 */
1559
+ /** stub QQNT.dll 目录(--stub-dir > NAPUKETTO_STUB_DIR > loader 包内闭源 submodule 默认)。 */
1580
1560
  function resolveStubDir(opts) {
1581
- return opts.stubDir ?? process$1.env["NAPUKETTO_STUB_DIR"] ?? process$1.env["NAPUTO_STUB_DIR"] ?? defaultStubDir();
1561
+ return opts.stubDir ?? process$1.env["NAPUKETTO_STUB_DIR"] ?? defaultStubDir();
1582
1562
  }
1583
1563
  /** QQ 原生文件多级来源 + 自动下载(本机未装 QQ 时走下载管线)。
1584
1564
  * 失败记录可操作提示并置 exitCode 1,返回 undefined(调用方提前返回)。 */
@@ -1589,7 +1569,7 @@ async function locateQqFiles(dataRoot, opts) {
1589
1569
  ...opts.qqPath !== void 0 ? { qqPath: opts.qqPath } : {}
1590
1570
  });
1591
1571
  } catch (err) {
1592
- logger.error({ err }, `定位/下载 QQ 原生文件失败:${errorMessage(err)}\n(本机未装 QQ 时自动下载官方安装包;若下载失败请检查网络,或手动安装 QQ、设置 NAPUTO_QQ_PATH 指定已有安装、NAPUTO_QQ_FILES 指定文件根、NAPUTO_QQ_URL 覆盖下载地址)`);
1572
+ logger.error({ err }, `定位/下载 QQ 原生文件失败:${errorMessage(err)}\n(本机未装 QQ 时自动下载官方安装包;若下载失败请检查网络,或手动安装 QQ、设置 NAPUKETTO_QQ_PATH 指定已有安装、NAPUKETTO_QQ_FILES 指定文件根、NAPUKETTO_QQ_URL 覆盖下载地址)`);
1593
1573
  process$1.exitCode = 1;
1594
1574
  return;
1595
1575
  }
@@ -2215,7 +2195,7 @@ async function runSingleAccountBranch(opts, qqs) {
2215
2195
  }
2216
2196
  /** 无 -q 时:读全局配置 accounts(账号必填,2026-08-08 拍板),supervisor 拉起全部启用账号。
2217
2197
  * 不再有「配置为空 → 交互式单账号登录」老路径:缺账号直接报错提示编辑模板。
2218
- * 配置加载内联优先(NAPKETTO_CONFIG_JSON > 文件);校验失败 ConfigError → exit 78。 */
2198
+ * 配置加载内联优先(NAPUKETTO_CONFIG_JSON > 文件);校验失败 ConfigError → exit 78。 */
2219
2199
  async function autoStart(opts) {
2220
2200
  const { config } = await loadCliConfigWithSource({
2221
2201
  ...opts.dataDir === void 0 ? {} : { dataDir: opts.dataDir },
@@ -2378,14 +2358,14 @@ function collectQq(value, prev) {
2378
2358
  prev.push(value);
2379
2359
  return prev;
2380
2360
  }
2381
- /** 启动字符画(NapukettoQQ 品牌标识,内嵌;art 含反引号/反斜杠,用数组逐行转义)。 */
2361
+ /** 启动字符画(Napuketto 品牌标识,内嵌;art 含反引号/反斜杠,用数组逐行转义)。 */
2382
2362
  const BANNER = [
2383
- " _ __ __ __ __ ____ ____ ",
2384
- " / | / /___ _____ __ __/ /_____ / /_/ /_____ / __ \\/ __ \\",
2385
- " / |/ / __ `/ __ \\/ / / / //_/ _ \\/ __/ __/ __ \\/ / / / / / /",
2386
- " / /| / /_/ / /_/ / /_/ / ,< / __/ /_/ /_/ /_/ / /_/ / /_/ / ",
2387
- "/_/ |_/\\__,_/ .___/\\__,_/_/|_|\\___/\\__/\\__/\\____/\\___\\_\\___\\_\\ ",
2388
- " /_/ "
2363
+ " _ __ __ __ __",
2364
+ " / | / /___ _____ __ __/ /_____ / /_/ /_____",
2365
+ " / |/ / __ `/ __ \\/ / / / //_/ _ \\/ __/ __/ __ \\",
2366
+ " / /| / /_/ / /_/ / /_/ / ,< / __/ /_/ /_/ /_/ /",
2367
+ "/_/ |_/\\__,_/ .___/\\__,_/_/|_|\\___/\\__/\\__/\\____/",
2368
+ " /_/"
2389
2369
  ].join("\n");
2390
2370
  /** 读主命令已解析的 data-dir(-d 定义在主命令,子命令经此共享)。 */
2391
2371
  function rootDataDir(program) {
@@ -2478,7 +2458,7 @@ function registerMainAction(program) {
2478
2458
  /** 入口:注册全部子命令与主命令后解析。 */
2479
2459
  function main() {
2480
2460
  const program = new Command();
2481
- program.name("napuketto").version(cliVersion()).description("NapukettoQQ 机器人框架(OneBot 11 兼容)");
2461
+ program.name("napuketto").version(cliVersion()).description("Napuketto 机器人框架(OneBot 11 兼容)");
2482
2462
  program.option("-q, --qq <uin>", "QQ 号(可重复;多个时 supervisor 拉起多账号子进程)", collectQq, []).option("-d, --data-dir <dir>", "数据根目录(缺省 <项目根>/.napuketto)").option("--qq-path <path>", "QQ 安装路径(联调覆盖)").option("--stub-dir <dir>", "stub QQNT.dll 目录(自建宿主 PATH 前置,缺省 loader/native/prebuilt/win32-x64,Git Submodule)");
2483
2463
  program.hook("preAction", () => {
2484
2464
  if (resolveCliLogConfig(rootDataDir(program).dataDir).banner) process$1.stdout.write(`${BANNER}\n`);
package/package.json CHANGED
@@ -1,23 +1,22 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "@napuketto/cli",
4
- "version": "0.7.4",
4
+ "version": "0.8.1",
5
5
  "type": "module",
6
- "description": "Command line interface for NapukettoQQ",
6
+ "description": "Command line interface for Napuketto",
7
7
  "keywords": [
8
- "qq",
9
8
  "bot",
10
9
  "napuketto",
11
10
  "cli",
12
11
  "terminal"
13
12
  ],
14
- "homepage": "https://github.com/NapukettoDev/NapukettoQQ/tree/main/apps/cli#readme",
13
+ "homepage": "https://github.com/NapukettoDev/Napuketto/tree/main/apps/cli#readme",
15
14
  "bugs": {
16
- "url": "https://github.com/NapukettoDev/NapukettoQQ/issues"
15
+ "url": "https://github.com/NapukettoDev/Napuketto/issues"
17
16
  },
18
17
  "repository": {
19
18
  "type": "git",
20
- "url": "git+https://github.com/NapukettoDev/NapukettoQQ.git",
19
+ "url": "git+https://github.com/NapukettoDev/Napuketto.git",
21
20
  "directory": "apps/cli"
22
21
  },
23
22
  "license": "MIT",
@@ -53,10 +52,10 @@
53
52
  "start": "node ./dist/index.mjs"
54
53
  },
55
54
  "dependencies": {
56
- "@napuketto/adapter": "^0.23.0",
57
- "@napuketto/kernel": "^0.18.1",
58
- "@napuketto/loader": "^0.15.0",
59
- "@napuketto/network": "^0.5.0",
55
+ "@napuketto/adapter": "^0.24.0",
56
+ "@napuketto/kernel": "^0.19.1",
57
+ "@napuketto/loader": "^0.16.1",
58
+ "@napuketto/network": "^0.5.1",
60
59
  "commander": "^15.1.0",
61
60
  "uqr": "^0.1.3"
62
61
  },