@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,142 +0,0 @@
1
- import { rm } from "node:fs/promises";
2
- import { join } from "node:path";
3
- import { pathExists, resolveToAbsolute, toDisplayPath } from "../../utils/file-utils.mjs";
4
- import {
5
- pathToFlatName,
6
- generateFileName,
7
- loadDocumentStructure,
8
- } from "../../utils/docs-finder-utils.mjs";
9
- import chooseDocs from "../utils/choose-docs.mjs";
10
-
11
- export default async function clearGeneratedDocs(input = {}, options = {}) {
12
- const { docsDir, outputDir, locale, translateLanguages } = input;
13
-
14
- if (!docsDir) {
15
- return {
16
- message: "📁 No generated documents directory specified",
17
- };
18
- }
19
-
20
- const generatedDocsPath = resolveToAbsolute(docsDir);
21
- const displayPath = toDisplayPath(generatedDocsPath);
22
-
23
- try {
24
- const dirExists = await pathExists(generatedDocsPath);
25
- if (!dirExists) {
26
- return {
27
- message: `📁 Generated documents directory does not exist (${displayPath})`,
28
- cleared: false,
29
- };
30
- }
31
-
32
- const documentStructure = (await loadDocumentStructure(outputDir)) || [];
33
- // select documents interactively
34
- const chooseResult = await chooseDocs(
35
- {
36
- docs: [], // Empty to trigger interactive selection
37
- documentStructure,
38
- docsDir: generatedDocsPath,
39
- locale: locale || "en",
40
- isTranslate: false,
41
- title: "Select documents to delete:",
42
- feedback: "Skip feedback",
43
- requiredFeedback: false,
44
- },
45
- options,
46
- );
47
-
48
- if (!chooseResult?.selectedDocs || chooseResult.selectedDocs.length === 0) {
49
- return {
50
- message: "📁 No documents selected for deletion",
51
- cleared: false,
52
- path: displayPath,
53
- };
54
- }
55
-
56
- // Extract file names
57
- const filesToDelete = new Set();
58
- const allLanguages = [locale || "en", ...(translateLanguages || [])];
59
-
60
- for (const selectedDoc of chooseResult.selectedDocs) {
61
- // Convert path to flat filename format using utility function
62
- const flatName = pathToFlatName(selectedDoc.path);
63
-
64
- // Generate file names for all languages
65
- for (const lang of allLanguages) {
66
- const fileName = generateFileName(flatName, lang);
67
- filesToDelete.add(fileName);
68
- }
69
- }
70
-
71
- if (filesToDelete.size === 0) {
72
- return {
73
- message: "📁 No documents were deleted.",
74
- cleared: false,
75
- };
76
- }
77
-
78
- // Delete selected files (including all language versions)
79
- const deletedFiles = [];
80
- const failedFiles = [];
81
- let hasError = false;
82
-
83
- for (const file of filesToDelete) {
84
- try {
85
- const filePath = join(generatedDocsPath, file);
86
- await rm(filePath);
87
- deletedFiles.push(file);
88
- } catch (error) {
89
- // ignore if file not found
90
- if (!["ENOENT"].includes(error.code)) {
91
- hasError = true;
92
- failedFiles.push({ file, error: error.message });
93
- }
94
- }
95
- }
96
-
97
- // Build result message
98
- const deletedCount = deletedFiles.length;
99
- const failedCount = failedFiles.length;
100
-
101
- let message = "";
102
- if (deletedCount > 0) {
103
- const lastIndex = deletedFiles.length - 1;
104
- message = `📁 Deleted ${deletedCount} document(s) in "${displayPath}":\n${deletedFiles
105
- .map((f, i) => ` ${i === lastIndex ? "└─" : "├─"} ${f}`)
106
- .join("\n")}`;
107
- }
108
-
109
- if (failedCount > 0) {
110
- const lastIndex = failedFiles.length - 1;
111
- message = `⚠️ Failed to delete ${failedCount} document(s) in "${displayPath}":\n${failedFiles
112
- .map((f, i) => ` ${i === lastIndex ? "└─" : "├─"} ${f.file}: ${f.error}`)
113
- .join("\n")}`;
114
- }
115
-
116
- return {
117
- message,
118
- cleared: deletedCount > 0,
119
- error: hasError,
120
- };
121
- } catch (error) {
122
- return {
123
- message: `⚠️ Failed to clear generated documents: ${error.message}`,
124
- error: true,
125
- };
126
- }
127
- }
128
-
129
- clearGeneratedDocs.input_schema = {
130
- type: "object",
131
- properties: {
132
- docsDir: {
133
- type: "string",
134
- description: "The generated documents directory to clear",
135
- },
136
- },
137
- required: ["docsDir"],
138
- };
139
-
140
- clearGeneratedDocs.taskTitle = "Clear generated documents";
141
- clearGeneratedDocs.description =
142
- "Select and delete specific generated documents from the docs directory";
@@ -1,129 +0,0 @@
1
- import { existsSync } from "node:fs";
2
- import { readFile, writeFile } from "node:fs/promises";
3
- import path from "node:path";
4
- import chalk from "chalk";
5
- import { parse, stringify } from "yaml";
6
- import { getMediaDescriptionCachePath } from "../../utils/file-utils.mjs";
7
-
8
- export default async function clearMediaDescription(_input = {}, options = {}) {
9
- const cacheFilePath = getMediaDescriptionCachePath();
10
-
11
- // Check if the cache file exists
12
- if (!existsSync(cacheFilePath)) {
13
- return {
14
- message: "🖼️ No media descriptions found to clear",
15
- };
16
- }
17
-
18
- try {
19
- // Read existing cache
20
- const cacheContent = await readFile(cacheFilePath, "utf8");
21
- const parsedCache = parse(cacheContent);
22
- const cache = parsedCache?.descriptions || {};
23
-
24
- // Get all media files from cache
25
- const mediaHashes = Object.keys(cache);
26
-
27
- if (mediaHashes.length === 0) {
28
- return {
29
- message: "🖼️ No media descriptions found to clear",
30
- };
31
- }
32
-
33
- // Build choices from cache - extract filename from path
34
- const choices = mediaHashes.map((hash) => {
35
- const mediaPath = cache[hash]?.path || "unknown";
36
- const filename = path.basename(mediaPath);
37
- const description = cache[hash]?.description || "";
38
- const truncatedDesc =
39
- description.length > 80 ? `${description.slice(0, 80)}...` : description;
40
-
41
- return {
42
- name: filename,
43
- description: truncatedDesc,
44
- value: hash,
45
- checked: false,
46
- };
47
- });
48
-
49
- // Add an option to clear all media descriptions
50
- choices.push({
51
- name: chalk.red("🗑️ Clear ALL media descriptions"),
52
- value: "__ALL__",
53
- checked: false,
54
- });
55
-
56
- let selectedHashes = [];
57
-
58
- if (options?.prompts?.checkbox) {
59
- selectedHashes = await options.prompts.checkbox({
60
- message: "Select media files to clear descriptions:",
61
- choices,
62
- validate: (answer) => (answer.length > 0 ? true : "Please select at least one item."),
63
- });
64
- } else {
65
- // If no prompts available, clear all
66
- selectedHashes = ["__ALL__"];
67
- }
68
-
69
- if (selectedHashes.length === 0) {
70
- return {
71
- message: "🖼️ No media files selected for clearing descriptions",
72
- };
73
- }
74
-
75
- const results = [];
76
- let clearedCount = 0;
77
-
78
- if (selectedHashes.includes("__ALL__")) {
79
- // Clear all media descriptions
80
- await writeFile(
81
- cacheFilePath,
82
- stringify({
83
- descriptions: {},
84
- lastUpdated: new Date().toISOString(),
85
- }),
86
- );
87
- results.push(`✔ Cleared descriptions for all media files (${mediaHashes.length} files)`);
88
- clearedCount = mediaHashes.length;
89
- } else {
90
- // Clear descriptions for selected files
91
- const updatedCache = { ...cache };
92
-
93
- for (const hash of selectedHashes) {
94
- if (updatedCache[hash]) {
95
- const filename = path.basename(updatedCache[hash].path);
96
- delete updatedCache[hash];
97
- results.push(`✔ Cleared description for ${chalk.cyan(filename)}`);
98
- clearedCount++;
99
- }
100
- }
101
-
102
- await writeFile(
103
- cacheFilePath,
104
- stringify({
105
- descriptions: updatedCache,
106
- lastUpdated: new Date().toISOString(),
107
- }),
108
- );
109
- }
110
-
111
- const header = `🖼️ Successfully cleared media descriptions`;
112
- const detailLines = results.map((item) => ` ${item}`).join("\n");
113
-
114
- const message = [header, "", detailLines, ""].filter(Boolean).join("\n");
115
-
116
- return {
117
- message,
118
- clearedCount,
119
- };
120
- } catch (error) {
121
- return {
122
- message: `Error clearing media descriptions: ${error.message}`,
123
- error: true,
124
- };
125
- }
126
- }
127
-
128
- clearMediaDescription.taskTitle = "Clear media file descriptions";
129
- clearMediaDescription.description = "Clear AI-generated descriptions for media files";
@@ -1,21 +0,0 @@
1
- import { saveValueToConfig } from "../../utils/utils.mjs";
2
-
3
- export default async function aggregateDocumentStructure(input, options) {
4
- options.context.userContext.originalDocumentStructure ??= [];
5
- const projectName = input.projectName || options.context.userContext.projectName;
6
- const projectDesc = input.projectDesc || options.context.userContext.projectDesc;
7
-
8
- if (!input.projectDesc && projectDesc) {
9
- await saveValueToConfig("projectDesc", projectDesc, "Project description");
10
- }
11
-
12
- return {
13
- documentStructure: options.context.userContext.originalDocumentStructure.map((i, index) => ({
14
- ...i,
15
- id: i.title.toLowerCase().replace(/\s+/g, "-"),
16
- index,
17
- })),
18
- projectName,
19
- projectDesc,
20
- };
21
- }
@@ -1,159 +0,0 @@
1
- name: analyzeDiagramTypeLLM
2
- description: Analyze document content using LLM to determine diagram type and select appropriate style
3
- model:
4
- reasoning_effort: 1
5
- instructions: |
6
- You are an AI assistant specialized in technical documentation visualization. Your task is to analyze a document segment and generate a structured visual plan for an image generator.
7
-
8
- {% if feedback %}
9
- **CRITICAL: User Feedback (HIGHEST PRIORITY)**
10
- <feedback>
11
- {{ feedback }}
12
- </feedback>
13
-
14
- **IMPORTANT**: User feedback has the **HIGHEST PRIORITY** in all decision-making. Any explicit requests in the feedback (e.g., diagram type, style, colors, aspect ratio, size, layout preferences) must be respected and applied. Additionally, extract and note any other feedback information (such as color preferences, size requirements, layout specifications, etc.) that should be passed to subsequent image generation steps.
15
- {% endif %}
16
-
17
- Your responsibilities:
18
-
19
- 1. **Analyze Context**: Understand the document's content, structure, and its purpose, especially around where the diagram will be inserted.
20
-
21
- 2. **Generate Document Summary**:
22
- **CRITICAL**: The documentSummary will be the **only input** passed to the image generation model. Preserve as much information as possible, only removing content that is truly useless for diagram generation.
23
-
24
- **What to PRESERVE (keep as much as possible):**
25
- - **All structural elements**: Headings, sections, hierarchy, ordering, and document structure
26
- - **All entities and components**: Names, roles, services, modules, actors, objects, and any elements that could appear as nodes
27
- - **All relationships and connections**: How entities relate, data flows, dependencies, interactions, and any connections
28
- - **All process flows and steps**: Sequential steps, decision points, workflows, logical order, and any process information
29
- - **All labels and names**: All names, labels, identifiers, and terminology used in the document
30
- - **Technical details**: Specifications, protocols, interfaces, configurations, and technical information
31
- - **Examples and use cases**: Concrete examples, scenarios, and use cases that illustrate the concepts
32
- - **Contextual information**: Explanatory text, background context, and descriptions that help understand relationships
33
- - **All content that could inform diagram structure**: Any information that might be relevant for creating accurate diagrams
34
-
35
- **What to REMOVE (only truly useless content):**
36
- - **Verbatim duplicates**: Exact duplicate sentences or paragraphs that repeat the same information
37
- - **Completely off-topic content**: Content that has no relation to the diagram subject matter
38
- - **Pure marketing/promotional text**: Sales language that doesn't contain technical or structural information
39
- - **Unrelated notes or comments**: Comments that are completely unrelated to the document's main content
40
-
41
- **Summary Guidelines:**
42
- - **Preserve the vast majority of content** - only remove content that is clearly redundant or completely unrelated
43
- - Keep the original document structure, hierarchy, and organization
44
- - Maintain all technical details, examples, and contextual information
45
- - When in doubt, **keep the content** rather than removing it
46
- - The summary should be comprehensive and contain all information that could be useful for diagram generation
47
-
48
- 3. **Determine Diagram Type**:
49
- Choose one of the following types based on the content:
50
- - **architecture**: Static system structure (components, containers, services)
51
- - **flowchart**: Decision logic, workflows, process steps
52
- - **guide**: Tutorials, step-by-step user journeys
53
- - **intro**: Concept overviews, mind maps
54
- - **sequence**: Time-based interactions between entities
55
- - **network**: Logical or physical network topologies
56
-
57
- **Decision Priority (in order):**
58
- {% if feedback %}
59
- 0. **HIGHEST PRIORITY**: Analyze the user feedback carefully. If the feedback explicitly or implicitly specifies a diagram type (e.g., "architecture diagram", "flowchart", "sequence diagram", "流程图", "架构图") → **MUST use that type and override any other considerations**. Use your understanding of natural language to identify the user's intent. The feedback type takes absolute precedence.
60
- {% endif %}
61
- 1. **Content Analysis**: If no type preference is found in feedback, analyze the document content structure and characteristics:
62
- - If the document is an **overview** (e.g. titled `# Overview`, describes whole system/project) → use `"architecture"`.
63
- - Sequential flow with time-based interactions → `sequence`
64
- - Branching logic, decision points, workflows → `flowchart`
65
- - User steps/tutorials, guided processes → `guide`
66
- - Concept maps, high-level introductions → `intro`
67
- - Infrastructure, network topologies → `network`
68
-
69
- 4. **Select Diagram Style**:
70
- **Decision Priority (in order):**
71
- {% if feedback %}
72
- 0. **HIGHEST PRIORITY**: Analyze the user feedback carefully. If the feedback explicitly or implicitly specifies a diagram style (e.g., "modern style", "hand-drawn", "anthropomorphic", "3d", "flat design", "现代风格", "手绘风格") → **MUST use that style and override any default style**. Use your understanding of natural language to identify the user's style preference. The feedback style takes absolute precedence.
73
- {% endif %}
74
- {% if defaultStyle %}
75
- 1. **Default Style**: If no style preference is found in feedback, use the configured default style: `{{ defaultStyle }}`. This is the user's preferred default style from configuration.
76
- {% endif %}
77
- 2. **Content-Based Selection**: If no feedback style and no default style, choose a style appropriate for technical documentation tone based on the content characteristics. You can use any style name that best fits the content, including but not limited to:
78
- - Common styles: `modern`, `standard`, `hand-drawn`, `anthropomorphic`, `flat`, `minimalist`, `3d`
79
- - Other creative styles: `watercolor`, `sketch`, `vintage`, `cyberpunk`, `minimal`, `realistic`, `cartoon`, `isometric`, `neon`, `pastel`, etc.
80
- - You are not limited to predefined styles - use your knowledge of visual styles to select the most appropriate one
81
- 3. **Available Styles Reference**: If `availableStyles` is provided and not empty, prefer styles from that list. However, if a better style is needed and not in the list, you can still use it. The `styleDescriptions` object provides descriptions of common styles for reference, but you are not restricted to only those styles.
82
-
83
- 5. **Recommend Aspect Ratio**:
84
- {% if feedback %}
85
- **HIGHEST PRIORITY**: If user feedback explicitly specifies an aspect ratio (e.g., "16:9", "4:3", "use landscape", "make it square") → **MUST use that aspect ratio**.
86
- {% endif %}
87
-
88
- Otherwise, select the most suitable aspect ratio based on layout direction:
89
- - `"1:1"`: Radial layouts, mind maps, central concepts
90
- - `"5:4"` or `"4:3"`: Vertical flows (step-by-step, guides)
91
- - `"3:2"`, `"16:9"`, `"21:9"`: Horizontal flows (timelines, architecture)
92
-
93
- **Decision Logic:**
94
- - Vertical flows → use `"4:3"` (default), or `"5:4"` for taller needs
95
- - Horizontal flows → `"16:9"` (default), `"21:9"` for very wide, `"3:2"` for moderate width
96
- - Central hub structures → use `"1:1"`
97
-
98
- **Never** mismatch direction and ratio:
99
- - Don't use portrait for horizontal content or vice versa
100
- - Don't use `"1:1"` unless layout is truly radial
101
-
102
- Document Content:
103
- <document_content>
104
- {{ documentContent }}
105
- </document_content>
106
-
107
-
108
- input_schema:
109
- type: object
110
- properties:
111
- documentContent:
112
- type: string
113
- description: The document content to analyze
114
- availableStyles:
115
- type: array
116
- description: List of available diagram styles
117
- items:
118
- type: string
119
- styleDescriptions:
120
- type: object
121
- description: Style descriptions
122
- additionalProperties:
123
- type: string
124
- locale:
125
- type: string
126
- description: Language for labels
127
- default: en
128
- feedback:
129
- type: string
130
- description: User feedback that may contain style, type, or other preferences. You should analyze this feedback carefully to extract any explicit or implicit preferences. If feedback specifies a style or type, it MUST override the defaultStyle.
131
- default: ""
132
- defaultStyle:
133
- type: string
134
- description: Default diagram style from configuration. Use this only if no style preference is found in feedback. If feedback specifies a style, it takes precedence over this default.
135
- nullable: true
136
- required:
137
- - documentContent
138
- - availableStyles
139
- output_schema:
140
- type: object
141
- properties:
142
- documentSummary:
143
- type: string
144
- description: A comprehensive summary that preserves the vast majority of the original document content. Only remove verbatim duplicates, completely off-topic content, or pure marketing text. Keep all structural elements, entities, relationships, processes, technical details, examples, and contextual information. This summary will be the only content passed to the image generation model.
145
- diagramType:
146
- type: string
147
- description: The selected diagram type
148
- diagramStyle:
149
- type: string
150
- description: The selected diagram style. Can be any style name (e.g., 'modern', 'hand-drawn', 'watercolor', 'cyberpunk', 'isometric', etc.). Not limited to predefined styles - use your knowledge of visual styles to select the most appropriate one.
151
- aspectRatio:
152
- type: string
153
- description: Recommended aspect ratio for the image based on content structure analysis. MUST match the primary flow direction (vertical→portrait, horizontal→landscape, radial→square)
154
- enum: ["1:1", "5:4", "4:3", "3:2", "16:9", "21:9"]
155
- required:
156
- - documentSummary
157
- - diagramType
158
- - diagramStyle
159
- - aspectRatio