@8btc/ppt-generator-mcp 0.0.32-beta.3 → 0.0.32-beta.5

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.
@@ -63,7 +63,71 @@ const t = zod_1.z.object({ ...inputSchema });
63
63
  const tool = {
64
64
  name: "generate_ppt",
65
65
  title: "ppt生成工具",
66
- description: "根据大纲自动匹配模板生成PPT文件",
66
+ description: `
67
+ ## generate_ppt参数outline的要求
68
+ 1. 严格按照以下JSON格式生成:
69
+ - cover: 封面页,包含title和text
70
+ - contents: 目录页,包含items数组
71
+ - transition: 过渡页,包含title和text
72
+ - content: 内容页,包含title和items数组,每个item包含title和text
73
+ - end: 结束页
74
+
75
+ 2. 内容要求:
76
+ - **章节数量**:整个PPT的目录控制生成 2-4 个章节(即ppt的目录页控制2-4个具体目录)
77
+ - **页数控制**:用户未指定生成总页数,控制在8-15页
78
+ - **要点精炼**:每个内容页的 \`items\` 数组中,每个要点的 \`title\` 必须是高度提炼的短句(每个章节包含1-4个要点),长度不超过 15 个字符,每个要点的 \`text\` 要点的详细内容介绍可以有更多内容介绍。符合PPT标题简洁,内容充裕的原则。
79
+ - **逻辑性**:内容必须严格遵循**总-分-总**的逻辑结构,确保章节间过渡自然。
80
+ - **专业性**:内容要专业、有逻辑性,并能直接支持演示文稿使用。
81
+ - time取get_timely_info的结果中的now_data_time值
82
+ - **文档结构严格遵循**:封面页 → 目录页 → 过渡页 → 内容页 → 结束页
83
+
84
+ 参考格式示例(请根据实际主题调整内容):
85
+ \`\`\`json
86
+ [
87
+ {
88
+ "type": "cover",
89
+ "data": {
90
+ "title": "主题标题",
91
+ "text": "副标题或简介"
92
+ }
93
+ },
94
+ {
95
+ "type": "contents",
96
+ "data": {
97
+ "items": ["章节1", "章节2", "章节3"]
98
+ }
99
+ },
100
+ {
101
+ "type": "transition",
102
+ "data": {
103
+ "title": "章节标题",
104
+ "text": "章节介绍"
105
+ }
106
+ },
107
+ {
108
+ "type": "content",
109
+ "data": {
110
+ "title": "具体内容标题",
111
+ "items": [
112
+ {
113
+ "title": "要点1",
114
+ "text": "要点1的详细说明"
115
+ }
116
+ ],
117
+ "images": [
118
+ {
119
+ "imageType": "pageFigure",
120
+ "src": "http://www.exp.com/xxx.png"
121
+ }
122
+ ]
123
+ }
124
+ },
125
+ {
126
+ "type": "end"
127
+ }
128
+ ]
129
+ \`\`\`
130
+ `,
67
131
  inputSchema: (0, schema_1.zodToJsonSchema)(inputSchema),
68
132
  };
