@xiaozhi-client/cli 1.9.8-beta.2 → 1.9.8
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/package.json +6 -2
- package/src/commands/McpCommandHandler.ts +26 -14
- package/src/global.d.ts +0 -4
- package/src/services/ProcessManager.ts +12 -0
- package/tsconfig.json +5 -1
- /package/src/commands/__tests__/{CommandHandlerFactory.test.ts → command-handler-factory.test.ts} +0 -0
- /package/src/commands/__tests__/{CommandRegistry.test.ts → command-registry.test.ts} +0 -0
- /package/src/commands/__tests__/{ConfigCommandHandler.test.ts → config-command-handler.test.ts} +0 -0
- /package/src/commands/__tests__/{EndpointCommandHandler.test.ts → endpoint-command-handler.test.ts} +0 -0
- /package/src/commands/__tests__/{McpCommandHandler.test.ts → mcp-command-handler.test.ts} +0 -0
- /package/src/commands/__tests__/{ProjectCommandHandler.test.ts → project-command-handler.test.ts} +0 -0
- /package/src/commands/__tests__/{ServiceCommands.integration.test.ts → service-commands.integration.test.ts} +0 -0
- /package/src/utils/__tests__/{FormatUtils.test.ts → format-utils.test.ts} +0 -0
- /package/src/utils/__tests__/{PathUtils.test.ts → path-utils.test.ts} +0 -0
- /package/src/utils/__tests__/{Validation.test.ts → validation.test.ts} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xiaozhi-client/cli",
|
|
3
|
-
"version": "1.9.8
|
|
3
|
+
"version": "1.9.8",
|
|
4
4
|
"private": false,
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -17,8 +17,12 @@
|
|
|
17
17
|
"xiaozhi-client": "../../dist/cli/index.js"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
+
"chalk": "^5.6.0",
|
|
21
|
+
"cli-table3": "^0.6.5",
|
|
22
|
+
"commander": "^14.0.0",
|
|
20
23
|
"consola": "^3.4.2",
|
|
21
|
-
"
|
|
24
|
+
"ora": "^8.2.0",
|
|
25
|
+
"@xiaozhi-client/config": "1.9.8"
|
|
22
26
|
},
|
|
23
27
|
"devDependencies": {
|
|
24
28
|
"@types/node": "^24.3.0",
|
|
@@ -634,6 +634,30 @@ export class McpCommandHandler extends BaseCommandHandler {
|
|
|
634
634
|
}
|
|
635
635
|
}
|
|
636
636
|
|
|
637
|
+
/**
|
|
638
|
+
* 验证服务是否存在
|
|
639
|
+
* @param serverName 服务名称
|
|
640
|
+
* @param spinner Ora 加载动画实例
|
|
641
|
+
* @returns 服务是否存在
|
|
642
|
+
* @private
|
|
643
|
+
*/
|
|
644
|
+
private validateServerExists(
|
|
645
|
+
serverName: string,
|
|
646
|
+
spinner: ReturnType<typeof ora>
|
|
647
|
+
): boolean {
|
|
648
|
+
const mcpServers = configManager.getMcpServers();
|
|
649
|
+
|
|
650
|
+
if (!mcpServers[serverName]) {
|
|
651
|
+
spinner.fail(`服务 '${serverName}' 不存在`);
|
|
652
|
+
console.log(
|
|
653
|
+
chalk.yellow("💡 提示: 使用 'xiaozhi mcp list' 查看所有可用服务")
|
|
654
|
+
);
|
|
655
|
+
return false;
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
return true;
|
|
659
|
+
}
|
|
660
|
+
|
|
637
661
|
/**
|
|
638
662
|
* 列出指定服务的工具
|
|
639
663
|
*/
|
|
@@ -641,13 +665,7 @@ export class McpCommandHandler extends BaseCommandHandler {
|
|
|
641
665
|
const spinner = ora(`获取 ${serverName} 服务的工具列表...`).start();
|
|
642
666
|
|
|
643
667
|
try {
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
if (!mcpServers[serverName]) {
|
|
647
|
-
spinner.fail(`服务 '${serverName}' 不存在`);
|
|
648
|
-
console.log(
|
|
649
|
-
chalk.yellow("💡 提示: 使用 'xiaozhi mcp list' 查看所有可用服务")
|
|
650
|
-
);
|
|
668
|
+
if (!this.validateServerExists(serverName, spinner)) {
|
|
651
669
|
return;
|
|
652
670
|
}
|
|
653
671
|
|
|
@@ -729,13 +747,7 @@ export class McpCommandHandler extends BaseCommandHandler {
|
|
|
729
747
|
const spinner = ora(`${action}工具 ${serverName}/${toolName}...`).start();
|
|
730
748
|
|
|
731
749
|
try {
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
if (!mcpServers[serverName]) {
|
|
735
|
-
spinner.fail(`服务 '${serverName}' 不存在`);
|
|
736
|
-
console.log(
|
|
737
|
-
chalk.yellow("💡 提示: 使用 'xiaozhi mcp list' 查看所有可用服务")
|
|
738
|
-
);
|
|
750
|
+
if (!this.validateServerExists(serverName, spinner)) {
|
|
739
751
|
return;
|
|
740
752
|
}
|
|
741
753
|
|
package/src/global.d.ts
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 进程管理服务
|
|
3
|
+
*
|
|
4
|
+
* 负责管理 xiaozhi 服务的进程生命周期,包括:
|
|
5
|
+
* - 进程启动和停止
|
|
6
|
+
* - PID 文件管理
|
|
7
|
+
* - 进程状态查询
|
|
8
|
+
* - 优雅关闭进程
|
|
9
|
+
*
|
|
10
|
+
* @module packages/cli/src/services/ProcessManager
|
|
11
|
+
*/
|
|
12
|
+
|
|
1
13
|
import { FileError, ProcessError } from "../errors/index";
|
|
2
14
|
import type {
|
|
3
15
|
ProcessManager as IProcessManager,
|
package/tsconfig.json
CHANGED
|
@@ -7,5 +7,9 @@
|
|
|
7
7
|
},
|
|
8
8
|
"include": ["src/**/*.ts"],
|
|
9
9
|
"exclude": ["node_modules", "dist", "**/*.test.ts"],
|
|
10
|
-
"references": [
|
|
10
|
+
"references": [
|
|
11
|
+
{ "path": "../../apps/backend" },
|
|
12
|
+
{ "path": "../config" },
|
|
13
|
+
{ "path": "../version" }
|
|
14
|
+
]
|
|
11
15
|
}
|
/package/src/commands/__tests__/{CommandHandlerFactory.test.ts → command-handler-factory.test.ts}
RENAMED
|
File without changes
|
|
File without changes
|
/package/src/commands/__tests__/{ConfigCommandHandler.test.ts → config-command-handler.test.ts}
RENAMED
|
File without changes
|
/package/src/commands/__tests__/{EndpointCommandHandler.test.ts → endpoint-command-handler.test.ts}
RENAMED
|
File without changes
|
|
File without changes
|
/package/src/commands/__tests__/{ProjectCommandHandler.test.ts → project-command-handler.test.ts}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|