@8btc/ppt-generator-mcp 0.0.32-beta.7 → 0.0.32-beta.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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
declare const t: z.ZodObject<{
|
|
3
|
-
templateFilePath: z.
|
|
4
|
-
outputPath: z.
|
|
3
|
+
templateFilePath: z.ZodString;
|
|
4
|
+
outputPath: z.ZodString;
|
|
5
5
|
outlinePath: z.ZodString;
|
|
6
6
|
pageIndex: z.ZodNumber;
|
|
7
7
|
newContent: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
@@ -127,6 +127,8 @@ declare const t: z.ZodObject<{
|
|
|
127
127
|
type: "end";
|
|
128
128
|
}>]>;
|
|
129
129
|
}, "strip", z.ZodTypeAny, {
|
|
130
|
+
templateFilePath: string;
|
|
131
|
+
outputPath: string;
|
|
130
132
|
outlinePath: string;
|
|
131
133
|
pageIndex: number;
|
|
132
134
|
newContent: {
|
|
@@ -159,9 +161,9 @@ declare const t: z.ZodObject<{
|
|
|
159
161
|
} | {
|
|
160
162
|
type: "end";
|
|
161
163
|
};
|
|
162
|
-
templateFilePath?: string | undefined;
|
|
163
|
-
outputPath?: string | undefined;
|
|
164
164
|
}, {
|
|
165
|
+
templateFilePath: string;
|
|
166
|
+
outputPath: string;
|
|
165
167
|
outlinePath: string;
|
|
166
168
|
pageIndex: number;
|
|
167
169
|
newContent: {
|
|
@@ -194,8 +196,6 @@ declare const t: z.ZodObject<{
|
|
|
194
196
|
} | {
|
|
195
197
|
type: "end";
|
|
196
198
|
};
|
|
197
|
-
templateFilePath?: string | undefined;
|
|
198
|
-
outputPath?: string | undefined;
|
|
199
199
|
}>;
|
|
200
200
|
type IUpdatePptOutline = z.infer<typeof t>;
|
|
201
201
|
export declare const update_ppt: {
|
package/dist/tools/update-ppt.js
CHANGED
|
@@ -17,12 +17,12 @@ const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
|
17
17
|
const ppt_generator_js_1 = require("./pptGenerator/ppt-generator.js");
|
|
18
18
|
const inputSchema = {
|
|
19
19
|
// 模版地址
|
|
20
|
-
templateFilePath: zod_1.z.string().
|
|
20
|
+
templateFilePath: zod_1.z.string().describe("原ppt的模版地址"),
|
|
21
21
|
// 输出地址
|
|
22
|
-
outputPath: zod_1.z.string()
|
|
22
|
+
outputPath: zod_1.z.string(),
|
|
23
23
|
outlinePath: zod_1.z.string().describe(`需要替换的PPT文件大纲(pptFileName_outline.json)文件地址, 文件名由ppt文件名和下划线outline拼接,
|
|
24
24
|
例如:AI个性化学习_outline.json`),
|
|
25
|
-
pageIndex: zod_1.z.number().describe("
|
|
25
|
+
pageIndex: zod_1.z.number().describe("需要替换的页码, 例如:1 ~ 100"),
|
|
26
26
|
newContent: zod_1.z.discriminatedUnion("type", [
|
|
27
27
|
zod_1.z.object({
|
|
28
28
|
type: zod_1.z.literal("cover"),
|
|
@@ -70,13 +70,12 @@ const tool = {
|
|
|
70
70
|
const t = zod_1.z.object({ ...inputSchema });
|
|
71
71
|
const toolHandler = async ({ outlinePath, pageIndex, newContent, templateFilePath, outputPath, }) => {
|
|
72
72
|
try {
|
|
73
|
-
fs_extra_1.default.ensureDirSync(outlinePath);
|
|
74
73
|
// --1.修改大纲文件--------------
|
|
75
74
|
const outlineData = await fs_extra_1.default.readJSON(outlinePath);
|
|
76
75
|
if (!Array.isArray(outlineData)) {
|
|
77
76
|
throw new types_js_1.McpError(types_js_1.ErrorCode.InvalidParams, "Invalid outline file format.");
|
|
78
77
|
}
|
|
79
|
-
if (pageIndex <
|
|
78
|
+
if (pageIndex < 1 || pageIndex > outlineData.length) {
|
|
80
79
|
throw new types_js_1.McpError(types_js_1.ErrorCode.InvalidParams, "Page index out of range.");
|
|
81
80
|
}
|
|
82
81
|
if (typeof newContent === "string") {
|
|
@@ -88,7 +87,7 @@ const toolHandler = async ({ outlinePath, pageIndex, newContent, templateFilePat
|
|
|
88
87
|
}
|
|
89
88
|
}
|
|
90
89
|
// 替换指定页码内容
|
|
91
|
-
outlineData[pageIndex] = newContent;
|
|
90
|
+
outlineData[pageIndex - 1] = newContent;
|
|
92
91
|
// 写回大纲文件
|
|
93
92
|
await fs_extra_1.default.writeJSON(outlinePath, outlineData, { spaces: 2 });
|
|
94
93
|
// --2.重新生成ppt--------------
|