@aigne/doc-smith 0.9.7-beta.2 → 0.9.7-beta.3

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/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.9.7-beta.3](https://github.com/AIGNE-io/aigne-doc-smith/compare/v0.9.7-beta.2...v0.9.7-beta.3) (2025-11-28)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * ensure x-card data-image is accessible ([#341](https://github.com/AIGNE-io/aigne-doc-smith/issues/341)) ([9209990](https://github.com/AIGNE-io/aigne-doc-smith/commit/92099909d9b1a0d5760a9b9977c940287af1aaec))
9
+
3
10
  ## [0.9.7-beta.2](https://github.com/AIGNE-io/aigne-doc-smith/compare/v0.9.7-beta.1...v0.9.7-beta.2) (2025-11-28)
4
11
 
5
12
 
@@ -103,7 +103,11 @@ Your task is to remove ${DIAGRAM_PLACEHOLDER} and adjust the document context (b
103
103
 
104
104
  <user_feedback>
105
105
  {{feedback}}
106
- </user_feedback>`;
106
+ </user_feedback>
107
+
108
+ <output_constraints>
109
+ - Do not provide any explanations; include only the document content itself
110
+ </output_constraints>`;
107
111
  const deleteAgent = AIAgent.from({
108
112
  name: "deleteDiagram",
109
113
  description: "Remove a diagram from the document content",
@@ -1,5 +1,5 @@
1
- import { checkMarkdown } from "../../utils/markdown-checker.mjs";
2
1
  import { buildAllowedLinksFromStructure } from "../../utils/docs-finder-utils.mjs";
2
+ import { checkMarkdown } from "../../utils/markdown-checker.mjs";
3
3
 
4
4
  export default async function checkDetailResult({ documentStructure, reviewContent, docsDir }) {
5
5
  if (!reviewContent || reviewContent.trim() === "") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aigne/doc-smith",
3
- "version": "0.9.7-beta.2",
3
+ "version": "0.9.7-beta.3",
4
4
  "description": "AI-driven documentation generation tool built on the AIGNE Framework",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -9,6 +9,7 @@ XCard is individual link display card, suitable for displaying individual links
9
9
  - `data-icon` (optional): Icon identifier (e.g., lucide:icon-name or material-symbols:rocket-outline).
10
10
  - Icons should prioritize Lucide (lucide:icon-name). If not available in Lucide, use Iconify (collection:icon-name, e.g., material-symbols:rocket-outline).
11
11
  - `data-image` (optional): Image URL, can coexist with icon.
12
+ - Prefer to use image url from `<media_file_list>`.
12
13
  - **Requirement**: At least one of `data-icon` or `data-image` must be provided.
13
14
  - It's recommended to always provide data-icon.
14
15
  - `data-href` (optional): Navigation link for clicking the card or button.
@@ -308,6 +308,67 @@ async function checkRemoteImages(markdown, source, errorMessages) {
308
308
  }
309
309
  }
310
310
 
311
+ async function checkXCardImage(markdown, source, errorMessages, markdownFilePath, baseDir) {
312
+ const imageRegex = /data-image="([^"]*)"/g;
313
+ let match;
314
+
315
+ while (true) {
316
+ match = imageRegex.exec(markdown);
317
+ if (match === null) break;
318
+ const imagePath = match[1].trim();
319
+
320
+ // Skip data URLs
321
+ if (/^data:/.test(imagePath)) continue;
322
+
323
+ if (isRelative(imagePath)) {
324
+ try {
325
+ let resolvedPath;
326
+ if (markdownFilePath) {
327
+ // Resolve relative to the markdown file's directory
328
+ const markdownDir = path.dirname(markdownFilePath);
329
+ resolvedPath = path.resolve(markdownDir, imagePath);
330
+ } else if (baseDir) {
331
+ // Resolve relative to the provided base directory
332
+ resolvedPath = path.resolve(baseDir, imagePath);
333
+ } else {
334
+ // Fallback to current working directory
335
+ resolvedPath = path.resolve(imagePath);
336
+ }
337
+
338
+ if (!fs.existsSync(resolvedPath)) {
339
+ errorMessages.push(
340
+ `Found invalid local image in ${source}: ${imagePath} - only valid media resources can be used`,
341
+ );
342
+ }
343
+ } catch {
344
+ errorMessages.push(
345
+ `Found invalid local image in ${source}: ${imagePath} - only valid media resources can be used`,
346
+ );
347
+ }
348
+ } else if (imagePath.startsWith("/")) {
349
+ try {
350
+ if (!fs.existsSync(imagePath)) {
351
+ errorMessages.push(
352
+ `Found invalid local image in ${source}: ${imagePath} - only valid media resources can be used`,
353
+ );
354
+ }
355
+ } catch {
356
+ errorMessages.push(
357
+ `Found invalid local image in ${source}: ${imagePath} - only valid media resources can be used`,
358
+ );
359
+ }
360
+ } else if (isRemoteFile(imagePath)) {
361
+ const isAvailable = await isRemoteFileAvailable(imagePath);
362
+ if (isAvailable) continue;
363
+ else {
364
+ errorMessages.push(
365
+ `Found invalid remote image in ${source}: ${imagePath} - only valid media resources can be used`,
366
+ );
367
+ }
368
+ }
369
+ }
370
+ }
371
+
311
372
  /**
312
373
  * Check content structure and formatting issues
313
374
  * @param {string} markdown - The markdown content
@@ -449,6 +510,8 @@ export async function checkMarkdown(markdown, source = "content", options = {})
449
510
  // 3. Check remote images existence
450
511
  await checkRemoteImages(markdown, source, errorMessages);
451
512
 
513
+ await checkXCardImage(markdown, source, errorMessages, filePath, baseDir);
514
+
452
515
  // 4. Check content structure and formatting issues
453
516
  checkContentStructure(markdown, source, errorMessages);
454
517