@aigne/doc-smith 0.9.7 → 0.9.8-beta

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.
Files changed (56) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/agents/create/analyze-diagram-type-llm.yaml +160 -0
  3. package/agents/create/analyze-diagram-type.mjs +297 -0
  4. package/agents/create/generate-diagram-image.yaml +60 -0
  5. package/agents/create/replace-d2-with-image.mjs +624 -0
  6. package/agents/create/utils/init-current-content.mjs +5 -9
  7. package/agents/evaluate/document.yaml +6 -0
  8. package/agents/evaluate/index.yaml +1 -0
  9. package/agents/init/index.mjs +16 -0
  10. package/agents/media/batch-generate-media-description.yaml +2 -0
  11. package/agents/media/generate-media-description.yaml +3 -0
  12. package/agents/media/load-media-description.mjs +44 -15
  13. package/agents/publish/publish-docs.mjs +1 -4
  14. package/agents/update/check-diagram-flag.mjs +116 -0
  15. package/agents/update/check-document.mjs +0 -1
  16. package/agents/update/check-generate-diagram.mjs +48 -30
  17. package/agents/update/check-sync-image-flag.mjs +55 -0
  18. package/agents/update/check-update-is-single.mjs +11 -0
  19. package/agents/update/generate-diagram.yaml +43 -9
  20. package/agents/update/generate-document.yaml +9 -0
  21. package/agents/update/handle-document-update.yaml +10 -8
  22. package/agents/update/index.yaml +16 -1
  23. package/agents/update/sync-images-and-exit.mjs +148 -0
  24. package/agents/update/update-single/update-single-document-detail.mjs +131 -17
  25. package/agents/utils/analyze-feedback-intent.mjs +136 -0
  26. package/agents/utils/choose-docs.mjs +183 -40
  27. package/agents/utils/generate-document-or-skip.mjs +41 -0
  28. package/agents/utils/handle-diagram-operations.mjs +263 -0
  29. package/agents/utils/load-all-document-content.mjs +30 -0
  30. package/agents/utils/load-sources.mjs +2 -2
  31. package/agents/utils/read-current-document-content.mjs +46 -0
  32. package/agents/utils/save-doc.mjs +42 -0
  33. package/agents/utils/skip-if-content-exists.mjs +27 -0
  34. package/aigne.yaml +6 -1
  35. package/assets/report-template/report.html +17 -17
  36. package/docs-mcp/read-doc-content.mjs +30 -1
  37. package/package.json +4 -4
  38. package/prompts/detail/diagram/generate-image-system.md +135 -0
  39. package/prompts/detail/diagram/generate-image-user.md +32 -0
  40. package/prompts/detail/generate/user-prompt.md +27 -13
  41. package/prompts/evaluate/document.md +23 -10
  42. package/prompts/media/media-description/system-prompt.md +10 -2
  43. package/prompts/media/media-description/user-prompt.md +9 -0
  44. package/utils/check-document-has-diagram.mjs +97 -0
  45. package/utils/constants/index.mjs +46 -0
  46. package/utils/d2-utils.mjs +114 -181
  47. package/utils/delete-diagram-images.mjs +103 -0
  48. package/utils/docs-finder-utils.mjs +34 -1
  49. package/utils/image-compress.mjs +75 -0
  50. package/utils/kroki-utils.mjs +2 -3
  51. package/utils/sync-diagram-to-translations.mjs +258 -0
  52. package/utils/utils.mjs +24 -0
  53. package/agents/create/check-diagram.mjs +0 -40
  54. package/agents/create/draw-diagram.yaml +0 -27
  55. package/agents/create/merge-diagram.yaml +0 -39
  56. package/agents/create/wrap-diagram-code.mjs +0 -35
@@ -3,6 +3,32 @@ import path from "node:path";
3
3
 
4
4
  const docsDir = path.join(process.cwd(), "./.aigne/doc-smith", "docs");
5
5
 
