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

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.
@@ -79,8 +79,11 @@ const toolHandler = async ({ outline, templateFilePath, outputPath, }) => {
79
79
  outputPath = node_path_1.default.resolve(outputPath);
80
80
  try {
81
81
  fs_extra_1.default.ensureDirSync(outputPath);
82
+ // 以cover的title为文件名
83
+ const coverItem = outline.find((it) => it.type === "cover");
84
+ const fileName = (coverItem?.data?.title || "未命名演示文稿").replace(/\s+/g, "");
82
85
  // 保存result.json
83
- await fs_extra_1.default.writeJson(node_path_1.default.join(outputPath, "outline.json"), outline, {
86
+ await fs_extra_1.default.writeJson(node_path_1.default.join(outputPath, `${fileName}_outline.json`), outline, {
84
87
  spaces: 2,
85
88
  });
86
89
  // 读取模板文件
@@ -91,19 +94,16 @@ const toolHandler = async ({ outline, templateFilePath, outputPath, }) => {
91
94
  templateData: templateData,
92
95
  });
93
96
  // 保存result.json
94
- await fs_extra_1.default.writeJson(node_path_1.default.join(outputPath, "result.json"), resultJSON, {
97
+ await fs_extra_1.default.writeJson(node_path_1.default.join(outputPath, `${fileName}_result.json`), resultJSON, {
95
98
  spaces: 2,
96
99
  });
97
100
  if (!resultJSON) {
98
101
  console.error("generate_result_json 生成 result.json 失败");
99
- throw new types_js_1.McpError(types_js_1.ErrorCode.InternalError, "生成result.json失败");
102
+ throw new types_js_1.McpError(types_js_1.ErrorCode.InternalError, `生成${fileName}_result.json失败`);
100
103
  }
101
104
  const pptx = await pptGenerator.generatePPTFromResult({
102
105
  result: resultJSON,
103
106
  });
104
- // 以cover的title为文件名
105
- const coverItem = outline.find((it) => it.type === "cover");
106
- const fileName = (coverItem?.data?.title || "未命名演示文稿").replace(/\s+/g, "");
107
107
  // 确定输出路径
108
108
  const pptOutputPath = node_path_1.default.join(outputPath, `${fileName}.pptx`);
109
109
  // 确保输出目录存在
@@ -123,7 +123,7 @@ const toolHandler = async ({ outline, templateFilePath, outputPath, }) => {
123
123
  {
124
124
  type: "resource_link",
125
125
  uri: `file:///${pptOutputPath}`,
126
- name: "result.pptx",
126
+ name: `${fileName}.pptx`,
127
127
  description: "生成的PPT",
128
128
  mimeType: "application/vnd.openxmlformats-officedocument.presentationml.presentation",
129
129
  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文件大纲路径,outputPath(原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({
@@ -69,6 +71,7 @@ const tool = {
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.4",
4
4
  "description": "MCP service for generating PPT files from AI-generated outlines and templates",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {