@xiaozhi-client/cli 1.9.4-beta.10 → 1.9.4-beta.11

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/README.md CHANGED
@@ -76,7 +76,7 @@ import { configManager } from "@/lib/config/manager";
76
76
  pnpm build
77
77
 
78
78
  # 类型检查
79
- pnpm type-check
79
+ pnpm check:type
80
80
 
81
81
  # 运行测试
82
82
  pnpm test
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xiaozhi-client/cli",
3
- "version": "1.9.4-beta.10",
3
+ "version": "1.9.4-beta.11",
4
4
  "private": false,
5
5
  "repository": {
6
6
  "type": "git",
package/src/Container.ts CHANGED
@@ -140,18 +140,18 @@ export class DIContainer implements IDIContainer {
140
140
 
141
141
  // 注册服务层
142
142
  container.registerSingleton("processManager", () => {
143
- const ProcessManagerModule = require("@cli/services/ProcessManager.js");
143
+ const ProcessManagerModule = require("./services/ProcessManager.js");
144
144
  return new ProcessManagerModule.ProcessManagerImpl();
145
145
  });
146
146
 
147
147
  container.registerSingleton("daemonManager", () => {
148
- const DaemonManagerModule = require("@cli/services/DaemonManager.js");
148
+ const DaemonManagerModule = require("./services/DaemonManager.js");
149
149
  const processManager = container.get("processManager") as any;
150
150
  return new DaemonManagerModule.DaemonManagerImpl(processManager);
151
151
  });
152
152
 
153
153
  container.registerSingleton("serviceManager", () => {
154
- const ServiceManagerModule = require("@cli/services/ServiceManager.js");
154
+ const ServiceManagerModule = require("./services/ServiceManager.js");
155
155
  const processManager = container.get("processManager") as any;
156
156
  const configManager = container.get("configManager") as any;
157
157
  return new ServiceManagerModule.ServiceManagerImpl(
@@ -162,7 +162,7 @@ export class DIContainer implements IDIContainer {
162
162
 
163
163
  container.registerSingleton("templateManager", () => {
164
164
  // 使用动态导入的同步版本
165
- const TemplateManagerModule = require("@cli/services/TemplateManager.js");
165
+ const TemplateManagerModule = require("./services/TemplateManager.js");
166
166
  return new TemplateManagerModule.TemplateManagerImpl();
167
167
  });
168
168
 
@@ -52,9 +52,7 @@ export class CommandHandlerFactory implements ICommandHandlerFactory {
52
52
  */
53
53
  private createServiceCommandHandler(): CommandHandler {
54
54
  // 动态导入以避免循环依赖
55
- const {
56
- ServiceCommandHandler,
57
- } = require("@cli/commands/ServiceCommandHandler.js");
55
+ const { ServiceCommandHandler } = require("./ServiceCommandHandler.js");
58
56
  return new ServiceCommandHandler(this.container);
59
57
  }
60
58
 
@@ -62,9 +60,7 @@ export class CommandHandlerFactory implements ICommandHandlerFactory {
62
60
  * 创建配置命令处理器
63
61
  */
64
62
  private createConfigCommandHandler(): CommandHandler {
65
- const {
66
- ConfigCommandHandler,
67
- } = require("@cli/commands/ConfigCommandHandler.js");
63
+ const { ConfigCommandHandler } = require("./ConfigCommandHandler.js");
68
64
  return new ConfigCommandHandler(this.container);
69
65
  }
70
66
 
@@ -72,9 +68,7 @@ export class CommandHandlerFactory implements ICommandHandlerFactory {
72
68
  * 创建项目命令处理器
73
69
  */
74
70
  private createProjectCommandHandler(): CommandHandler {
75
- const {
76
- ProjectCommandHandler,
77
- } = require("@cli/commands/ProjectCommandHandler.js");
71
+ const { ProjectCommandHandler } = require("./ProjectCommandHandler.js");
78
72
  return new ProjectCommandHandler(this.container);
79
73
  }
80
74
 
@@ -82,7 +76,7 @@ export class CommandHandlerFactory implements ICommandHandlerFactory {
82
76
  * 创建MCP命令处理器
83
77
  */
84
78
  private createMcpCommandHandler(): CommandHandler {
85
- const { McpCommandHandler } = require("@cli/commands/McpCommandHandler.js");
79
+ const { McpCommandHandler } = require("./McpCommandHandler.js");
86
80
  return new McpCommandHandler(this.container);
87
81
  }
88
82
 
@@ -90,9 +84,7 @@ export class CommandHandlerFactory implements ICommandHandlerFactory {
90
84
  * 创建端点命令处理器
91
85
  */
92
86
  private createEndpointCommandHandler(): CommandHandler {
93
- const {
94
- EndpointCommandHandler,
95
- } = require("@cli/commands/EndpointCommandHandler.js");
87
+ const { EndpointCommandHandler } = require("./EndpointCommandHandler.js");
96
88
  return new EndpointCommandHandler(this.container);
97
89
  }
98
90
  }
@@ -79,7 +79,7 @@ export class ServiceCommandHandler extends BaseCommandHandler {
79
79
  try {
80
80
  // 处理--debug参数
81
81
  if (options.debug) {
82
- consola.level = "debug";
82
+ consola.level = 5; // debug 级别
83
83
  }
84
84
 
85
85
  const serviceManager = this.getService<any>("serviceManager");
@@ -1,4 +1,3 @@
1
- import type { IDIContainer } from "@cli/interfaces/Config.js";
2
1
  import { configManager } from "@xiaozhi-client/config";
3
2
  import type {
4
3
  MCPServerConfig,
@@ -7,6 +6,7 @@ import type {
7
6
  } from "@xiaozhi-client/config";
8
7
  import ora from "ora";
9
8
  import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
9
+ import type { IDIContainer } from "../../interfaces/Config.js";
10
10
  import { McpCommandHandler } from "../McpCommandHandler.js";
11
11
 
12
12
  // 测试专用类型定义
@@ -143,7 +143,7 @@ const mockGetServiceStatus = vi
143
143
  .fn()
144
144
  .mockReturnValue({ running: false, pid: null });
145
145
 
146
- vi.mock("@cli/services/ProcessManager.js", () => ({
146
+ vi.mock("../../services/ProcessManager.js", () => ({
147
147
  ProcessManagerImpl: vi.fn().mockImplementation(() => ({
148
148
  getServiceStatus: mockGetServiceStatus,
149
149
  })),
@@ -2,10 +2,10 @@
2
2
  * 守护进程管理服务单元测试
3
3
  */
4
4
 
5
- import { ServiceError } from "@cli/errors/index.js";
6
- import type { ProcessManager } from "@cli/interfaces/Service.js";
7
5
  import consola from "consola";
8
6
  import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
7
+ import { ServiceError } from "../../errors/index.js";
8
+ import type { ProcessManager } from "../../interfaces/Service.js";
9
9
  import type { DaemonOptions } from "../DaemonManager";
10
10
  import { DaemonManagerImpl } from "../DaemonManager";
11
11
 
@@ -49,7 +49,7 @@ vi.mock("node:fs", () => ({
49
49
  }));
50
50
 
51
51
  // Mock utils
52
- vi.mock("@cli/utils/PathUtils.js", () => ({
52
+ vi.mock("../../utils/PathUtils.js", () => ({
53
53
  PathUtils: {
54
54
  getWebServerLauncherPath: vi.fn(() => "/path/to/webserver.js"),
55
55
  getConfigDir: vi.fn(() => "/config"),
@@ -57,7 +57,7 @@ vi.mock("@cli/utils/PathUtils.js", () => ({
57
57
  },
58
58
  }));
59
59
 
60
- vi.mock("@cli/utils/PlatformUtils.js", () => ({
60
+ vi.mock("../../utils/PlatformUtils.js", () => ({
61
61
  PlatformUtils: {
62
62
  getTailCommand: vi.fn(() => ({
63
63
  command: "tail",
@@ -1,6 +1,6 @@
1
- import type { ServiceStartOptions } from "@cli/interfaces/Service.js";
2
- import { PathUtils } from "@cli/utils/PathUtils.js";
3
1
  import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
2
+ import type { ServiceStartOptions } from "../../interfaces/Service.js";
3
+ import { PathUtils } from "../../utils/PathUtils.js";
4
4
  import { ServiceManagerImpl } from "../ServiceManager";
5
5
 
6
6
  // Mock external dependencies
@@ -19,7 +19,7 @@ vi.mock("node:fs", () => ({
19
19
  mkdirSync: vi.fn(),
20
20
  }));
21
21
 
22
- vi.mock("@cli/utils/PathUtils.js", () => ({
22
+ vi.mock("../../utils/PathUtils.js", () => ({
23
23
  PathUtils: {
24
24
  getWebServerLauncherPath: vi.fn(),
25
25
  getExecutablePath: vi.fn(),
@@ -2,16 +2,16 @@
2
2
  * 进程管理服务单元测试
3
3
  */
4
4
 
5
- import { FileUtils } from "@cli/utils/FileUtils.js";
6
- import { PathUtils } from "@cli/utils/PathUtils.js";
7
- import { PlatformUtils } from "@cli/utils/PlatformUtils.js";
8
5
  import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
6
+ import { FileUtils } from "../../utils/FileUtils.js";
7
+ import { PathUtils } from "../../utils/PathUtils.js";
8
+ import { PlatformUtils } from "../../utils/PlatformUtils.js";
9
9
  import { ProcessManagerImpl } from "../ProcessManager";
10
10
 
11
11
  // Mock 依赖
12
- vi.mock("@cli/utils/FileUtils.js");
13
- vi.mock("@cli/utils/PathUtils.js");
14
- vi.mock("@cli/utils/PlatformUtils.js");
12
+ vi.mock("../../utils/FileUtils.js");
13
+ vi.mock("../../utils/PathUtils.js");
14
+ vi.mock("../../utils/PlatformUtils.js");
15
15
 
16
16
  const mockFileUtils = vi.mocked(FileUtils);
17
17
  const mockPathUtils = vi.mocked(PathUtils);
@@ -2,12 +2,12 @@
2
2
  * 服务管理服务单元测试
3
3
  */
4
4
 
5
- import { ConfigError, ServiceError } from "@cli/errors/index.js";
5
+ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
6
+ import { ConfigError, ServiceError } from "../../errors/index.js";
6
7
  import type {
7
8
  ProcessManager,
8
9
  ServiceStartOptions,
9
- } from "@cli/interfaces/Service.js";
10
- import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
10
+ } from "../../interfaces/Service.js";
11
11
  import { ServiceManagerImpl } from "../ServiceManager";
12
12
 
13
13
  // Mock 依赖
@@ -62,7 +62,7 @@ vi.mock("@services/MCPServer.js", () => ({
62
62
  }));
63
63
 
64
64
  // Mock PathUtils
65
- vi.mock("@cli/utils/PathUtils.js", () => ({
65
+ vi.mock("../../utils/PathUtils.js", () => ({
66
66
  PathUtils: {
67
67
  getWebServerLauncherPath: vi
68
68
  .fn()
@@ -158,7 +158,7 @@ describe("ServiceManagerImpl 服务管理器实现", () => {
158
158
  mockProcessExit.mockClear();
159
159
 
160
160
  // Reset PathUtils mocks
161
- const { PathUtils } = await import("@cli/utils/PathUtils.js");
161
+ const { PathUtils } = await import("../../utils/PathUtils.js");
162
162
  vi.mocked(PathUtils.getWebServerLauncherPath).mockReturnValue(
163
163
  "/mock/path/WebServerLauncher.js"
164
164
  );
@@ -2,20 +2,20 @@
2
2
  * 模板管理服务单元测试
3
3
  */
4
4
 
5
- import { FileError, ValidationError } from "@cli/errors/index.js";
6
5
  import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
6
+ import { FileError, ValidationError } from "../../errors/index.js";
7
7
  import type { TemplateCreateOptions } from "../TemplateManager";
8
8
  import { TemplateManagerImpl } from "../TemplateManager";
9
9
 
10
10
  // Mock 依赖
11
- vi.mock("@cli/utils/PathUtils.js", () => ({
11
+ vi.mock("../../utils/PathUtils.js", () => ({
12
12
  PathUtils: {
13
13
  findTemplatesDir: vi.fn(),
14
14
  getTemplatePath: vi.fn(),
15
15
  },
16
16
  }));
17
17
 
18
- vi.mock("@cli/utils/FileUtils.js", () => ({
18
+ vi.mock("../../utils/FileUtils.js", () => ({
19
19
  FileUtils: {
20
20
  exists: vi.fn(),
21
21
  readFile: vi.fn(),
@@ -26,7 +26,7 @@ vi.mock("@cli/utils/FileUtils.js", () => ({
26
26
  },
27
27
  }));
28
28
 
29
- vi.mock("@cli/utils/Validation.js", () => ({
29
+ vi.mock("../../utils/Validation.js", () => ({
30
30
  Validation: {
31
31
  validateTemplateName: vi.fn(),
32
32
  validateRequired: vi.fn(),
@@ -48,9 +48,9 @@ vi.mock("node:path", () => ({
48
48
  },
49
49
  }));
50
50
 
51
- const { PathUtils } = await import("@cli/utils/PathUtils.js");
52
- const { FileUtils } = await import("@cli/utils/FileUtils.js");
53
- const { Validation } = await import("@cli/utils/Validation.js");
51
+ const { PathUtils } = await import("../../utils/PathUtils.js");
52
+ const { FileUtils } = await import("../../utils/FileUtils.js");
53
+ const { Validation } = await import("../../utils/Validation.js");
54
54
  const fs = await import("node:fs");
55
55
 
56
56
  describe("TemplateManagerImpl", () => {
@@ -2,11 +2,11 @@ import { realpathSync } from "node:fs";
2
2
  import { tmpdir } from "node:os";
3
3
  import path from "node:path";
4
4
  import { fileURLToPath } from "node:url";
5
- import { PathUtils } from "@cli/utils/PathUtils.js";
6
5
  import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
6
+ import { PathUtils } from "../PathUtils.js";
7
7
 
8
8
  // Mock dependencies - 需要使用与源文件相同的导入方式
9
- vi.mock("@cli/utils/FileUtils.js", () => ({
9
+ vi.mock("../FileUtils.js", () => ({
10
10
  FileUtils: {
11
11
  exists: vi.fn(),
12
12
  },
@@ -38,7 +38,7 @@ describe("PathUtils 路径工具", () => {
38
38
  vi.clearAllMocks();
39
39
 
40
40
  // Setup mocks
41
- const { FileUtils } = await import("@cli/utils/FileUtils.js");
41
+ const { FileUtils } = await import("../FileUtils.js");
42
42
  mockFileExists = vi.mocked(FileUtils.exists);
43
43
  mockTmpdir = vi.mocked(tmpdir);
44
44
  mockFileURLToPath = vi.mocked(fileURLToPath);
package/tsconfig.json CHANGED
@@ -1,32 +1,11 @@
1
1
  {
2
+ "extends": "../../tsconfig.json",
2
3
  "compilerOptions": {
3
- "target": "ES2022",
4
- "module": "ESNext",
5
- "moduleResolution": "bundler",
6
- "lib": ["ES2022"],
7
- "strict": false,
8
- "esModuleInterop": true,
9
- "skipLibCheck": true,
10
- "forceConsistentCasingInFileNames": true,
11
- "resolveJsonModule": true,
12
- "allowSyntheticDefaultImports": true,
13
- "noEmit": true,
14
- "baseUrl": ".",
15
- "moduleSuffixes": [".ts", ".js"],
16
- "paths": {
17
- "@/*": ["src/*"],
18
- "@cli/commands": ["src/commands"],
19
- "@cli/commands/*": ["src/commands/*"],
20
- "@cli/services": ["src/services"],
21
- "@cli/services/*": ["src/services/*"],
22
- "@cli/utils": ["src/utils"],
23
- "@cli/utils/*": ["src/utils/*"],
24
- "@cli/errors": ["src/errors"],
25
- "@cli/errors/*": ["src/errors/*"],
26
- "@cli/interfaces": ["src/interfaces"],
27
- "@cli/interfaces/*": ["src/interfaces/*"]
28
- }
4
+ "composite": true,
5
+ "outDir": "../../dist/cli",
6
+ "rootDir": "src"
29
7
  },
30
8
  "include": ["src/**/*.ts"],
31
- "exclude": ["node_modules", "dist", "**/*.test.ts", "**/*.spec.ts"]
9
+ "exclude": ["node_modules", "dist", "**/*.test.ts"],
10
+ "references": [{ "path": "../../apps/backend" }, { "path": "../config" }]
32
11
  }
package/vitest.config.ts CHANGED
@@ -46,17 +46,6 @@ export default defineConfig({
46
46
  },
47
47
  resolve: {
48
48
  alias: {
49
- // CLI 内部路径别名(__dirname 是 packages/cli,所以使用相对路径)
50
- "@cli/commands": resolve(__dirname, "./src/commands"),
51
- "@cli/commands/*": resolve(__dirname, "./src/commands/*"),
52
- "@cli/services": resolve(__dirname, "./src/services"),
53
- "@cli/services/*": resolve(__dirname, "./src/services/*"),
54
- "@cli/utils": resolve(__dirname, "./src/utils"),
55
- "@cli/utils/*": resolve(__dirname, "./src/utils/*"),
56
- "@cli/errors": resolve(__dirname, "./src/errors"),
57
- "@cli/errors/*": resolve(__dirname, "./src/errors/*"),
58
- "@cli/interfaces": resolve(__dirname, "./src/interfaces"),
59
- "@cli/interfaces/*": resolve(__dirname, "./src/interfaces/*"),
60
49
  // Backend 路径别名(从 packages/cli 向上到项目根目录)
61
50
  "@handlers": resolve(__dirname, "../../apps/backend/handlers"),
62
51
  "@handlers/*": resolve(__dirname, "../../apps/backend/handlers/*"),