@aigne/doc-smith 0.8.12-beta.6 → 0.8.12-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.
- package/.aigne/doc-smith/config.yaml +1 -1
- package/.aigne/doc-smith/history.yaml +37 -0
- package/.aigne/doc-smith/media-description.yaml +91 -0
- package/.aigne/doc-smith/preferences.yml +12 -0
- package/.aigne/doc-smith/upload-cache.yaml +36 -69
- package/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +24 -0
- package/agents/clear/choose-contents.mjs +14 -1
- package/agents/clear/clear-media-description.mjs +129 -0
- package/agents/clear/index.yaml +3 -1
- package/agents/evaluate/code-snippet.mjs +28 -24
- package/agents/evaluate/document-structure.yaml +0 -4
- package/agents/evaluate/document.yaml +1 -5
- package/agents/generate/index.yaml +1 -0
- package/agents/generate/update-document-structure.yaml +9 -3
- package/agents/history/view.mjs +5 -2
- package/agents/init/index.mjs +10 -0
- package/agents/media/batch-generate-media-description.yaml +44 -0
- package/agents/media/generate-media-description.yaml +47 -0
- package/agents/media/load-media-description.mjs +238 -0
- package/agents/update/generate-document.yaml +10 -4
- package/agents/update/index.yaml +1 -0
- package/agents/update/update-document-detail.yaml +9 -3
- package/agents/update/user-review-document.mjs +2 -1
- package/agents/utils/load-sources.mjs +103 -53
- package/aigne.yaml +6 -0
- package/assets/report-template/report.html +34 -34
- package/docs/configuration-initial-setup.md +74 -55
- package/docs/configuration.ja.md +59 -86
- package/docs/configuration.md +59 -86
- package/docs/configuration.zh-TW.md +59 -86
- package/docs/configuration.zh.md +59 -86
- package/docs/getting-started.ja.md +43 -24
- package/docs/getting-started.md +29 -10
- package/docs/getting-started.zh-TW.md +42 -23
- package/docs/getting-started.zh.md +39 -20
- package/docs/guides-cleaning-up.ja.md +16 -15
- package/docs/guides-cleaning-up.md +19 -17
- package/docs/guides-cleaning-up.zh-TW.md +16 -15
- package/docs/guides-cleaning-up.zh.md +12 -11
- package/docs/guides-evaluating-documents.md +70 -29
- package/docs/guides-generating-documentation.ja.md +34 -32
- package/docs/guides-generating-documentation.md +59 -119
- package/docs/guides-generating-documentation.zh-TW.md +34 -32
- package/docs/guides-generating-documentation.zh.md +30 -28
- package/docs/guides-interactive-chat.md +34 -26
- package/docs/guides-managing-history.ja.md +17 -20
- package/docs/guides-managing-history.md +19 -17
- package/docs/guides-managing-history.zh-TW.md +18 -21
- package/docs/guides-managing-history.zh.md +13 -16
- package/docs/guides-publishing-your-docs.md +40 -35
- package/docs/guides-translating-documentation.ja.md +17 -17
- package/docs/guides-translating-documentation.md +39 -34
- package/docs/guides-translating-documentation.zh-TW.md +21 -21
- package/docs/guides-translating-documentation.zh.md +18 -18
- package/docs/guides-updating-documentation.ja.md +35 -35
- package/docs/guides-updating-documentation.md +11 -9
- package/docs/guides-updating-documentation.zh-TW.md +27 -27
- package/docs/guides-updating-documentation.zh.md +26 -26
- package/docs/overview.ja.md +13 -13
- package/docs/overview.md +2 -2
- package/docs/overview.zh-TW.md +19 -19
- package/docs/overview.zh.md +16 -16
- package/docs/release-notes.md +60 -27
- package/package.json +2 -1
- package/prompts/common/afs/afs-tools-usage.md +5 -0
- package/prompts/common/afs/use-afs-instruction.md +1 -0
- package/prompts/detail/generate/system-prompt.md +0 -13
- package/prompts/detail/generate/user-prompt.md +7 -0
- package/prompts/detail/update/system-prompt.md +1 -2
- package/prompts/detail/update/user-prompt.md +7 -0
- package/prompts/evaluate/document-structure.md +6 -7
- package/prompts/evaluate/document.md +16 -25
- package/prompts/media/media-description/system-prompt.md +35 -0
- package/prompts/media/media-description/user-prompt.md +8 -0
- package/prompts/structure/generate/system-prompt.md +0 -19
- package/prompts/structure/generate/user-prompt.md +22 -1
- package/prompts/structure/update/system-prompt.md +0 -17
- package/prompts/structure/update/user-prompt.md +24 -0
- package/tests/agents/history/view.test.mjs +97 -0
- package/tests/utils/history-utils.test.mjs +125 -97
- package/utils/constants/index.mjs +0 -107
- package/utils/file-utils.mjs +42 -1
- package/utils/history-utils.mjs +3 -3
- package/agents/update/fs-tools/glob.mjs +0 -184
- package/agents/update/fs-tools/grep.mjs +0 -317
- package/agents/update/fs-tools/read-file.mjs +0 -309
- package/media.md +0 -19
- package/tests/agents/update/fs-tools/glob.test.mjs +0 -438
- package/tests/agents/update/fs-tools/grep.test.mjs +0 -279
- package/tests/agents/update/fs-tools/read-file.test.mjs +0 -549
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { readFile } from "node:fs/promises";
|
|
2
2
|
import path from "node:path";
|
|
3
|
+
import imageSize from "image-size";
|
|
3
4
|
import {
|
|
4
5
|
buildSourcesContent,
|
|
5
6
|
calculateFileStats,
|
|
6
7
|
loadFilesFromPaths,
|
|
7
8
|
readFileContents,
|
|
9
|
+
getMimeType,
|
|
8
10
|
} from "../../utils/file-utils.mjs";
|
|
9
11
|
import {
|
|
10
12
|
getCurrentGitHead,
|
|
@@ -29,8 +31,10 @@ export default async function loadSources({
|
|
|
29
31
|
useDefaultPatterns = true,
|
|
30
32
|
lastGitHead,
|
|
31
33
|
reset = false,
|
|
34
|
+
media,
|
|
32
35
|
} = {}) {
|
|
33
36
|
let files = Array.isArray(sources) ? [...sources] : [];
|
|
37
|
+
const { minImageWidth } = media || { minImageWidth: 800 };
|
|
34
38
|
|
|
35
39
|
if (sourcesPath) {
|
|
36
40
|
const allFiles = await loadFilesFromPaths(sourcesPath, {
|
|
@@ -58,36 +62,102 @@ export default async function loadSources({
|
|
|
58
62
|
".bmp",
|
|
59
63
|
".webp",
|
|
60
64
|
".svg",
|
|
65
|
+
".heic",
|
|
66
|
+
".heif",
|
|
61
67
|
".mp4",
|
|
68
|
+
".mpeg",
|
|
69
|
+
".mpg",
|
|
62
70
|
".mov",
|
|
63
71
|
".avi",
|
|
72
|
+
".flv",
|
|
64
73
|
".mkv",
|
|
65
74
|
".webm",
|
|
75
|
+
".wmv",
|
|
66
76
|
".m4v",
|
|
77
|
+
".3gpp",
|
|
67
78
|
];
|
|
68
79
|
|
|
69
80
|
// Separate source files from media files
|
|
70
81
|
const sourceFilesPaths = [];
|
|
71
82
|
const mediaFiles = [];
|
|
72
83
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
84
|
+
// Helper function to determine file type from extension
|
|
85
|
+
const getFileType = (filePath) => {
|
|
86
|
+
const ext = path.extname(filePath).toLowerCase();
|
|
87
|
+
const imageExts = [".jpg", ".jpeg", ".png", ".gif", ".bmp", ".webp", ".svg", ".heic", ".heif"];
|
|
88
|
+
const videoExts = [
|
|
89
|
+
".mp4",
|
|
90
|
+
".mpeg",
|
|
91
|
+
".mpg",
|
|
92
|
+
".mov",
|
|
93
|
+
".avi",
|
|
94
|
+
".flv",
|
|
95
|
+
".mkv",
|
|
96
|
+
".webm",
|
|
97
|
+
".wmv",
|
|
98
|
+
".m4v",
|
|
99
|
+
".3gpp",
|
|
100
|
+
];
|
|
101
|
+
|
|
102
|
+
if (imageExts.includes(ext)) return "image";
|
|
103
|
+
if (videoExts.includes(ext)) return "video";
|
|
104
|
+
return "media";
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
let filteredImageCount = 0;
|
|
108
|
+
|
|
109
|
+
await Promise.all(
|
|
110
|
+
files.map(async (file) => {
|
|
111
|
+
const ext = path.extname(file).toLowerCase();
|
|
112
|
+
|
|
113
|
+
if (mediaExtensions.includes(ext)) {
|
|
114
|
+
// This is a media file
|
|
115
|
+
const relativePath = path.relative(docsDir, file);
|
|
116
|
+
const fileName = path.basename(file);
|
|
117
|
+
const description = path.parse(fileName).name;
|
|
118
|
+
|
|
119
|
+
const mediaItem = {
|
|
120
|
+
name: fileName,
|
|
121
|
+
path: relativePath,
|
|
122
|
+
type: getFileType(relativePath),
|
|
123
|
+
description,
|
|
124
|
+
mimeType: getMimeType(file),
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
// For image files, get dimensions and filter by width
|
|
128
|
+
if (mediaItem.type === "image") {
|
|
129
|
+
try {
|
|
130
|
+
const buffer = await readFile(file);
|
|
131
|
+
const dimensions = imageSize(buffer);
|
|
132
|
+
mediaItem.width = dimensions.width;
|
|
133
|
+
mediaItem.height = dimensions.height;
|
|
134
|
+
|
|
135
|
+
// Filter out images with width less than minImageWidth
|
|
136
|
+
if (dimensions.width < minImageWidth) {
|
|
137
|
+
filteredImageCount++;
|
|
138
|
+
console.log(
|
|
139
|
+
`Filtered image: ${fileName} (${dimensions.width}x${dimensions.height}px < ${minImageWidth}px minimum)`,
|
|
140
|
+
);
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
} catch (err) {
|
|
144
|
+
console.warn(`⚠️ Failed to get dimensions for ${fileName}: ${err.message}`);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
mediaFiles.push(mediaItem);
|
|
149
|
+
} else {
|
|
150
|
+
// This is a source file
|
|
151
|
+
sourceFilesPaths.push(file);
|
|
152
|
+
}
|
|
153
|
+
}),
|
|
154
|
+
);
|
|
155
|
+
|
|
156
|
+
// Log summary of filtered images
|
|
157
|
+
if (filteredImageCount > 0) {
|
|
158
|
+
console.log(
|
|
159
|
+
`\nTotal ${filteredImageCount} low-resolution image(s) filtered for better documentation quality (minimum width: ${minImageWidth}px)\n`,
|
|
160
|
+
);
|
|
91
161
|
}
|
|
92
162
|
|
|
93
163
|
// Read all source files using the utility function
|
|
@@ -179,37 +249,6 @@ export default async function loadSources({
|
|
|
179
249
|
}
|
|
180
250
|
}
|
|
181
251
|
|
|
182
|
-
// Generate assets content from media files
|
|
183
|
-
let assetsContent = "# Available Media Assets for Documentation\n\n";
|
|
184
|
-
|
|
185
|
-
if (mediaFiles.length > 0) {
|
|
186
|
-
// Helper function to determine file type from extension
|
|
187
|
-
const getFileType = (filePath) => {
|
|
188
|
-
const ext = path.extname(filePath).toLowerCase();
|
|
189
|
-
const imageExts = [".jpg", ".jpeg", ".png", ".gif", ".bmp", ".webp", ".svg"];
|
|
190
|
-
const videoExts = [".mp4", ".mov", ".avi", ".mkv", ".webm", ".m4v"];
|
|
191
|
-
|
|
192
|
-
if (imageExts.includes(ext)) return "image";
|
|
193
|
-
if (videoExts.includes(ext)) return "video";
|
|
194
|
-
return "media";
|
|
195
|
-
};
|
|
196
|
-
|
|
197
|
-
const mediaYaml = mediaFiles.map((file) => ({
|
|
198
|
-
name: file.name,
|
|
199
|
-
path: file.path,
|
|
200
|
-
type: getFileType(file.path),
|
|
201
|
-
}));
|
|
202
|
-
|
|
203
|
-
assetsContent += "```yaml\n";
|
|
204
|
-
assetsContent += "assets:\n";
|
|
205
|
-
mediaYaml.forEach((asset) => {
|
|
206
|
-
assetsContent += ` - name: "${asset.name}"\n`;
|
|
207
|
-
assetsContent += ` path: "${asset.path}"\n`;
|
|
208
|
-
assetsContent += ` type: "${asset.type}"\n`;
|
|
209
|
-
});
|
|
210
|
-
assetsContent += "```\n";
|
|
211
|
-
}
|
|
212
|
-
|
|
213
252
|
return {
|
|
214
253
|
datasources: allSources,
|
|
215
254
|
content,
|
|
@@ -218,7 +257,7 @@ export default async function loadSources({
|
|
|
218
257
|
modifiedFiles,
|
|
219
258
|
totalTokens,
|
|
220
259
|
totalLines,
|
|
221
|
-
|
|
260
|
+
mediaFiles,
|
|
222
261
|
isLargeContext,
|
|
223
262
|
allFilesPaths,
|
|
224
263
|
};
|
|
@@ -280,9 +319,20 @@ loadSources.output_schema = {
|
|
|
280
319
|
items: { type: "string" },
|
|
281
320
|
description: "Array of modified files since last generation",
|
|
282
321
|
},
|
|
283
|
-
|
|
284
|
-
type: "
|
|
285
|
-
|
|
322
|
+
mediaFiles: {
|
|
323
|
+
type: "array",
|
|
324
|
+
items: {
|
|
325
|
+
type: "object",
|
|
326
|
+
properties: {
|
|
327
|
+
name: { type: "string" },
|
|
328
|
+
path: { type: "string" },
|
|
329
|
+
type: { type: "string" },
|
|
330
|
+
width: { type: "number" },
|
|
331
|
+
height: { type: "number" },
|
|
332
|
+
mimeType: { type: "string" },
|
|
333
|
+
},
|
|
334
|
+
},
|
|
335
|
+
description: "Array of media file objects (images/videos)",
|
|
286
336
|
},
|
|
287
337
|
},
|
|
288
338
|
};
|
package/aigne.yaml
CHANGED
|
@@ -49,6 +49,11 @@ agents:
|
|
|
49
49
|
- ./agents/publish/publish-docs.mjs
|
|
50
50
|
- ./agents/publish/index.yaml
|
|
51
51
|
|
|
52
|
+
# Media
|
|
53
|
+
- ./agents/media/load-media-description.mjs
|
|
54
|
+
- ./agents/media/batch-generate-media-description.yaml
|
|
55
|
+
- ./agents/media/generate-media-description.yaml
|
|
56
|
+
|
|
52
57
|
# Clear/Cleanup
|
|
53
58
|
- ./agents/clear/choose-contents.mjs
|
|
54
59
|
- ./agents/clear/clear-document-structure.mjs
|
|
@@ -56,6 +61,7 @@ agents:
|
|
|
56
61
|
- ./agents/clear/clear-document-config.mjs
|
|
57
62
|
- ./agents/clear/clear-auth-tokens.mjs
|
|
58
63
|
- ./agents/clear/clear-deployment-config.mjs
|
|
64
|
+
- ./agents/clear/clear-media-description.mjs
|
|
59
65
|
|
|
60
66
|
# Utilities
|
|
61
67
|
- ./agents/utils/load-sources.mjs
|