69
133
  const toolHandler = async ({ outline, templateFilePath, outputPath, }) => {
@@ -79,8 +143,11 @@ const toolHandler = async ({ outline, templateFilePath, outputPath, }) => {
79
143
  outputPath = node_path_1.default.resolve(outputPath);
80
144
  try {
81
145
  fs_extra_1.default.ensureDirSync(outputPath);
146
+ // 以cover的title为文件名
147
+ const coverItem = outline.find((it) => it.type === "cover");
148
+ const fileName = (coverItem?.data?.title || "未命名演示文稿").replace(/\s+/g, "");
82
149
  // 保存result.json
83
- await fs_extra_1.default.writeJson(node_path_1.default.join(outputPath, "outline.json"), outline, {
150
+ await fs_extra_1.default.writeJson(node_path_1.default.join(outputPath, `${fileName}_outline.json`), outline, {
84
151
  spaces: 2,
85
152
  });
86
153
  // 读取模板文件
@@ -91,19 +158,16 @@ const toolHandler = async ({ outline, templateFilePath, outputPath, }) => {
91
158
  templateData: templateData,
92
159
  });
93
160
  // 保存result.json
94
- await fs_extra_1.default.writeJson(node_path_1.default.join(outputPath, "result.json"), resultJSON, {
161
+ await fs_extra_1.default.writeJson(node_path_1.default.join(outputPath, `${fileName}_result.json`), resultJSON, {
95
162
  spaces: 2,
96
163
  });
97
164
  if (!resultJSON) {
98
165
  console.error("generate_result_json 生成 result.json 失败");
99
- throw new types_js_1.McpError(types_js_1.ErrorCode.InternalError, "生成result.json失败");
166
+ throw new types_js_1.McpError(types_js_1.ErrorCode.InternalError, `生成${fileName}_result.json失败`);
100
167
  }
101
168
  const pptx = await pptGenerator.generatePPTFromResult({
102
169
  result: resultJSON,
103
170
  });
104
- // 以cover的title为文件名
105
- const coverItem = outline.find((it) => it.type === "cover");
106
- const fileName = (coverItem?.data?.title || "未命名演示文稿").replace(/\s+/g, "");
107
171
  // 确定输出路径
108
172
  const pptOutputPath = node_path_1.default.join(outputPath, `${fileName}.pptx`);
109
173
  // 确保输出目录存在
@@ -123,7 +187,7 @@ const toolHandler = async ({ outline, templateFilePath, outputPath, }) => {
123
187
  {
124
188
  type: "resource_link",
125
189
  uri: `file:///${pptOutputPath}`,
126
- name: "result.pptx",
190
+ name: `${fileName}.pptx`,
127
191
  description: "生成的PPT",
128
192
  mimeType: "application/vnd.openxmlformats-officedocument.presentationml.presentation",
129
193
  annotations: {
@@ -20,7 +20,9 @@ const inputSchema = {
20
20
  templateFilePath: zod_1.z.string().optional(),
21
21
  // 输出地址
22
22
  outputPath: zod_1.z.string().optional(),
23
- outlinePath: zod_1.z.string().describe("需要替换的PPT文件大纲路径"),
23
+ outlinePath: zod_1.z
24
+ .string()
25
+ .describe("需要替换的PPT文件大纲(outline.json)文件地址"),
24
26
  pageIndex: zod_1.z.number().describe("需要替换的页码,从0开始"),
25
27
  newContent: zod_1.z.discriminatedUnion("type", [
26
28
  zod_1.z.object({
@@ -62,13 +64,14 @@ const inputSchema = {
62
64
  // tool descriptor
63
65
  const tool = {
64
66
  name: "update_ppt",
65
- title: "修改大纲重新生成",
66
- description: "通过修改outline.jsonindex项对象,从而完成重新生成某一页",
67
+ title: "更新ppt",
68
+ description: "通过修改outline.jsonindex项对象,从而完成重新生成某一页",
67
69
  inputSchema: (0, schema_1.zodToJsonSchema)(inputSchema),
68
70
  };
69
71
  const t = zod_1.z.object({ ...inputSchema });
70
72
  const toolHandler = async ({ outlinePath, pageIndex, newContent, templateFilePath, outputPath, }) => {
71
73
  try {
74
+ fs_extra_1.default.ensureDirSync(outlinePath);
72
75
  // --1.修改大纲文件--------------
73
76
  const outlineData = await fs_extra_1.default.readJSON(outlinePath);
74
77
  if (!Array.isArray(outlineData)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@8btc/ppt-generator-mcp",
3
- "version": "0.0.32-beta.3",
3
+ "version": "0.0.32-beta.5",
4
4
  "description": "MCP service for generating PPT files from AI-generated outlines and templates",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {