@ppdocs/mcp 3.1.10 → 3.2.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.
- package/dist/agent.d.ts +6 -0
- package/dist/agent.js +130 -0
- package/dist/cli.js +9 -0
- package/dist/config.d.ts +1 -1
- package/dist/config.js +4 -40
- package/dist/index.js +1 -1
- package/dist/storage/discussion.d.ts +33 -0
- package/dist/storage/discussion.js +116 -0
- package/dist/storage/httpClient.d.ts +8 -0
- package/dist/storage/httpClient.js +29 -0
- package/dist/tools/analyzer.d.ts +8 -0
- package/dist/tools/analyzer.js +136 -0
- package/dist/tools/discussion.d.ts +7 -0
- package/dist/tools/discussion.js +111 -0
- package/dist/tools/docs.d.ts +3 -3
- package/dist/tools/docs.js +205 -175
- package/dist/tools/files.d.ts +3 -3
- package/dist/tools/files.js +61 -56
- package/dist/tools/index.d.ts +6 -1
- package/dist/tools/index.js +18 -3
- package/dist/tools/kg_status.d.ts +5 -0
- package/dist/tools/kg_status.js +42 -0
- package/dist/tools/projects.d.ts +3 -2
- package/dist/tools/projects.js +4 -40
- package/dist/tools/rules.d.ts +3 -3
- package/dist/tools/rules.js +88 -110
- package/dist/tools/tasks.d.ts +2 -2
- package/dist/tools/tasks.js +96 -73
- package/dist/web/server.d.ts +43 -0
- package/dist/web/server.js +611 -0
- package/dist/web/ui.d.ts +5 -0
- package/dist/web/ui.js +474 -0
- package/package.json +7 -3
package/dist/tools/tasks.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* task_create, task_get, task_update, task_archive
|
|
2
|
+
* 📝 kg_task (4→1)
|
|
3
|
+
* 合并: task_create, task_get, task_update, task_archive
|
|
4
4
|
*/
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
import { getClient } from '../storage/httpClient.js';
|
|
@@ -8,79 +8,102 @@ import { decodeObjectStrings } from '../utils.js';
|
|
|
8
8
|
import { wrap, safeTool } from './shared.js';
|
|
9
9
|
export function registerTaskTools(server, projectId, user) {
|
|
10
10
|
const client = () => getClient();
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
server.tool('kg_task', '📝 任务管理 — 创建、查询、更新进展、归档。action: create(创建)|get(查询)|update(添加日志)|archive(归档)', {
|
|
12
|
+
action: z.enum(['create', 'get', 'update', 'archive'])
|
|
13
|
+
.describe('操作类型'),
|
|
14
|
+
title: z.string().optional()
|
|
15
|
+
.describe('任务标题 (create/get)'),
|
|
16
|
+
description: z.string().optional()
|
|
17
|
+
.describe('任务描述Markdown (create)'),
|
|
18
|
+
goals: z.array(z.string()).optional()
|
|
19
|
+
.describe('目标清单 (create)'),
|
|
20
|
+
taskId: z.string().optional()
|
|
21
|
+
.describe('任务ID (update/archive)'),
|
|
22
|
+
log_type: z.enum(['progress', 'issue', 'solution', 'reference']).optional()
|
|
23
|
+
.describe('日志类型 (update)'),
|
|
24
|
+
content: z.string().optional()
|
|
25
|
+
.describe('日志内容Markdown (update)'),
|
|
26
|
+
summary: z.string().optional()
|
|
27
|
+
.describe('经验总结Markdown (archive)'),
|
|
28
|
+
difficulties: z.array(z.string()).optional()
|
|
29
|
+
.describe('遇到的困难 (archive)'),
|
|
30
|
+
solutions: z.array(z.string()).optional()
|
|
31
|
+
.describe('解决方案 (archive)'),
|
|
32
|
+
status: z.enum(['active', 'archived', 'all']).optional()
|
|
33
|
+
.describe('状态筛选 (get, 默认all)'),
|
|
16
34
|
}, async (args) => safeTool(async () => {
|
|
17
35
|
const decoded = decodeObjectStrings(args);
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
36
|
+
switch (decoded.action) {
|
|
37
|
+
case 'create': {
|
|
38
|
+
if (!decoded.title)
|
|
39
|
+
return wrap('❌ create 需要 title');
|
|
40
|
+
if (!decoded.description)
|
|
41
|
+
return wrap('❌ create 需要 description');
|
|
42
|
+
const task = await client().createTask({
|
|
43
|
+
title: decoded.title,
|
|
44
|
+
description: decoded.description,
|
|
45
|
+
goals: decoded.goals || []
|
|
46
|
+
}, user);
|
|
47
|
+
return wrap(JSON.stringify(task, null, 2));
|
|
48
|
+
}
|
|
49
|
+
case 'get': {
|
|
50
|
+
if (!decoded.title)
|
|
51
|
+
return wrap('❌ get 需要 title');
|
|
52
|
+
const filterStatus = decoded.status || 'all';
|
|
53
|
+
const searchTitle = decoded.title.toLowerCase();
|
|
54
|
+
let tasks;
|
|
55
|
+
if (filterStatus === 'all') {
|
|
56
|
+
const [active, archived] = await Promise.all([
|
|
57
|
+
client().listTasks('active'),
|
|
58
|
+
client().listTasks('archived')
|
|
59
|
+
]);
|
|
60
|
+
tasks = [...active, ...archived];
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
tasks = await client().listTasks(filterStatus);
|
|
64
|
+
}
|
|
65
|
+
const matched = tasks.filter(t => t.title.toLowerCase().includes(searchTitle));
|
|
66
|
+
if (matched.length === 0)
|
|
67
|
+
return wrap(`未找到匹配 "${decoded.title}" 的任务`);
|
|
68
|
+
if (matched.length === 1) {
|
|
69
|
+
const task = await client().getTask(matched[0].id);
|
|
70
|
+
return wrap(task ? JSON.stringify(task, null, 2) : '任务详情获取失败');
|
|
71
|
+
}
|
|
72
|
+
const list = matched.map(t => ({
|
|
73
|
+
id: t.id, title: t.title, status: t.status,
|
|
74
|
+
creator: t.creator, created_at: t.created_at
|
|
75
|
+
}));
|
|
76
|
+
return wrap(`找到 ${matched.length} 个匹配任务:\n${JSON.stringify(list, null, 2)}\n\n请提供更精确的任务名称`);
|
|
77
|
+
}
|
|
78
|
+
case 'update': {
|
|
79
|
+
if (!decoded.taskId)
|
|
80
|
+
return wrap('❌ update 需要 taskId');
|
|
81
|
+
if (!decoded.log_type)
|
|
82
|
+
return wrap('❌ update 需要 log_type');
|
|
83
|
+
if (!decoded.content)
|
|
84
|
+
return wrap('❌ update 需要 content');
|
|
85
|
+
const task = await client().addTaskLog(decoded.taskId, decoded.log_type, decoded.content);
|
|
86
|
+
if (!task)
|
|
87
|
+
return wrap('更新失败(任务不存在或已归档)');
|
|
88
|
+
return wrap(`✅ 日志已添加,任务共有 ${task.logs.length} 条日志`);
|
|
89
|
+
}
|
|
90
|
+
case 'archive': {
|
|
91
|
+
if (!decoded.taskId)
|
|
92
|
+
return wrap('❌ archive 需要 taskId');
|
|
93
|
+
if (!decoded.summary)
|
|
94
|
+
return wrap('❌ archive 需要 summary');
|
|
95
|
+
const task = await client().completeTask(decoded.taskId, {
|
|
96
|
+
summary: decoded.summary,
|
|
97
|
+
difficulties: decoded.difficulties || [],
|
|
98
|
+
solutions: decoded.solutions || [],
|
|
99
|
+
references: []
|
|
100
|
+
});
|
|
101
|
+
if (!task)
|
|
102
|
+
return wrap('归档失败(任务不存在或已归档)');
|
|
103
|
+
return wrap(`✅ 任务已归档: ${task.title}`);
|
|
104
|
+
}
|
|
105
|
+
default:
|
|
106
|
+
return wrap(`❌ 未知 action: ${decoded.action}`);
|
|
42
107
|
}
|
|
43
|
-
const matched = tasks.filter(t => t.title.toLowerCase().includes(searchTitle));
|
|
44
|
-
if (matched.length === 0)
|
|
45
|
-
return wrap(`未找到匹配 "${args.title}" 的任务`);
|
|
46
|
-
if (matched.length === 1) {
|
|
47
|
-
const task = await client().getTask(matched[0].id);
|
|
48
|
-
return wrap(task ? JSON.stringify(task, null, 2) : '任务详情获取失败');
|
|
49
|
-
}
|
|
50
|
-
const list = matched.map(t => ({
|
|
51
|
-
id: t.id, title: t.title, status: t.status,
|
|
52
|
-
creator: t.creator, created_at: t.created_at
|
|
53
|
-
}));
|
|
54
|
-
return wrap(`找到 ${matched.length} 个匹配任务:\n${JSON.stringify(list, null, 2)}\n\n请提供更精确的任务名称`);
|
|
55
|
-
}));
|
|
56
|
-
// 更新任务
|
|
57
|
-
server.tool('task_update', '更新任务(添加进展日志)', {
|
|
58
|
-
taskId: z.string().describe('任务ID'),
|
|
59
|
-
log_type: z.enum(['progress', 'issue', 'solution', 'reference']).describe('日志类型: progress=进展, issue=问题, solution=方案, reference=参考'),
|
|
60
|
-
content: z.string().describe('日志内容(Markdown)')
|
|
61
|
-
}, async (args) => safeTool(async () => {
|
|
62
|
-
const decoded = decodeObjectStrings(args);
|
|
63
|
-
const task = await client().addTaskLog(args.taskId, decoded.log_type, decoded.content);
|
|
64
|
-
if (!task)
|
|
65
|
-
return wrap('更新失败(任务不存在或已归档)');
|
|
66
|
-
return wrap(`✅ 日志已添加,任务共有 ${task.logs.length} 条日志`);
|
|
67
|
-
}));
|
|
68
|
-
// 归档任务
|
|
69
|
-
server.tool('task_archive', '归档任务(完成并填写经验总结)', {
|
|
70
|
-
taskId: z.string().describe('任务ID'),
|
|
71
|
-
summary: z.string().describe('经验总结(Markdown)'),
|
|
72
|
-
difficulties: z.array(z.string()).optional().describe('遇到的困难'),
|
|
73
|
-
solutions: z.array(z.string()).optional().describe('解决方案')
|
|
74
|
-
}, async (args) => safeTool(async () => {
|
|
75
|
-
const decoded = decodeObjectStrings(args);
|
|
76
|
-
const task = await client().completeTask(args.taskId, {
|
|
77
|
-
summary: decoded.summary,
|
|
78
|
-
difficulties: decoded.difficulties || [],
|
|
79
|
-
solutions: decoded.solutions || [],
|
|
80
|
-
references: []
|
|
81
|
-
});
|
|
82
|
-
if (!task)
|
|
83
|
-
return wrap('归档失败(任务不存在或已归档)');
|
|
84
|
-
return wrap(`✅ 任务已归档: ${task.title}`);
|
|
85
108
|
}));
|
|
86
109
|
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PPDocs Agent V2 — Web Config Server
|
|
3
|
+
* 多项目管理 + 智能匹配 + 知识图谱预览 + MCP 安装
|
|
4
|
+
*/
|
|
5
|
+
export interface ProjectBinding {
|
|
6
|
+
localDir: string;
|
|
7
|
+
localName: string;
|
|
8
|
+
remote: {
|
|
9
|
+
id: string;
|
|
10
|
+
name: string;
|
|
11
|
+
password: string;
|
|
12
|
+
};
|
|
13
|
+
sync: {
|
|
14
|
+
enabled: boolean;
|
|
15
|
+
intervalSec: number;
|
|
16
|
+
};
|
|
17
|
+
createdAt: string;
|
|
18
|
+
}
|
|
19
|
+
export interface AgentConfig {
|
|
20
|
+
host: string;
|
|
21
|
+
port: number;
|
|
22
|
+
webPort: number;
|
|
23
|
+
projects: ProjectBinding[];
|
|
24
|
+
}
|
|
25
|
+
export declare function loadAgentConfig(): AgentConfig | null;
|
|
26
|
+
export declare function saveAgentConfig(config: AgentConfig): void;
|
|
27
|
+
interface ProjectStatus {
|
|
28
|
+
connected: boolean;
|
|
29
|
+
syncStatus: string;
|
|
30
|
+
lastSync: Date | null;
|
|
31
|
+
docCount?: number;
|
|
32
|
+
}
|
|
33
|
+
interface AgentState {
|
|
34
|
+
hostConnected: boolean;
|
|
35
|
+
projectStatus: Map<string, ProjectStatus>;
|
|
36
|
+
onBind?: (project: ProjectBinding) => void;
|
|
37
|
+
onUnbind?: (remoteId: string) => void;
|
|
38
|
+
}
|
|
39
|
+
export declare function getAgentState(): AgentState;
|
|
40
|
+
export declare function setAgentState(partial: Partial<AgentState>): void;
|
|
41
|
+
export declare function setProjectStatus(remoteId: string, status: Partial<ProjectStatus>): void;
|
|
42
|
+
export declare function startWebServer(webPort: number): void;
|
|
43
|
+
export {};
|