6
+ /**
7
+ * Remove base64 encoded images from markdown content
8
+ * This prevents large binary data from being included in document content
9
+ * Base64 images are completely removed (not replaced with placeholders) because:
10
+ * 1. They significantly increase token usage without providing useful information to LLM
11
+ * 2. Normal image references (file paths) are preserved and should be used instead
12
+ * 3. Base64 images are typically temporary or erroneous entries
13
+ *
14
+ * @param {string} content - Markdown content that may contain base64 images
15
+ * @returns {string} - Content with base64 images completely removed
16
+ */
17
+ function removeBase64Images(content) {
18
+ if (!content || typeof content !== "string") {
19
+ return content;
20
+ }
21
+
22
+ // Match markdown image syntax with data URLs: ![alt](data:image/...;base64,...)
23
+ const base64ImageRegex = /!\[([^\]]*)\]\(data:image\/[^)]+\)/g;
24
+
25
+ // Completely remove base64 images (including the entire markdown image syntax)
26
+ // This maximizes token reduction while preserving normal image references
27
+ const cleanedContent = content.replace(base64ImageRegex, "");
28
+
29
+ return cleanedContent;
30
+ }
31
+
6
32
  export default async function readDocContent({ relevantDocPaths, docsDir: customDocsDir }) {
7
33
  const targetDocsDir = customDocsDir || docsDir;
8
34
  const docContents = [];
@@ -15,7 +41,10 @@ export default async function readDocContent({ relevantDocPaths, docsDir: custom
15
41
  const filePath = path.join(targetDocsDir, fileFullName);
16
42
 
17
43
  // Read the markdown file
18
- const content = await fs.readFile(filePath, "utf8");
44
+ let content = await fs.readFile(filePath, "utf8");
45
+
46
+ // Remove base64 encoded images to reduce token usage
47
+ content = removeBase64Images(content);
19
48
 
20
49
  docContents.push({
21
50
  success: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aigne/doc-smith",
3
- "version": "0.9.7",
3
+ "version": "0.9.8-beta",
4
4
  "description": "AI-driven documentation generation tool built on the AIGNE Framework",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -26,10 +26,9 @@
26
26
  "dependencies": {
27
27
  "@aigne/cli": "^1.56.0",
28
28
  "@aigne/core": "^1.69.0",
29
- "@aigne/publish-docs": "^0.14.1",
29
+ "@aigne/publish-docs": "^0.14.2",
30
30
  "@aigne/secrets": "^0.1.1-beta.3",
31
- "@blocklet/payment-broker-client": "^1.22.24",
32
- "@terrastruct/d2": "^0.1.33",
31
+ "@blocklet/payment-broker-client": "^1.22.27",
33
32
  "chalk": "^5.5.0",
34
33
  "debug": "^4.4.1",
35
34
  "diff": "^8.0.2",
@@ -40,6 +39,7 @@
40
39
  "glob": "^11.0.3",
41
40
  "gpt-tokenizer": "^3.2.0",
42
41
  "image-size": "^2.0.2",
42
+ "sharp": "^0.33.0",
43
43
  "is-in-ci": "^2.0.0",
44
44
  "isbinaryfile": "^5.0.6",
45
45
  "jsdom": "^26.1.0",
@@ -0,0 +1,135 @@
1
+ You are an AI assistant specialized in generating clean, modern, professional diagram images.
2
+
3
+ # GLOBAL RULES — APPLY TO ALL DIAGRAMS & ALL RATIOS
4
+
5
+ ## VISUAL STYLE (Unified)
6
+ - Modern SaaS product aesthetic
7
+ - Flat vector style, light soft depth (Material Design 2.0 / 3.0)
8
+ - White or light-grey background
9
+ - Open, airy, uncluttered layout
10
+ - No dark backgrounds, neon colors, grunge textures, or heavy borders
11
+
12
+ ## COLORS (Material Design 3)
13
+ - Background: white (#FFFFFF) or very light grey (#F5F5F5)
14
+ - Node cards: pure white (#FFFFFF), rounded corners, soft shadows
15
+ - Primary accents: blue (#2196F3), purple (#9C27B0), teal (#009688), green (#4CAF50)
16
+ - Accent colors: amber (#FFC107), orange (#FF9800)
17
+ - Optional group containers:
18
+ - Core logic: light blue (#E3F2FD)
19
+ - AI/external: light purple (#F3E5F5)
20
+ - Output/success: light green (#E8F5E9)
21
+ - Connectors: blue (#2196F3 or #1976D2), straight or orthogonal
22
+
23
+ ## TYPOGRAPHY & TEXT RULES
24
+ - English only
25
+ - Short labels: 2–5 words, action-oriented
26
+ - No long sentences
27
+ - No text outside nodes
28
+ - No titles, captions, or step numbers
29
+
30
+ ## UNIVERSAL NODE RULES
31
+ - 1 concept per node
32
+ - Merge minor steps when needed
33
+ - Keep node sizes consistent
34
+ - Icons optional (thin-line, ≤20% node area)
35
+ - Architecture diagrams may use larger icons (30–50%)
36
+
37
+ ## FLOW RULES (Universal)
38
+ - ONE start → sequential flow → ONE end
39
+ - Clear, unobstructed main flow
40
+ - Minimal branching
41
+ - Avoid crossings; use orthogonal routing
42
+ - Feedback loops minimal but allowed
43
+
44
+ ## NODE COUNT CONTROL
45
+ - Target: 5–10 nodes
46
+ - Hard maximum: 15 nodes
47
+ - If >10: merge related steps, use grouping containers
48
+ - Must preserve complete logical flow
49
+
50
+ # ASPECT RATIO RULES — SELECTED VIA aspectRatio
51
+
52
+ {% if aspectRatio == "1:1" %}
53
+ ## SQUARE (1:1)
54
+ - Canvas: ~1024×1024
55
+ - Primary layout: radial or balanced grid
56
+ - Center main concept; surround related nodes symmetrically
57
+ - Use the full square; avoid tiny central clusters
58
+
59
+ {% elif aspectRatio == "4:3" or aspectRatio == "5:4" %}
60
+ ## PORTRAIT (4:3 or 5:4)
61
+ - Canvas: ~1280×1024 or ~1365×1024
62
+ - Primary layout: vertical (top→bottom)
63
+ - Use height generously; avoid large top/bottom gaps
64
+ - 4:3 supports longer text wrapping
65
+
66
+ {% elif aspectRatio == "3:2" %}
67
+ ## LANDSCAPE (3:2)
68
+ - Canvas: ~1536×1024
69
+ - Primary layout: horizontal (left→right)
70
+ - Use width well; 2–4 vertical lanes recommended
71
+
72
+ {% elif aspectRatio == "16:9" %}
73
+ ## WIDESCREEN (16:9)
74
+ - Canvas: ~1820×1024
75
+ - Strong horizontal layout
76
+ - Ideal for timelines, processes, wide flows
77
+
78
+ {% elif aspectRatio == "21:9" %}
79
+ ## ULTRAWIDE (21:9)
80
+ - Canvas: ~2393×1024
81
+ - Very strong horizontal flow
82
+ - Ideal for multi-lane or multi-actor diagrams
83
+
84
+ {% endif %}
85
+
86
+ # DIAGRAM TYPE RULES — SELECT BASED ON diagramType
87
+
88
+ {% if diagramType == "flowchart" %}
89
+ ## FLOWCHART
90
+ - ONE start → ONE end
91
+ - Dominant main flow, minimal branches
92
+ - Logical grouping recommended:
93
+ - Initialization
94
+ - Processing
95
+ - Validation
96
+ - Output
97
+ - Optional group containers
98
+
99
+ {% elif diagramType == "architecture" %}
100
+ ## ARCHITECTURE DIAGRAM
101
+ - Layout flexible: horizontal, vertical layers, or radial
102
+ - Use containers or zones for modules/services
103
+ - Icons may be larger and more expressive
104
+ - Emphasize structure and relationships
105
+
106
+ {% elif diagramType == "intro" %}
107
+ ## INTRO / CONCEPT OVERVIEW
108
+ - Radial or hierarchical layout
109
+ - One central idea + surrounding concepts
110
+ - Few connectors required
111
+
112
+ {% elif diagramType == "guide" %}
113
+ ## GUIDE DIAGRAM
114
+ - Simple linear progression
115
+ - Horizontal or vertical based on aspectRatio
116
+
117
+ {% elif diagramType == "sequence" %}
118
+ ## SEQUENCE DIAGRAM
119
+ - Horizontal timeline
120
+ - Vertical lifelines for actors
121
+ - Horizontal message arrows
122
+
123
+ {% elif diagramType == "network" %}
124
+ ## NETWORK DIAGRAM
125
+ - Node-based topology
126
+ - Minimize crossing connections
127
+ - Use relative spatial placement to show relationships
128
+
129
+ {% endif %}
130
+
131
+ # NEGATIVE PROMPT (Unified)
132
+ (no dark background), (no neon colors), (no clutter),
133
+ (no overcrowding), (no messy lines), (no spaghetti diagram),
134
+ (no confusing flow), (no diagram title), (no captions),
135
+ (no long sentences), (no step numbers)
@@ -0,0 +1,32 @@
1
+ Your task is to create a professional diagram image based on the document content below.
2
+
3
+ Please follow **all global rules, styles, aspect ratio logic, and diagram-type rules** defined in the system prompt.
4
+
5
+ # Task Parameters:
6
+ - **Diagram Type:** {{ diagramType }}
7
+ - **Visual Style:** {{ diagramStyle }}
8
+ - **Aspect Ratio:** {{ aspectRatio }}
9
+ - **Language:** {{ locale }}
10
+
11
+ # Your responsibilities:
12
+ 1. Read and analyze the document content.
13
+ 2. Extract key concepts, steps, relationships, or flow sequences.
14
+ 3. Generate a diagram that accurately represents these elements.
15
+ 4. Apply all rules from the system prompt.
16
+ 5. Labels must be concise (2–5 words).
17
+ 6. No titles or explanations outside nodes.
18
+ 7. Maintain clarity, structure, and proper layout based on the aspect ratio.
19
+
20
+ # Document Content:
21
+
22
+ Now analyze the following document content to understand what should be drawn:
23
+
24
+ {% if documentSummary %}
25
+ **Document Content (comprehensive summary for diagram generation):**
26
+ {{ documentSummary }}
27
+ {% else %}
28
+ **Document Content (full original content):**
29
+ {{ documentContent }}
30
+ {% endif %}
31
+
32
+ (Use this content to determine node structure, relationships, and flow.)
@@ -49,24 +49,38 @@ User feedback on previous generation:
49
49
  </feedback>
50
50
  {% endif %}
51
51
 
52
- {% if content %}
52
+ {% if content or originalContent %}
53
+ {% set previousContent = content or originalContent %}
53
54
 
54
55
  <previous_generation_content>
55
- {{content}}
56
+ {{previousContent}}
56
57
  </previous_generation_content>
57
58
 
58
59
  <instructions>
59
- Analyze the previous document content and user feedback, then use available tools to implement the requested improvements while maintaining the document's integrity and style.
60
- </instructions>
61
-
62
- {% elseif originalContent %}
63
-
64
- <previous_generation_content>
65
- {{originalContent}}
66
- </previous_generation_content>
67
-
68
- <instructions>
69
- Analyze the previous document content and user feedback, then use available tools to implement the requested improvements while maintaining the document's integrity and style.
60
+ Analyze the user feedback carefully.
61
+
62
+ {% if intentType and intentType in ["addDiagram", "updateDiagram", "deleteDiagram"] %}
63
+ **CRITICAL INSTRUCTION FOR DIAGRAM/IMAGE UPDATES:**
64
+ The user intent is to {{ intentType }} (diagram-related operation). You MUST:
65
+ 1. **DO NOT** change the text content.
66
+ 2. **DO NOT** rewrite, summarize, or "improve" the existing text.
67
+ 3. **DO NOT** use any search tools.
68
+ 4. **OUTPUT the `previous_generation_content` VERBATIM (exactly as is).**
69
+ The system has a dedicated downstream agent that will handle the image generation based on your output. Your job is to preserve the text so the image agent can work on the same context.
70
+ {% else %}
71
+ **CRITICAL INSTRUCTION FOR DIAGRAM/IMAGE UPDATES:**
72
+ If the user feedback is ONLY about updating diagrams, images, or visual styles (e.g., "update diagram", "change image", "use 16:9 ratio", "fix flowchart") and does NOT explicitly ask for text changes:
73
+ 1. **DO NOT** change the text content.
74
+ 2. **DO NOT** rewrite, summarize, or "improve" the existing text.
75
+ 3. **DO NOT** use any search tools.
76
+ 4. **OUTPUT the `previous_generation_content` VERBATIM (exactly as is).**
77
+ The system has a dedicated downstream agent that will handle the image generation based on your output. Your job is to preserve the text so the image agent can work on the same context.
78
+
79
+ Only if the feedback explicitly requests changes to the text content (e.g., "fix typo", "rewrite introduction", "add info"):
80
+ 1. Analyze the previous document content and user feedback.
81
+ 2. Use available tools to implement the requested improvements.
82
+ 3. Maintain the document's integrity and style.
83
+ {% endif %}
70
84
  </instructions>
71
85
 
72
86
  {% else %}
@@ -17,27 +17,40 @@ Please **strictly adhere** to the evaluation standards defined in `<standards>`
17
17
 
18
18
  - **Document content to be evaluated**:
19
19
 
20
+ {% if allDocumentContentList %}
21
+ <all_document_content>
22
+ {% for documentItem in allDocumentContentList %}
23
+ <document_content file_path="{{ documentItem.path }}">
24
+ {{ documentItem.content }}
20
25
  <document_content>
21
- {{ content }}
22
- </document_content>
23
-
24
- <document_content_plan>
25
- {{ description }}
26
- </document_content_plan>
27
-
26
+ {% endfor %}
27
+ </all_document_content>
28
+
29
+ <current_document_path>
30
+ {{ path }}
31
+ </current_document_path>
32
+ {% else %}
33
+ <current_document_content>
34
+ {{ content }}
35
+ </current_document_content>
36
+ {% endif %}
37
+
38
+ <current_document_content_plan>
39
+ {{ description }}
40
+ </current_document_content_plan>
28
41
 
29
42
  - **User Selection**:
30
43
 
31
44
  <purposes>
32
- {{purposes}}
45
+ {{ purposes }}
33
46
  </purposes>
34
47
 
35
48
  <audiences>
36
- {{audiences}}
49
+ {{ audiences }}
37
50
  </audiences>
38
51
 
39
52
  <reader_knowledge_level>
40
- {{readerKnowledgeLevel}}
53
+ {{ readerKnowledgeLevel }}
41
54
  </reader_knowledge_level>
42
55
 
43
56
  </context>
@@ -1,5 +1,5 @@
1
1
  <role_and_goal>
2
- You are an expert at analyzing media files (images and videos) and generating concise, meaningful descriptions for documentation content.
2
+ You are an expert at analyzing media files (images, videos, and SVG graphics) and generating concise, meaningful descriptions for documentation content.
3
3
 
4
4
  Your goal is to examine a single media file and generate an accurate description that helps both AI content generators and human readers understand what the media depicts and how it can be used effectively in documentation.
5
5
  </role_and_goal>
@@ -12,11 +12,13 @@ Your goal is to examine a single media file and generate an accurate description
12
12
  - The purpose or context of this media
13
13
  - Mood or atmosphere if distinctive
14
14
  - For videos: key actions, movements, or transitions
15
+ - For SVG: analyze the SVG code structure to understand the graphic content
15
16
 
16
17
  2. **Generate Description**: Create a concise, human-readable description following these principles:
17
18
  - Keep it between 2-3 sentences
18
19
  - Be specific and descriptive about visual content
19
20
  - For videos, describe the key content or action shown
21
+ - For SVG graphics, describe the visual theme and elements shown, NOT the file paths or code structure
20
22
  - Focus on aspects that matter for documentation usage
21
23
  - Remain objective - describe what you see, not what you interpret
22
24
  </analysis_workflow>
@@ -26,10 +28,16 @@ Your goal is to examine a single media file and generate an accurate description
26
28
  - Main subject or focus of the media
27
29
  - Key visual elements and composition
28
30
  - Context or setting if relevant for understanding
29
- - Technical aspects if relevant (e.g., "screenshot", "diagram", "illustration", "animation")
31
+ - Technical aspects if relevant (e.g., "screenshot", "diagram", "illustration", "animation", "icon", "logo")
30
32
  - Key features or functionality visible
31
33
  - Its purpose or functionality
32
34
  - Any notable UI elements or features
33
35
  - For videos: describe the main action, movement, or narrative
36
+ - For SVG graphics: describe the visual theme, shapes, colors, and what the graphic represents
37
+
38
+ **What NOT to Include (especially for SVG):**
39
+ - File paths, URLs, or technical references within the SVG code
40
+ - XML/SVG tag structure or implementation details
41
+ - Code-level technical information
34
42
  </description_guidelines>
35
43
 
@@ -4,5 +4,14 @@
4
4
  {%if width and height %}
5
5
  - Dimensions: {{width}}x{{height}}px
6
6
  {%endif%}
7
+ {%if svgContent %}
8
+
9
+ SVG Content:
10
+ ```xml
11
+ {{svgContent}}
12
+ ```
13
+
14
+ Please analyze the SVG code above and describe what visual elements and theme it represents. Focus on the visual appearance and purpose, not the code structure or file paths.
15
+ {%endif%}
7
16
  </media_information>
8
17
 
@@ -0,0 +1,97 @@
1
+ import { DIAGRAM_PLACEHOLDER, d2CodeBlockRegex } from "./d2-utils.mjs";
2
+
3
+ const diagramImageRegex = /<!--\s*DIAGRAM_IMAGE_START:[^>]+-->/g;
4
+
5
+ /**
6
+ * Check if document content contains diagram-related content
7
+ * @param {string} content - Document content to check
8
+ * @returns {boolean} - True if document contains d2 code blocks, DIAGRAM_PLACEHOLDER, or diagram images
9
+ */
10
+ export function hasDiagramContent(content) {
11
+ if (!content || typeof content !== "string") {
12
+ return false;
13
+ }
14
+
15
+ // Check for DIAGRAM_PLACEHOLDER
16
+ if (content.includes(DIAGRAM_PLACEHOLDER)) {
17
+ return true;
18
+ }
19
+
20
+ // Check for D2 code blocks
21
+ const d2Matches = Array.from(content.matchAll(d2CodeBlockRegex));
22
+ if (d2Matches.length > 0) {
23
+ return true;
24
+ }
25
+
26
+ // Check for existing diagram images (DIAGRAM_IMAGE_START markers)
27
+ const imageMatches = Array.from(content.matchAll(diagramImageRegex));
28
+ if (imageMatches.length > 0) {
29
+ return true;
30
+ }
31
+
32
+ return false;
33
+ }
34
+
35
+ /**
36
+ * Get diagram type labels for a document
37
+ * @param {string} content - Document content to analyze
38
+ * @returns {string[]} - Array of diagram type labels (e.g., ["D2", "AI Image", "Placeholder"])
39
+ */
40
+ export function getDiagramTypeLabels(content) {
41
+ if (!content || typeof content !== "string") {
42
+ return [];
43
+ }
44
+
45
+ const labels = [];
46
+
47
+ // Check for D2 code blocks
48
+ const d2Matches = Array.from(content.matchAll(d2CodeBlockRegex));
49
+ if (d2Matches.length > 0) {
50
+ labels.push("⛔️ D2");
51
+ }
52
+
53
+ // Check for existing diagram images (AI-generated images)
54
+ const imageMatches = Array.from(content.matchAll(diagramImageRegex));
55
+ if (imageMatches.length > 0) {
56
+ labels.push("🍌 Image");
57
+ }
58
+
59
+ // Check for DIAGRAM_PLACEHOLDER
60
+ if (content.includes(DIAGRAM_PLACEHOLDER)) {
61
+ labels.push("Placeholder");
62
+ }
63
+
64
+ return labels;
65
+ }
66
+
67
+ /**
68
+ * Format diagram type labels as a suffix string
69
+ * @param {string[]} labels - Array of diagram type labels
70
+ * @returns {string} - Formatted suffix string (e.g., " [D2, AI Image]")
71
+ */
72
+ export function formatDiagramTypeSuffix(labels) {
73
+ if (!labels || labels.length === 0) {
74
+ return "";
75
+ }
76
+ return ` [${labels.join(", ")}]`;
77
+ }
78
+
79
+ /**
80
+ * Check if document content contains banana images (AI-generated images)
81
+ * Only checks for DIAGRAM_IMAGE_START markers, excludes D2 code blocks and placeholders
82
+ * @param {string} content - Document content to check
83
+ * @returns {boolean} - True if document contains banana images
84
+ */
85
+ export function hasBananaImages(content) {
86
+ if (!content || typeof content !== "string") {
87
+ return false;
88
+ }
89
+
90
+ // Check for existing diagram images (DIAGRAM_IMAGE_START markers)
91
+ const imageMatches = Array.from(content.matchAll(diagramImageRegex));
92
+ if (imageMatches.length > 0) {
93
+ return true;
94
+ }
95
+
96
+ return false;
97
+ }
@@ -572,3 +572,49 @@ export const REASONING_EFFORT_LEVELS = {
572
572
  pro: 2000,
573
573
  },
574
574
  };
575
+
576
+ // Diagram styles - visual styles for diagram generation
577
+ export const DIAGRAM_STYLES = {
578
+ modern: {
579
+ name: "Modern",
580
+ description: "Modern, clean, professional style with contemporary design elements",
581
+ prompt:
582
+ "Modern, clean, professional diagram style with contemporary design elements, smooth lines, and a professional color scheme",
583
+ },
584
+ standard: {
585
+ name: "Standard Flowchart",
586
+ description: "Standard flowchart style with traditional symbols and formats",
587
+ prompt:
588
+ "Standard flowchart style with traditional symbols (rectangles for processes, diamonds for decisions, arrows for flows), clear and conventional formatting",
589
+ },
590
+ "hand-drawn": {
591
+ name: "Hand-drawn",
592
+ description: "Hand-drawn style with natural, organic lines and sketch-like appearance",
593
+ prompt:
594
+ "Hand-drawn, sketch-like style with natural, organic lines, slightly imperfect shapes, and a casual, approachable appearance",
595
+ },
596
+ anthropomorphic: {
597
+ name: "Anthropomorphic",
598
+ description: "Anthropomorphic style with personified elements and vivid imagery",
599
+ prompt:
600
+ "Anthropomorphic style with personified elements, vivid and lively imagery, characters or objects with human-like features, engaging and memorable",
601
+ },
602
+ flat: {
603
+ name: "Flat Design",
604
+ description: "Flat design style without shadows or 3D effects",
605
+ prompt:
606
+ "Flat design style with no shadows, gradients, or 3D effects, clean geometric shapes, bold colors, and minimalist aesthetics",
607
+ },
608
+ minimalist: {
609
+ name: "Minimalist",
610
+ description: "Minimalist style with minimal elements and maximum clarity",
611
+ prompt:
612
+ "Minimalist style with the fewest possible elements, maximum clarity, simple shapes, ample white space, and essential information only",
613
+ },
614
+ "3d": {
615
+ name: "3D",
616
+ description: "3D style with three-dimensional effects and perspective",
617
+ prompt:
618
+ "3D style with three-dimensional effects, perspective, depth, shadows, and realistic spatial relationships",
619
+ },
620
+ };