@dyno181cm.nexsoft/zentao_mcp 1.2.15 → 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 +6 -23
- package/package.json +1 -1
package/build/tools.js
CHANGED
|
@@ -80,8 +80,8 @@ async function localizeImages(html) {
|
|
|
80
80
|
await client.downloadImageToLocal(remoteUrl, localPath);
|
|
81
81
|
}
|
|
82
82
|
const fileUrl = toFileUrl(localPath);
|
|
83
|
-
// Replace img tag with a standard hyperlink (no inline rendering, saves tokens)
|
|
84
|
-
const linkTag = `<a href="${fileUrl}"
|
|
83
|
+
// Replace img tag with a standard hyperlink (no inline rendering, saves tokens)
|
|
84
|
+
const linkTag = `<a href="${fileUrl}">${linkText}</a>`;
|
|
85
85
|
result = result.split(fullTag).join(linkTag);
|
|
86
86
|
}
|
|
87
87
|
catch {
|
|
@@ -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,28 +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
|
-
return `-
|
|
128
|
+
return `- ${f.title} — *(download failed, Size: ${formatSize(f.size)})*`;
|
|
141
129
|
const fileUrl = toFileUrl(f.localPath);
|
|
142
|
-
|
|
143
|
-
if (IMAGE_EXTS.has(f.ext))
|
|
144
|
-
icon = '🖼️';
|
|
145
|
-
else if (VIDEO_EXTS.has(f.ext))
|
|
146
|
-
icon = '🎬';
|
|
147
|
-
return `- ${icon} [${f.title}](${fileUrl}) *(Size: ${formatSize(f.size)})*`;
|
|
130
|
+
return `- [${f.title}](${fileUrl}) *(Size: ${formatSize(f.size)})*`;
|
|
148
131
|
});
|
|
149
|
-
return `\n## Files
|
|
132
|
+
return `\n## Files\n${lines.join('\n')}\n`;
|
|
150
133
|
}
|
|
151
134
|
// ─── Public formatters ───────────────────────────────────────────────────────
|
|
152
135
|
/**
|