@dyno181cm.nexsoft/zentao_mcp 1.2.16 → 1.2.17
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/build/tools.js +2 -14
- package/package.json +1 -1
package/build/tools.js
CHANGED
|
@@ -107,12 +107,10 @@ function formatSize(bytes) {
|
|
|
107
107
|
function mcpText(text) {
|
|
108
108
|
return { content: [{ type: "text", text }] };
|
|
109
109
|
}
|
|
110
|
-
/** Download all attachments to local tmp dir and render them as a Markdown section
|
|
110
|
+
/** Download all attachments to local tmp dir and render them as a Markdown section. */
|
|
111
111
|
async function renderAttachments(files) {
|
|
112
112
|
if (!files || files.length === 0)
|
|
113
113
|
return '';
|
|
114
|
-
const IMAGE_EXTS = new Set(['png', 'jpg', 'jpeg', 'gif', 'webp', 'bmp', 'svg']);
|
|
115
|
-
const VIDEO_EXTS = new Set(['mp4', 'mov', 'avi', 'mkv', 'webm']);
|
|
116
114
|
const enriched = await Promise.all(files.map(async (f) => {
|
|
117
115
|
const ext = (f.extension || '').toLowerCase();
|
|
118
116
|
const targetPath = path.join(os.tmpdir(), `zentao_file_${f.id}.${ext}`);
|
|
@@ -125,23 +123,13 @@ async function renderAttachments(files) {
|
|
|
125
123
|
catch { /* keep null, show download failed below */ }
|
|
126
124
|
return { title: f.title, size: f.size, localPath, ext };
|
|
127
125
|
}));
|
|
128
|
-
// Build section header hint based on media types present
|
|
129
|
-
const hasImage = enriched.some(f => f.localPath && IMAGE_EXTS.has(f.ext));
|
|
130
|
-
const hasVideo = enriched.some(f => f.localPath && VIDEO_EXTS.has(f.ext));
|
|
131
|
-
let headerHint = '';
|
|
132
|
-
if (hasImage && hasVideo)
|
|
133
|
-
headerHint = ' *(AI: Please view the images and videos below)*';
|
|
134
|
-
else if (hasImage)
|
|
135
|
-
headerHint = ' *(AI: Please view the images below)*';
|
|
136
|
-
else if (hasVideo)
|
|
137
|
-
headerHint = ' *(AI: Please view the videos below)*';
|
|
138
126
|
const lines = enriched.map((f) => {
|
|
139
127
|
if (!f.localPath)
|
|
140
128
|
return `- ${f.title} — *(download failed, Size: ${formatSize(f.size)})*`;
|
|
141
129
|
const fileUrl = toFileUrl(f.localPath);
|
|
142
130
|
return `- [${f.title}](${fileUrl}) *(Size: ${formatSize(f.size)})*`;
|
|
143
131
|
});
|
|
144
|
-
return `\n## Files
|
|
132
|
+
return `\n## Files\n${lines.join('\n')}\n`;
|
|
145
133
|
}
|
|
146
134
|
// ─── Public formatters ───────────────────────────────────────────────────────
|
|
147
135
|
/**
|