@ppdocs/mcp 3.2.1 → 3.2.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.
package/dist/cli.d.ts CHANGED
@@ -2,6 +2,6 @@
2
2
  * ppdocs MCP CLI
3
3
  * 命令: init - 初始化项目配置 + 安装工作流模板 + 自动注册 MCP
4
4
  */
5
- export declare function runCli(args: string[]): boolean;
5
+ export declare function runCli(args: string[]): Promise<'exit' | 'keep-alive' | false>;
6
6
  /** 安装项目模板文件 (供授权后自动配置调用) */
7
7
  export declare function setupProjectFiles(cwd: string, apiUrl: string): void;
package/dist/cli.js CHANGED
@@ -112,7 +112,7 @@ Example:
112
112
  npx @ppdocs/mcp init -p myproject -k abc123xyz --sync shared-rules
113
113
  `);
114
114
  }
115
- export function runCli(args) {
115
+ export async function runCli(args) {
116
116
  const cmd = args[0];
117
117
  if (cmd === 'init') {
118
118
  const opts = parseArgs(args.slice(1));
@@ -121,23 +121,17 @@ export function runCli(args) {
121
121
  showHelp();
122
122
  process.exit(1);
123
123
  }
124
- initProject(opts).catch(e => {
125
- console.error(`❌ Init failed: ${e}`);
126
- process.exit(1);
127
- });
128
- return true;
124
+ await initProject(opts);
125
+ return 'exit';
129
126
  }
130
- if (cmd === 'agent') {
131
- // 动态导入 Agent 入口
132
- import('./agent.js').catch(e => {
133
- console.error(`❌ Agent failed: ${e}`);
134
- process.exit(1);
135
- });
136
- return true;
127
+ if (cmd === 'agent' || cmd === 'webui') {
128
+ // 动态导入 Agent 入口 (Web UI + 多项目管理) — 长驻进程,不退出
129
+ await import('./agent.js');
130
+ return 'keep-alive';
137
131
  }
138
132
  if (cmd === '--help' || cmd === '-h' || cmd === 'help') {
139
133
  showHelp();
140
- return true;
134
+ return 'exit';
141
135
  }
142
136
  return false; // Not a CLI command, run as MCP server
143
137
  }
package/dist/index.js CHANGED
@@ -21,8 +21,16 @@ const pkg = JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'package.json'
21
21
  const VERSION = pkg.version;
22
22
  // 检查是否为 CLI 命令
23
23
  const args = process.argv.slice(2);
24
- if (args.length > 0 && runCli(args)) {
25
- process.exit(0);
24
+ if (args.length > 0) {
25
+ const result = await runCli(args);
26
+ if (result === 'exit')
27
+ process.exit(0);
28
+ if (result === 'keep-alive') {
29
+ // agent/webui 长驻模式,不继续执行 MCP Server
30
+ // @ts-ignore: 阻止后续 main() 执行
31
+ await new Promise(() => { }); // 永不 resolve,进程由 agent.ts 的 HTTP 服务保活
32
+ }
33
+ // result === false → 继续作为 MCP Server
26
34
  }
27
35
  // 运行 MCP 服务
28
36
  async function main() {
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "@ppdocs/mcp",
3
- "version": "3.2.1",
3
+ "version": "3.2.3",
4
4
  "description": "ppdocs MCP Server - Knowledge Graph for Claude",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "bin": {
8
+ "ppdocs": "dist/index.js",
8
9
  "mcp": "dist/index.js",
9
10
  "ppdocs-mcp": "dist/index.js",
10
11
  "ppdocs-agent": "dist/agent.js"
@@ -46,4 +47,4 @@
46
47
  "@types/node": "^22.0.0",
47
48
  "typescript": "^5.7.0"
48
49
  }
49
- }
50
+ }