@aigne/doc-smith 0.9.10 → 0.9.11-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 (308) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +189 -219
  3. package/README.zh.md +270 -0
  4. package/agents/bash-executor/index.mjs +347 -0
  5. package/agents/clear/ai/intent.md +142 -0
  6. package/agents/clear/choose-contents.mjs +13 -65
  7. package/agents/clear/clear-auth-tokens.mjs +17 -21
  8. package/agents/clear/clear-deployment-config.mjs +33 -24
  9. package/agents/clear/index.yaml +1 -9
  10. package/agents/content-checker/ai/intent.md +209 -0
  11. package/agents/content-checker/clean-invalid-docs.mjs +254 -0
  12. package/agents/content-checker/index.mjs +191 -0
  13. package/agents/content-checker/validate-content.mjs +983 -0
  14. package/agents/generate-images/generate-image.yaml +75 -0
  15. package/agents/generate-images/generate-summary.mjs +213 -0
  16. package/agents/generate-images/index.yaml +39 -0
  17. package/agents/generate-images/prepare-generation.mjs +286 -0
  18. package/agents/generate-images/prepare-image-generation.mjs +130 -0
  19. package/{prompts/detail/diagram/generate-image-system.md → agents/generate-images/prompts/system.md} +22 -56
  20. package/agents/generate-images/prompts/user.md +85 -0
  21. package/agents/generate-images/save-image-result.mjs +247 -0
  22. package/agents/generate-images/scan-image-slots.mjs +247 -0
  23. package/agents/localize/index.yaml +19 -42
  24. package/{prompts/translate → agents/localize/prompts}/translate-document.md +0 -139
  25. package/agents/localize/translate-documents/generate-summary.mjs +163 -0
  26. package/agents/localize/translate-documents/load-glossary.mjs +52 -0
  27. package/agents/localize/translate-documents/prepare-translation.mjs +249 -0
  28. package/agents/localize/translate-documents/save-translation.mjs +171 -0
  29. package/agents/localize/translate-documents/translate-document-to-language.mjs +209 -0
  30. package/agents/localize/translate-documents/translate-document.yaml +23 -0
  31. package/agents/localize/translate-documents/translate-to-languages.yaml +10 -0
  32. package/agents/localize/translate-images/check-image-translation.mjs +225 -0
  33. package/agents/localize/translate-images/detect-text/detect-and-update-shared.mjs +148 -0
  34. package/agents/localize/translate-images/detect-text/detect-image-text.yaml +44 -0
  35. package/agents/localize/translate-images/detect-text/detect-images-text.yaml +21 -0
  36. package/agents/localize/translate-images/detect-text/prompts/detect-image-text-system.md +43 -0
  37. package/agents/localize/translate-images/detect-text/prompts/detect-image-text-user.md +14 -0
  38. package/agents/localize/translate-images/detect-text/save-text-detection.mjs +105 -0
  39. package/agents/localize/translate-images/prepare-image-input.mjs +124 -0
  40. package/agents/localize/translate-images/save-image-translation.mjs +172 -0
  41. package/agents/localize/translate-images/scan-doc-images.mjs +165 -0
  42. package/agents/localize/translate-images/translate-doc-images.yaml +24 -0
  43. package/agents/localize/{translate-diagram.yaml → translate-images/translate-image.yaml} +25 -14
  44. package/agents/publish/ai/intent.md +182 -0
  45. package/agents/publish/check.mjs +107 -0
  46. package/agents/publish/index.yaml +9 -14
  47. package/agents/publish/publish-docs.mjs +81 -61
  48. package/agents/publish/translate-meta.mjs +79 -58
  49. package/agents/save-document/index.mjs +260 -0
  50. package/agents/structure-checker/index.mjs +307 -0
  51. package/agents/structure-checker/validate-structure.mjs +477 -0
  52. package/agents/update-image/analyze-feedback.yaml +37 -0
  53. package/agents/update-image/index.yaml +78 -0
  54. package/agents/update-image/load-existing-image.mjs +211 -0
  55. package/agents/update-image/prompts/analyze-feedback-system.md +43 -0
  56. package/agents/update-image/prompts/analyze-feedback-user.md +15 -0
  57. package/aigne.yaml +26 -139
  58. package/package.json +16 -48
  59. package/scripts/README.md +90 -0
  60. package/scripts/install.sh +86 -0
  61. package/scripts/uninstall.sh +52 -0
  62. package/skills/doc-smith/SKILL.md +285 -0
  63. package/skills/doc-smith/ai/intent/sources-improve.md +290 -0
  64. package/skills/doc-smith/references/changeset-guide.md +171 -0
  65. package/skills/doc-smith/references/document-content-guide.md +214 -0
  66. package/skills/doc-smith/references/document-structure-schema.md +138 -0
  67. package/skills/doc-smith/references/patch-guide.md +96 -0
  68. package/skills/doc-smith/references/structure-confirmation-guide.md +133 -0
  69. package/skills/doc-smith/references/structure-planning-guide.md +149 -0
  70. package/skills/doc-smith/references/update-workflow.md +108 -0
  71. package/skills/doc-smith/references/user-intent-guide.md +175 -0
  72. package/skills/doc-smith/references/workspace-initialization.md +376 -0
  73. package/skills/doc-smith-docs-detail/SKILL.md +356 -0
  74. package/skills/doc-smith-docs-detail/ai/intent.md +271 -0
  75. package/skills-entry/doc-smith/ai/intent.md +260 -0
  76. package/skills-entry/doc-smith/index.mjs +66 -0
  77. package/skills-entry/doc-smith/prompt.md +57 -0
  78. package/skills-entry/doc-smith/utils.mjs +27 -0
  79. package/skills-entry/doc-smith-docs-detail/batch.yaml +56 -0
  80. package/skills-entry/doc-smith-docs-detail/index.mjs +95 -0
  81. package/skills-entry/doc-smith-docs-detail/prompt.md +64 -0
  82. package/utils/afs-factory.mjs +183 -0
  83. package/utils/agent-constants.mjs +97 -0
  84. package/utils/{auth-utils.mjs → auth.mjs} +6 -9
  85. package/{agents/utils/update-branding.mjs → utils/branding.mjs} +3 -4
  86. package/utils/config.mjs +261 -0
  87. package/utils/constants.mjs +32 -0
  88. package/utils/deploy.mjs +3 -3
  89. package/utils/docs-converter.mjs +454 -0
  90. package/utils/docs.mjs +212 -0
  91. package/utils/document-paths.mjs +172 -0
  92. package/utils/files.mjs +74 -0
  93. package/utils/git.mjs +65 -0
  94. package/utils/{blocklet.mjs → http.mjs} +18 -0
  95. package/utils/image-slots.mjs +57 -0
  96. package/utils/image-utils.mjs +114 -0
  97. package/utils/project.mjs +95 -0
  98. package/utils/sources-path-resolver.mjs +76 -0
  99. package/utils/{upload-files.mjs → upload.mjs} +3 -3
  100. package/utils/workspace.mjs +371 -0
  101. package/agents/chat/chat-system.md +0 -38
  102. package/agents/chat/index.mjs +0 -59
  103. package/agents/chat/skills/generate-document.yaml +0 -15
  104. package/agents/chat/skills/list-documents.mjs +0 -15
  105. package/agents/chat/skills/update-document.yaml +0 -24
  106. package/agents/clear/clear-document-config.mjs +0 -36
  107. package/agents/clear/clear-document-structure.mjs +0 -102
  108. package/agents/clear/clear-generated-docs.mjs +0 -142
  109. package/agents/clear/clear-media-description.mjs +0 -129
  110. package/agents/create/aggregate-document-structure.mjs +0 -21
  111. package/agents/create/analyze-diagram-type-llm.yaml +0 -159
  112. package/agents/create/analyze-diagram-type.mjs +0 -455
  113. package/agents/create/check-document-structure.yaml +0 -30
  114. package/agents/create/check-need-generate-structure.mjs +0 -138
  115. package/agents/create/document-structure-tools/add-document.mjs +0 -85
  116. package/agents/create/document-structure-tools/delete-document.mjs +0 -116
  117. package/agents/create/document-structure-tools/move-document.mjs +0 -109
  118. package/agents/create/document-structure-tools/update-document.mjs +0 -84
  119. package/agents/create/generate-diagram-image.yaml +0 -91
  120. package/agents/create/generate-structure.yaml +0 -106
  121. package/agents/create/index.yaml +0 -45
  122. package/agents/create/refine-document-structure.yaml +0 -12
  123. package/agents/create/replace-d2-with-image.mjs +0 -610
  124. package/agents/create/update-document-structure.yaml +0 -54
  125. package/agents/create/user-add-document/add-documents-to-structure.mjs +0 -90
  126. package/agents/create/user-add-document/find-documents-to-add-links.yaml +0 -47
  127. package/agents/create/user-add-document/index.yaml +0 -46
  128. package/agents/create/user-add-document/prepare-documents-to-translate.mjs +0 -22
  129. package/agents/create/user-add-document/print-add-document-summary.mjs +0 -63
  130. package/agents/create/user-add-document/review-documents-with-new-links.mjs +0 -110
  131. package/agents/create/user-remove-document/find-documents-with-invalid-links.mjs +0 -78
  132. package/agents/create/user-remove-document/index.yaml +0 -40
  133. package/agents/create/user-remove-document/prepare-documents-to-translate.mjs +0 -22
  134. package/agents/create/user-remove-document/print-remove-document-summary.mjs +0 -53
  135. package/agents/create/user-remove-document/remove-documents-from-structure.mjs +0 -99
  136. package/agents/create/user-remove-document/review-documents-with-invalid-links.mjs +0 -115
  137. package/agents/create/user-review-document-structure.mjs +0 -139
  138. package/agents/create/utils/init-current-content.mjs +0 -34
  139. package/agents/create/utils/merge-document-structures.mjs +0 -36
  140. package/agents/evaluate/code-snippet.mjs +0 -97
  141. package/agents/evaluate/document-structure.yaml +0 -67
  142. package/agents/evaluate/document.yaml +0 -82
  143. package/agents/evaluate/generate-report.mjs +0 -85
  144. package/agents/evaluate/index.yaml +0 -46
  145. package/agents/history/index.yaml +0 -6
  146. package/agents/history/view.mjs +0 -78
  147. package/agents/init/check.mjs +0 -16
  148. package/agents/init/index.mjs +0 -643
  149. package/agents/init/validate.mjs +0 -16
  150. package/agents/localize/choose-language.mjs +0 -107
  151. package/agents/localize/record-translation-history.mjs +0 -23
  152. package/agents/localize/save-doc-translation-or-skip.mjs +0 -18
  153. package/agents/localize/set-review-content.mjs +0 -58
  154. package/agents/localize/translate-document-wrapper.mjs +0 -34
  155. package/agents/localize/translate-document.yaml +0 -24
  156. package/agents/localize/translate-multilingual.yaml +0 -57
  157. package/agents/localize/translate-or-skip-diagram.mjs +0 -52
  158. package/agents/media/batch-generate-media-description.yaml +0 -46
  159. package/agents/media/generate-media-description.yaml +0 -50
  160. package/agents/media/load-media-description.mjs +0 -454
  161. package/agents/prefs/index.mjs +0 -203
  162. package/agents/schema/document-structure-item.yaml +0 -26
  163. package/agents/schema/document-structure-refine-item.yaml +0 -23
  164. package/agents/schema/document-structure.yaml +0 -29
  165. package/agents/update/batch-generate-document.yaml +0 -27
  166. package/agents/update/batch-update-document.yaml +0 -7
  167. package/agents/update/check-diagram-flag.mjs +0 -116
  168. package/agents/update/check-document.mjs +0 -162
  169. package/agents/update/check-generate-diagram.mjs +0 -106
  170. package/agents/update/check-update-is-single.mjs +0 -53
  171. package/agents/update/document-tools/update-document-content.mjs +0 -303
  172. package/agents/update/generate-diagram.yaml +0 -80
  173. package/agents/update/generate-document.yaml +0 -70
  174. package/agents/update/handle-document-update.yaml +0 -103
  175. package/agents/update/index.yaml +0 -69
  176. package/agents/update/pre-check-generate-diagram.yaml +0 -44
  177. package/agents/update/save-and-translate-document.mjs +0 -80
  178. package/agents/update/update-document-detail.yaml +0 -71
  179. package/agents/update/update-single/update-single-document-detail.mjs +0 -322
  180. package/agents/update/update-single-document.yaml +0 -7
  181. package/agents/update/user-review-document.mjs +0 -272
  182. package/agents/utils/action-success.mjs +0 -16
  183. package/agents/utils/analyze-document-feedback-intent.yaml +0 -32
  184. package/agents/utils/analyze-feedback-intent.mjs +0 -253
  185. package/agents/utils/analyze-structure-feedback-intent.yaml +0 -29
  186. package/agents/utils/check-detail-result.mjs +0 -51
  187. package/agents/utils/check-feedback-refiner.mjs +0 -81
  188. package/agents/utils/choose-docs.mjs +0 -251
  189. package/agents/utils/document-icon-generate.yaml +0 -52
  190. package/agents/utils/document-title-streamline.yaml +0 -48
  191. package/agents/utils/ensure-document-icons.mjs +0 -129
  192. package/agents/utils/exit.mjs +0 -6
  193. package/agents/utils/feedback-refiner.yaml +0 -50
  194. package/agents/utils/find-item-by-path.mjs +0 -114
  195. package/agents/utils/find-user-preferences-by-path.mjs +0 -37
  196. package/agents/utils/format-document-structure.mjs +0 -35
  197. package/agents/utils/generate-document-or-skip.mjs +0 -41
  198. package/agents/utils/handle-diagram-operations.mjs +0 -263
  199. package/agents/utils/load-all-document-content.mjs +0 -30
  200. package/agents/utils/load-document-all-content.mjs +0 -96
  201. package/agents/utils/load-sources.mjs +0 -405
  202. package/agents/utils/map-reasoning-effort-level.mjs +0 -15
  203. package/agents/utils/post-generate.mjs +0 -133
  204. package/agents/utils/read-current-document-content.mjs +0 -46
  205. package/agents/utils/save-doc-translation.mjs +0 -30
  206. package/agents/utils/save-doc.mjs +0 -54
  207. package/agents/utils/save-output.mjs +0 -26
  208. package/agents/utils/save-sidebar.mjs +0 -38
  209. package/agents/utils/skip-if-content-exists.mjs +0 -27
  210. package/agents/utils/streamline-document-titles-if-needed.mjs +0 -88
  211. package/agents/utils/transform-detail-data-sources.mjs +0 -45
  212. package/assets/report-template/report.html +0 -198
  213. package/docs-mcp/analyze-content-relevance.yaml +0 -50
  214. package/docs-mcp/analyze-docs-relevance.yaml +0 -59
  215. package/docs-mcp/docs-search.yaml +0 -42
  216. package/docs-mcp/get-docs-detail.mjs +0 -41
  217. package/docs-mcp/get-docs-structure.mjs +0 -16
  218. package/docs-mcp/read-doc-content.mjs +0 -119
  219. package/prompts/common/document/content-rules-core.md +0 -20
  220. package/prompts/common/document/markdown-syntax-rules.md +0 -65
  221. package/prompts/common/document/media-file-list-usage-rules.md +0 -18
  222. package/prompts/common/document/openapi-usage-rules.md +0 -189
  223. package/prompts/common/document/role-and-personality.md +0 -16
  224. package/prompts/common/document/user-preferences.md +0 -9
  225. package/prompts/common/document-structure/conflict-resolution-guidance.md +0 -16
  226. package/prompts/common/document-structure/document-icon-generate.md +0 -116
  227. package/prompts/common/document-structure/document-structure-rules.md +0 -43
  228. package/prompts/common/document-structure/document-title-streamline.md +0 -86
  229. package/prompts/common/document-structure/glossary.md +0 -7
  230. package/prompts/common/document-structure/intj-traits.md +0 -5
  231. package/prompts/common/document-structure/openapi-usage-rules.md +0 -28
  232. package/prompts/common/document-structure/output-constraints.md +0 -18
  233. package/prompts/common/document-structure/user-locale-rules.md +0 -10
  234. package/prompts/common/document-structure/user-preferences.md +0 -9
  235. package/prompts/detail/custom/admonition-usage-rules.md +0 -94
  236. package/prompts/detail/custom/code-block-usage-rules.md +0 -163
  237. package/prompts/detail/custom/custom-components/x-card-usage-rules.md +0 -63
  238. package/prompts/detail/custom/custom-components/x-cards-usage-rules.md +0 -83
  239. package/prompts/detail/custom/custom-components/x-field-desc-usage-rules.md +0 -120
  240. package/prompts/detail/custom/custom-components/x-field-group-usage-rules.md +0 -80
  241. package/prompts/detail/custom/custom-components/x-field-usage-rules.md +0 -189
  242. package/prompts/detail/custom/custom-components-usage-rules.md +0 -18
  243. package/prompts/detail/diagram/generate-image-user.md +0 -81
  244. package/prompts/detail/diagram/guide.md +0 -29
  245. package/prompts/detail/diagram/official-examples.md +0 -712
  246. package/prompts/detail/diagram/pre-check.md +0 -23
  247. package/prompts/detail/diagram/role-and-personality.md +0 -2
  248. package/prompts/detail/diagram/rules.md +0 -46
  249. package/prompts/detail/diagram/system-prompt.md +0 -1139
  250. package/prompts/detail/diagram/user-prompt.md +0 -43
  251. package/prompts/detail/generate/detail-example.md +0 -457
  252. package/prompts/detail/generate/document-rules.md +0 -45
  253. package/prompts/detail/generate/system-prompt.md +0 -61
  254. package/prompts/detail/generate/user-prompt.md +0 -99
  255. package/prompts/detail/jsx/rules.md +0 -6
  256. package/prompts/detail/update/system-prompt.md +0 -121
  257. package/prompts/detail/update/user-prompt.md +0 -41
  258. package/prompts/evaluate/document-structure.md +0 -93
  259. package/prompts/evaluate/document.md +0 -149
  260. package/prompts/media/media-description/system-prompt.md +0 -43
  261. package/prompts/media/media-description/user-prompt.md +0 -17
  262. package/prompts/structure/check-document-structure.md +0 -93
  263. package/prompts/structure/document-rules.md +0 -21
  264. package/prompts/structure/find-documents-to-add-links.md +0 -52
  265. package/prompts/structure/generate/system-prompt.md +0 -13
  266. package/prompts/structure/generate/user-prompt.md +0 -137
  267. package/prompts/structure/review/structure-review-system.md +0 -81
  268. package/prompts/structure/structure-example.md +0 -89
  269. package/prompts/structure/structure-getting-started.md +0 -10
  270. package/prompts/structure/update/system-prompt.md +0 -93
  271. package/prompts/structure/update/user-prompt.md +0 -43
  272. package/prompts/translate/admonition.md +0 -20
  273. package/prompts/translate/code-block.md +0 -33
  274. package/prompts/utils/analyze-document-feedback-intent.md +0 -54
  275. package/prompts/utils/analyze-structure-feedback-intent.md +0 -43
  276. package/prompts/utils/feedback-refiner.md +0 -105
  277. package/types/document-schema.mjs +0 -55
  278. package/types/document-structure-schema.mjs +0 -261
  279. package/utils/check-document-has-diagram.mjs +0 -95
  280. package/utils/conflict-detector.mjs +0 -149
  281. package/utils/constants/index.mjs +0 -620
  282. package/utils/constants/linter.mjs +0 -102
  283. package/utils/d2-utils.mjs +0 -205
  284. package/utils/debug.mjs +0 -3
  285. package/utils/delete-diagram-images.mjs +0 -99
  286. package/utils/diagram-version-utils.mjs +0 -14
  287. package/utils/docs-finder-utils.mjs +0 -548
  288. package/utils/evaluate/report-utils.mjs +0 -132
  289. package/utils/extract-api.mjs +0 -32
  290. package/utils/file-utils.mjs +0 -960
  291. package/utils/history-utils.mjs +0 -203
  292. package/utils/icon-map.mjs +0 -26
  293. package/utils/image-compress.mjs +0 -154
  294. package/utils/kroki-utils.mjs +0 -173
  295. package/utils/linter/index.mjs +0 -50
  296. package/utils/load-config.mjs +0 -78
  297. package/utils/markdown/index.mjs +0 -26
  298. package/utils/markdown-checker.mjs +0 -694
  299. package/utils/mermaid-validator.mjs +0 -140
  300. package/utils/mermaid-worker-pool.mjs +0 -250
  301. package/utils/mermaid-worker.mjs +0 -233
  302. package/utils/openapi/index.mjs +0 -28
  303. package/utils/preferences-utils.mjs +0 -175
  304. package/utils/request.mjs +0 -10
  305. package/utils/sync-diagram-to-translations.mjs +0 -272
  306. package/utils/translate-diagram-images.mjs +0 -807
  307. package/utils/utils.mjs +0 -1354
  308. /package/{prompts/translate → agents/localize/prompts}/glossary.md +0 -0
@@ -1,455 +0,0 @@
1
- import { DIAGRAM_STYLES } from "../../utils/constants/index.mjs";
2
- import path from "node:path";
3
- import fs from "fs-extra";
4
-
5
- const DEFAULT_DIAGRAM_STYLE = "modern";
6
- const DEFAULT_DIAGRAM_TYPE = "flowchart";
7
-
8
- // Type-specific content requirements
9
- const TYPE_REQUIREMENTS = {
10
- architecture: `- Accurately represent the system architecture, components, services, and their relationships
11
- - Show clear component boundaries and service interactions
12
- - Include all key architectural elements (layers, modules, services, databases, APIs)
13
- - Display data flow and communication patterns between components
14
- - Use clear labels for each component and connection`,
15
- flowchart: `- Accurately represent the process flow, steps, decisions, and workflow
16
- - Show clear step-by-step progression with decision points
17
- - Use standard flowchart symbols: rectangles for processes, diamonds for decisions, arrows for flows
18
- - Include all key steps and decision branches
19
- - Maintain logical flow direction (top-to-bottom or left-to-right)`,
20
- guide: `- Show user journey, tutorial flow, or guided process
21
- - Display clear progression from start to completion
22
- - Include key milestones, checkpoints, or decision points
23
- - Use clear visual cues to guide the viewer through the process
24
- - Make it easy to follow and understand the path`,
25
- intro: `- Provide a high-level overview or conceptual explanation
26
- - Show main concepts, relationships, and key ideas
27
- - Use clear visual hierarchy to emphasize important elements
28
- - Make it accessible and easy to understand for newcomers
29
- - Focus on big picture rather than detailed implementation`,
30
- sequence: `- Show interactions over time between components or actors
31
- - Display clear message flow and timing
32
- - Include all participating entities and their interactions
33
- - Show chronological order of events
34
- - Use clear labels for messages and interactions`,
35
- network: `- Show network structure, nodes, and connections
36
- - Display routing paths and network topology
37
- - Include all network components (routers, switches, servers, clients)
38
- - Show connection types and data flow directions
39
- - Use clear labels for network elements`,
40
- };
41
-
42
- // Style-specific requirements
43
- const STYLE_REQUIREMENTS = {
44
- modern: `- Modern, clean, professional diagram style
45
- - Contemporary design elements with smooth lines
46
- - Professional color scheme suitable for technical documentation
47
- - Clear visual hierarchy and readable text
48
- - Sleek and polished appearance`,
49
- standard: `- Standard flowchart style with traditional symbols
50
- - Conventional formatting and clear structure
51
- - Rectangles for processes, diamonds for decisions, arrows for flows
52
- - Clear, readable text labels
53
- - Professional and familiar appearance`,
54
- "hand-drawn": `- Hand-drawn, sketch-like style with natural, organic lines
55
- - Slightly imperfect shapes for a casual, approachable appearance
56
- - Natural line variations and hand-drawn aesthetics
57
- - Friendly and informal visual style
58
- - Avoid perfect geometric shapes`,
59
- anthropomorphic: `- Anthropomorphic style with personified elements
60
- - Vivid and lively imagery with characters or objects having human-like features
61
- - Engaging and memorable visual elements
62
- - Creative and expressive design
63
- - Make abstract concepts more relatable through personification`,
64
- flat: `- Flat design style with no shadows, gradients, or 3D effects
65
- - Clean geometric shapes with bold colors
66
- - Minimalist aesthetics with simple, flat surfaces
67
- - Modern and clean appearance
68
- - Avoid depth and dimensionality`,
69
- minimalist: `- Minimalist style with the fewest possible elements
70
- - Maximum clarity with simple shapes
71
- - Ample white space and essential information only
72
- - Clean and uncluttered appearance
73
- - Focus on core message without distractions`,
74
- "3d": `- 3D style with three-dimensional effects and perspective
75
- - Depth, shadows, and realistic spatial relationships
76
- - Three-dimensional appearance with volume and dimension
77
- - Professional and modern 3D rendering
78
- - Clear depth cues and perspective`,
79
- };
80
-
81
- /**
82
- * Convert diagramInfo from analyzeFeedbackIntent to mediaFile format
83
- * @param {Object} diagramInfo - Diagram info from analyzeFeedbackIntent (contains path, index, markdown)
84
- * @param {string} docPath - Document path
85
- * @param {string} docsDir - Documentation directory
86
- * @returns {Promise<Array|null>} - Array of mediaFile objects or null if conversion fails
87
- * Note: Currently each document has only one diagram, so we always use the first (and only) image
88
- */
89
- async function convertDiagramInfoToMediaFile(diagramInfo, docPath, docsDir) {
90
- if (!diagramInfo || !diagramInfo.path) {
91
- return null;
92
- }
93
-
94
- try {
95
- const imagePath = diagramInfo.path;
96
- const docDir = path.dirname(docPath);
97
-
98
- // Resolve absolute path
99
- let absolutePath;
100
- if (imagePath.startsWith("http://") || imagePath.startsWith("https://")) {
101
- // Remote URL, cannot convert to local file
102
- return null;
103
- } else if (path.isAbsolute(imagePath)) {
104
- absolutePath = imagePath;
105
- } else {
106
- // Relative path - resolve from document location
107
- const imageRelativePath = imagePath.startsWith("../")
108
- ? imagePath
109
- : path.join(docDir, imagePath).replace(/\\/g, "/");
110
- absolutePath = path.join(process.cwd(), docsDir, imageRelativePath);
111
- }
112
-
113
- // Normalize path
114
- const normalizedPath = path.normalize(absolutePath);
115
-
116
- // Check if file exists
117
- if (!(await fs.pathExists(normalizedPath))) {
118
- return null;
119
- }
120
-
121
- // Get file info
122
- const ext = path.extname(normalizedPath).toLowerCase().slice(1);
123
- const filename = path.basename(normalizedPath);
124
-
125
- // Determine MIME type
126
- const mimeTypes = {
127
- jpg: "image/jpeg",
128
- jpeg: "image/jpeg",
129
- png: "image/png",
130
- webp: "image/webp",
131
- gif: "image/gif",
132
- };
133
- const mimeType = mimeTypes[ext] || "image/png";
134
-
135
- // Return mediaFile format (array as required by input_file_key)
136
- return [
137
- {
138
- type: "local",
139
- path: normalizedPath,
140
- filename,
141
- mimeType,
142
- },
143
- ];
144
- } catch (error) {
145
- console.warn(`Failed to convert diagramInfo to mediaFile: ${error.message}`);
146
- return null;
147
- }
148
- }
149
-
150
- /**
151
- * Analyze document content to determine diagram type and select appropriate style
152
- * Uses LLM analysis to determine diagram type and style
153
- * Supports extracting style and type preferences from user feedback
154
- * Now also detects existing images and determines if image-to-image generation should be used
155
- */
156
- export default async function analyzeDiagramType(
157
- {
158
- documentContent,
159
- availableStyles = [],
160
- defaultStyle,
161
- diagramming,
162
- locale = "en",
163
- feedback = "",
164
- path,
165
- docsDir,
166
- // Analysis results from first layer (analyzeFeedbackIntent)
167
- intentAnalysis,
168
- },
169
- options,
170
- ) {
171
- // Extract defaultStyle from diagramming object if not provided directly
172
- if (!defaultStyle && diagramming?.style) {
173
- defaultStyle = diagramming.style;
174
- }
175
-
176
- // Step 1: Use LLM to analyze document content (chart detection and intent analysis already done in first layer)
177
- const llmAgent = options.context?.agents?.["analyzeDiagramTypeLLM"];
178
- let llmResult = null;
179
-
180
- if (llmAgent) {
181
- try {
182
- // Build styleDescriptions object for template
183
- // Include predefined styles as reference, but allow LLM to use any style
184
- const styleDescriptions = {};
185
- const stylesToUse =
186
- availableStyles.length > 0 ? availableStyles : Object.keys(DIAGRAM_STYLES);
187
- for (const style of stylesToUse) {
188
- if (DIAGRAM_STYLES[style]) {
189
- styleDescriptions[style] =
190
- DIAGRAM_STYLES[style].description || DIAGRAM_STYLES[style].name;
191
- }
192
- }
193
- // Also include all predefined styles as reference even if not in availableStyles
194
- // This helps LLM understand common style options but doesn't restrict it
195
- for (const [style, styleInfo] of Object.entries(DIAGRAM_STYLES)) {
196
- if (!styleDescriptions[style]) {
197
- styleDescriptions[style] = styleInfo.description || styleInfo.name;
198
- }
199
- }
200
-
201
- const llmInput = {
202
- documentContent,
203
- availableStyles: stylesToUse,
204
- styleDescriptions,
205
- locale,
206
- feedback: feedback || "",
207
- defaultStyle: defaultStyle || null,
208
- // Note: We only analyze current documentContent, no originalContent comparison
209
- // User feedback is the only indicator for whether diagram needs update
210
- };
211
-
212
- llmResult = await options.context.invoke(llmAgent, llmInput);
213
- } catch (error) {
214
- console.warn(`⚠️ LLM analysis failed: ${error.message}`);
215
- }
216
- }
217
-
218
- // Step 2: Determine diagram type
219
- // Priority: LLM result (which already analyzed feedback) > default
220
- const diagramType = llmResult?.diagramType || DEFAULT_DIAGRAM_TYPE;
221
-
222
- // Step 3: Select style
223
- // Trust LLM to always return a valid style (required in output_schema)
224
- // LLM can return any style name, not limited to predefined styles
225
- // Only use fallback if LLM completely failed
226
- const diagramStyle = llmResult?.diagramStyle || defaultStyle || DEFAULT_DIAGRAM_STYLE;
227
-
228
- // Note: We allow any style name from LLM, even if not in availableStyles
229
- // This enables creative styles beyond predefined ones (e.g., 'watercolor', 'cyberpunk', 'isometric')
230
- // If availableStyles is provided and not empty, it serves as a preference guide, not a strict restriction
231
-
232
- // Step 4: Generate prompt requirements for image generation
233
- const diagramTypeRequirements =
234
- TYPE_REQUIREMENTS[diagramType] || TYPE_REQUIREMENTS[DEFAULT_DIAGRAM_TYPE];
235
- const diagramStyleRequirements =
236
- STYLE_REQUIREMENTS[diagramStyle] || STYLE_REQUIREMENTS[DEFAULT_DIAGRAM_STYLE];
237
-
238
- // Generate negative prompt exclusions based on style
239
- let negativePromptExclusions = "";
240
- if (diagramStyle !== "anthropomorphic") {
241
- negativePromptExclusions += ", anthropomorphic";
242
- }
243
- if (diagramStyle !== "hand-drawn") {
244
- negativePromptExclusions += ", hand-drawn, sketch";
245
- }
246
-
247
- // Step 5: Extract document summary from LLM result
248
- // The LLM creates a concise summary focusing on key elements for diagram generation
249
- // This ensures both the analysis model and image generation model have consistent understanding
250
- const documentSummary = llmResult?.documentSummary || documentContent;
251
-
252
- // If LLM didn't provide a summary (fallback), use original content
253
- // But prefer the LLM-generated summary as it's focused and aligned with the analysis
254
-
255
- // Step 6: Determine aspect ratio from LLM result
256
- // The LLM analyzes the content structure and recommends the best aspect ratio
257
- // We trust the LLM's judgment as it has analyzed the actual content
258
- // If LLM doesn't provide aspectRatio (shouldn't happen, but fallback for safety), use 4:3 as safe default
259
- let aspectRatio = llmResult?.aspectRatio || "4:3";
260
-
261
- // Validate that the aspectRatio is one of the supported values
262
- const supportedRatios = ["1:1", "5:4", "4:3", "3:2", "16:9", "21:9"];
263
- if (!supportedRatios.includes(aspectRatio)) {
264
- console.warn(`Invalid aspectRatio "${aspectRatio}" from LLM, falling back to "4:3"`);
265
- aspectRatio = "4:3";
266
- }
267
-
268
- // Step 2: Use analysis results from first layer (analyzeFeedbackIntent)
269
- // Get generationMode and diagramInfo from intentAnalysis
270
- const generationMode = intentAnalysis?.generationMode || "add-new";
271
- const diagramInfo = intentAnalysis?.diagramInfo || null;
272
-
273
- // Step 3: Convert diagramInfo to mediaFile format if needed for image-to-image generation
274
- let existingImage = null;
275
- let useImageToImage = false;
276
-
277
- if (diagramInfo && generationMode === "image-to-image" && path && docsDir) {
278
- // Convert diagramInfo to the format expected by image generation agent
279
- existingImage = await convertDiagramInfoToMediaFile(diagramInfo, path, docsDir);
280
- useImageToImage = existingImage !== null;
281
- }
282
-
283
- // Step 3: Return document content and summary for image generation
284
- return {
285
- diagramType,
286
- diagramStyle,
287
- aspectRatio,
288
- documentContent, // The full document content (kept for backward compatibility and additional context)
289
- documentSummary, // The concise summary generated by LLM, focused on key elements for diagram generation
290
- diagramTypeRequirements,
291
- diagramStyleRequirements,
292
- negativePromptExclusions,
293
- // Image-to-image generation support (from LLM analysis)
294
- existingImage, // Array of mediaFile objects or null
295
- useImageToImage, // Boolean indicating if image-to-image mode should be used
296
- generationMode, // Generation mode from LLM: "text-only", "image-to-image", "remove-image", "add-new"
297
- };
298
- }
299
-
300
- analyzeDiagramType.input_schema = {
301
- type: "object",
302
- properties: {
303
- documentContent: {
304
- type: "string",
305
- description: "The document content to analyze for diagram type and style selection",
306
- },
307
- availableStyles: {
308
- type: "array",
309
- description:
310
- "List of available diagram styles configured by user (optional restriction). If empty, any style is allowed.",
311
- items: {
312
- type: "string",
313
- },
314
- },
315
- defaultStyle: {
316
- type: "string",
317
- description:
318
- "Default diagram style to use when no style is specified in feedback. Can be any style name, not limited to predefined styles.",
319
- },
320
- diagramming: {
321
- type: "object",
322
- description: "Diagramming configuration object (alternative way to pass style)",
323
- properties: {
324
- style: {
325
- type: "string",
326
- description: "Default diagram style",
327
- },
328
- },
329
- },
330
- locale: {
331
- type: "string",
332
- description: "Language for analysis",
333
- default: "en",
334
- },
335
- feedback: {
336
- type: "string",
337
- description:
338
- "User feedback that may contain style or type preferences (e.g., 'use anthropomorphic style', 'create architecture diagram')",
339
- default: "",
340
- },
341
- path: {
342
- type: "string",
343
- description:
344
- "Document path (e.g., 'guides/getting-started.md') used for extracting existing images",
345
- },
346
- docsDir: {
347
- type: "string",
348
- description: "Documentation directory where diagram images are stored",
349
- },
350
- },
351
- required: ["documentContent"],
352
- };
353
-
354
- analyzeDiagramType.output_schema = {
355
- type: "object",
356
- properties: {
357
- diagramType: {
358
- type: "string",
359
- description: "The detected diagram type",
360
- },
361
- diagramStyle: {
362
- type: "string",
363
- description: "The selected diagram style",
364
- },
365
- diagramTypeRequirements: {
366
- type: "string",
367
- description: "Content requirements for the diagram type",
368
- },
369
- diagramStyleRequirements: {
370
- type: "string",
371
- description: "Style requirements for the diagram style",
372
- },
373
- negativePromptExclusions: {
374
- type: "string",
375
- description: "Additional negative prompt exclusions based on style",
376
- },
377
- aspectRatio: {
378
- type: "string",
379
- description: "Aspect ratio for the diagram (must match content flow direction)",
380
- enum: ["1:1", "5:4", "4:3", "3:2", "16:9", "21:9"],
381
- },
382
- documentContent: {
383
- type: "string",
384
- description:
385
- "The full document content (kept for backward compatibility and additional context)",
386
- },
387
- documentSummary: {
388
- type: "string",
389
- description:
390
- "A concise summary of the document content focusing on key elements needed for diagram generation. This summary is generated by the analysis LLM to ensure consistent understanding between analysis and image generation models.",
391
- },
392
- existingImage: {
393
- type: "array",
394
- nullable: true,
395
- description:
396
- "Array of mediaFile objects for existing diagram image (for image-to-image generation). Null if no existing image or text-only regeneration requested.",
397
- items: {
398
- type: "object",
399
- properties: {
400
- type: { type: "string" },
401
- path: { type: "string" },
402
- filename: { type: "string" },
403
- mimeType: { type: "string" },
404
- },
405
- },
406
- },
407
- useImageToImage: {
408
- type: "boolean",
409
- description:
410
- "Whether to use image-to-image generation mode. True if existing image found and generationMode is 'image-to-image'.",
411
- },
412
- generationMode: {
413
- type: "string",
414
- description: "Generation mode determined from intentAnalysis (from analyzeFeedbackIntent).",
415
- },
416
- intentAnalysis: {
417
- type: "object",
418
- description:
419
- "Analysis results from analyzeFeedbackIntent containing intentType, diagramInfo, generationMode, and changes.",
420
- properties: {
421
- intentType: {
422
- type: "string",
423
- enum: ["addDiagram", "updateDiagram", "deleteDiagram", "updateDocument"],
424
- },
425
- diagramInfo: {
426
- type: "object",
427
- nullable: true,
428
- properties: {
429
- path: { type: "string" },
430
- index: { type: "number" },
431
- markdown: { type: "string" },
432
- },
433
- },
434
- generationMode: {
435
- type: "string",
436
- },
437
- changes: {
438
- type: "array",
439
- items: { type: "string" },
440
- },
441
- },
442
- },
443
- },
444
- required: [
445
- "diagramType",
446
- "diagramStyle",
447
- "aspectRatio",
448
- "documentSummary",
449
- "diagramTypeRequirements",
450
- "diagramStyleRequirements",
451
- "negativePromptExclusions",
452
- "documentContent",
453
- "useImageToImage",
454
- ],
455
- };
@@ -1,30 +0,0 @@
1
- name: checkDocumentStructure
2
- description: Check the Documentation Structure to ensure it meets expectations, especially in scenarios with previous generation results and user feedback.
3
- instructions:
4
- url: ../../prompts/structure/check-document-structure.md
5
- input_schema:
6
- type: object
7
- properties:
8
- documentStructure:
9
- $ref: ../schema/document-structure.yaml
10
- description: Newly generated documentation structure.
11
- originalDocumentStructure:
12
- $ref: ../schema/document-structure.yaml
13
- description: Previous generation's documentation structure for comparison. If it doesn't exist, the check passes by default.
14
- feedback:
15
- type: string
16
- description: User feedback provided for the previous generation's results.
17
- required:
18
- - documentStructure
19
- output_schema:
20
- type: object
21
- properties:
22
- isValid:
23
- type: boolean
24
- description: Whether the check passes. true indicates pass, false indicates failure.
25
- structureReviewFeedback:
26
- type: string
27
- description: Detailed explanation of the check results. If it fails, clearly specify which parts do not meet requirements.
28
- required:
29
- - isValid
30
- - structureReviewFeedback
@@ -1,138 +0,0 @@
1
- import chalk from "chalk";
2
- import { getActiveRulesForScope } from "../../utils/preferences-utils.mjs";
3
- import { getProjectInfo, loadConfigFromFile, saveValueToConfig } from "../../utils/utils.mjs";
4
- import streamlineDocumentTitlesIfNeeded from "../utils/streamline-document-titles-if-needed.mjs";
5
-
6
- export default async function checkNeedGenerateStructure(
7
- { originalDocumentStructure, forceRegenerate, ...rest },
8
- options,
9
- ) {
10
- // Check if originalDocumentStructure is empty and prompt user
11
- if (!originalDocumentStructure) {
12
- const choice = await options.prompts.select({
13
- message: "Project configured. Generate documentation structure now?",
14
- choices: [
15
- {
16
- name: "Yes, generate now",
17
- value: "generate",
18
- },
19
- {
20
- name: "No, review configuration first",
21
- value: "later",
22
- },
23
- ],
24
- });
25
-
26
- if (choice === "later") {
27
- console.log(`\nConfiguration file: ${chalk.cyan("./.aigne/doc-smith/config.yaml")}`);
28
- console.log("Review and edit your configuration, then run `aigne doc create` to continue.");
29
-
30
- // In test environment, return a special result instead of exiting
31
- if (process.env.NODE_ENV === "test") {
32
- return {
33
- userDeferred: true,
34
- documentStructure: null,
35
- };
36
- }
37
-
38
- process.exit(0);
39
- }
40
- }
41
-
42
- let finalFeedback = "";
43
-
44
- // User requested regeneration
45
- if (forceRegenerate) {
46
- finalFeedback = `
47
- User requested forced regeneration of documentation structure. Please regenerate based on the latest Data Sources and user requirements, **allowing any modifications**.
48
- `;
49
- }
50
-
51
- if (originalDocumentStructure && !forceRegenerate) {
52
- return {
53
- documentStructure: originalDocumentStructure,
54
- };
55
- }
56
-
57
- const generateStructureAgent = options.context.agents["generateStructure"];
58
-
59
- const structureRules = getActiveRulesForScope("structure", []);
60
- const globalRules = getActiveRulesForScope("global", []);
61
-
62
- const allApplicableRules = [...structureRules, ...globalRules];
63
- const ruleTexts = allApplicableRules.map((rule) => rule.rule);
64
-
65
- const userPreferences = ruleTexts.length > 0 ? ruleTexts.join("\n\n") : "";
66
-
67
- const result = await options.context.invoke(generateStructureAgent, {
68
- ...rest,
69
- originalDocumentStructure,
70
- userPreferences,
71
- feedback: finalFeedback || "",
72
- });
73
-
74
- await streamlineDocumentTitlesIfNeeded({ documentStructure: result.documentStructure }, options);
75
- options.context.userContext.streamlinedDocumentTitles = true;
76
-
77
- let message = "";
78
-
79
- // Check and save project information
80
- if (result.projectName || result.projectDesc) {
81
- try {
82
- const currentConfig = await loadConfigFromFile();
83
- const projectInfo = await getProjectInfo();
84
-
85
- const userModifiedProjectName =
86
- currentConfig?.projectName && currentConfig.projectName !== projectInfo.name;
87
- const userModifiedProjectDesc =
88
- currentConfig?.projectDesc && currentConfig.projectDesc !== projectInfo.description;
89
-
90
- // Save AI-generated project info if not modified by the user and not from GitHub
91
- if (!userModifiedProjectName && !userModifiedProjectDesc) {
92
- let hasUpdated = false;
93
- // Don't update if the current info is from GitHub
94
- if (
95
- result.projectName &&
96
- result.projectName !== projectInfo.name &&
97
- !projectInfo.fromGitHub
98
- ) {
99
- // Remove leading and trailing spaces (middle spaces are preserved and count toward limit)
100
- const trimmedProjectName = result.projectName.trim();
101
- await saveValueToConfig("projectName", trimmedProjectName);
102
- message += `Project name: \`${trimmedProjectName}\``;
103
- hasUpdated = true;
104
- }
105
-
106
- if (
107
- result.projectDesc &&
108
- result.projectDesc !== projectInfo.description &&
109
- !projectInfo.fromGitHub
110
- ) {
111
- // Remove leading and trailing spaces (middle spaces are preserved and count toward limit)
112
- const trimmedProjectDesc = result.projectDesc.trim();
113
- await saveValueToConfig("projectDesc", trimmedProjectDesc);
114
- message += `\nProject description: \`${trimmedProjectDesc}\``;
115
- hasUpdated = true;
116
- }
117
-
118
- if (hasUpdated) {
119
- message = `\n## Project Information Updated\n\nSaved to \`.aigne/doc-smith/config.yaml\`:\n\n${message}\n\n`;
120
- }
121
- }
122
- } catch (error) {
123
- console.warn("Failed to check/save project information:", error.message);
124
- }
125
- }
126
-
127
- return {
128
- ...result,
129
- feedback: "", // clear feedback
130
- projectInfoMessage: message,
131
- originalDocumentStructure: originalDocumentStructure
132
- ? originalDocumentStructure
133
- : JSON.parse(JSON.stringify(result.documentStructure || [])),
134
- };
135
- }
136
-
137
- checkNeedGenerateStructure.taskTitle =
138
- "Check if documentation structure needs to be generated or updated";