@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,81 +0,0 @@
1
- import { stringify } from "yaml";
2
- import { addPreferenceRule, readPreferences } from "../../utils/preferences-utils.mjs";
3
-
4
- export default async function checkFeedbackRefiner(
5
- { feedback, stage, selectedPaths, documentStructureFeedback },
6
- options,
7
- ) {
8
- // If feedback is empty, no need to save user preferences
9
- if (!feedback && !documentStructureFeedback) {
10
- return {};
11
- }
12
-
13
- // Read existing preferences as context for deduplication
14
- const existingPreferences = readPreferences();
15
- const activePreferences = existingPreferences.rules?.filter((rule) => rule.active) || [];
16
-
17
- // Convert active preferences to YAML string format for passing
18
- const activePreferencesYaml =
19
- activePreferences.length > 0 ? stringify({ rules: activePreferences }, { indent: 2 }) : "";
20
-
21
- const feedbackToUse = feedback || documentStructureFeedback;
22
- const result = await options.context.invoke(options.context.agents["feedbackRefiner"], {
23
- feedback: feedbackToUse,
24
- stage,
25
- paths: selectedPaths,
26
- existingPreferences: activePreferencesYaml,
27
- });
28
-
29
- // If preferences need to be saved, save them to the preference file
30
- if (result?.save) {
31
- try {
32
- const savedRule = addPreferenceRule(result, feedbackToUse, selectedPaths);
33
-
34
- // Add saved preference information to the return result
35
- result.savedPreference = {
36
- id: savedRule.id,
37
- saved: true,
38
- };
39
- } catch (error) {
40
- console.error(
41
- "Failed to save user preference rule:",
42
- error.message,
43
- "\nFeedback:",
44
- feedbackToUse,
45
- );
46
- result.savedPreference = {
47
- saved: false,
48
- error: error.message,
49
- };
50
- }
51
- }
52
-
53
- return result;
54
- }
55
-
56
- checkFeedbackRefiner.input_schema = {
57
- type: "object",
58
- properties: {
59
- feedback: {
60
- type: "string",
61
- description: "User feedback to refine",
62
- },
63
- documentStructureFeedback: {
64
- type: "string",
65
- description: "Feedback from documentation structure stage",
66
- },
67
- stage: {
68
- type: "string",
69
- description: "Stage of the feedback",
70
- },
71
- selectedPaths: {
72
- type: "array",
73
- items: {
74
- type: "string",
75
- },
76
- description: "Selected paths of documents",
77
- },
78
- },
79
- };
80
-
81
- checkFeedbackRefiner.taskRenderMode = "collapse";
@@ -1,251 +0,0 @@
1
- import chalk from "chalk";
2
- import {
3
- addFeedbackToItems,
4
- findItemByPath,
5
- getActionText,
6
- getMainLanguageFiles,
7
- processSelectedFiles,
8
- readFileContent,
9
- } from "../../utils/docs-finder-utils.mjs";
10
- import {
11
- hasDiagramContent,
12
- getDiagramTypeLabels,
13
- formatDiagramTypeSuffix,
14
- } from "../../utils/check-document-has-diagram.mjs";
15
- import { debug } from "../../utils/debug.mjs";
16
- import { DOC_ACTION } from "../../utils/constants/index.mjs";
17
-
18
- function getFeedbackMessage(action) {
19
- if (action === DOC_ACTION.translate) {
20
- return "Any specific translation preferences or instructions? (Press Enter to skip):";
21
- }
22
- return "How would you like to improve this document? (Press Enter to skip)";
23
- }
24
-
25
- export default async function chooseDocs(
26
- {
27
- docs,
28
- documentStructure,
29
- boardId,
30
- docsDir,
31
- isTranslate,
32
- feedback,
33
- locale,
34
- reset = false,
35
- requiredFeedback = true,
36
- action,
37
- shouldUpdateDiagrams = false,
38
- shouldAutoSelectDiagrams = false,
39
- },
40
- options,
41
- ) {
42
- let foundItems = [];
43
- let selectedFiles = [];
44
- const docAction = action || (isTranslate ? DOC_ACTION.translate : DOC_ACTION.update);
45
-
46
- // If docs is empty or not provided, let user select multiple documents
47
- if (!docs || docs.length === 0) {
48
- try {
49
- // Get all main language .md files in docsDir
50
- const mainLanguageFiles = await getMainLanguageFiles(docsDir, locale, documentStructure);
51
-
52
- if (mainLanguageFiles.length === 0) {
53
- throw new Error(
54
- `No documents found in the docs directory. You can generate them with ${chalk.yellow(
55
- "`aigne doc create`",
56
- )}`,
57
- );
58
- }
59
-
60
- // If --diagram flag is set, filter documents by diagram content
61
- if (shouldUpdateDiagrams) {
62
- debug("🔄 Filtering documents with diagram content...");
63
-
64
- // Read content for all files and filter by diagram content
65
- const filesWithDiagrams = [];
66
- for (const fileName of mainLanguageFiles) {
67
- const content = await readFileContent(docsDir, fileName);
68
- if (content && hasDiagramContent(content)) {
69
- filesWithDiagrams.push(fileName);
70
- }
71
- }
72
-
73
- if (filesWithDiagrams.length === 0) {
74
- debug(
75
- "ℹ️ No documents found with diagram content (d2 code blocks, placeholders, or diagram images).",
76
- );
77
- return {
78
- selectedDocs: [],
79
- feedback: "",
80
- selectedPaths: [],
81
- };
82
- }
83
-
84
- debug(`✅ Found ${filesWithDiagrams.length} document(s) with diagram content.`);
85
-
86
- // If --diagram-all, auto-select all; otherwise let user choose
87
- if (shouldAutoSelectDiagrams) {
88
- debug("📋 Auto-selecting all documents with diagrams...");
89
- // Show diagram types for each document in auto-select mode
90
- for (const file of filesWithDiagrams) {
91
- const content = await readFileContent(docsDir, file);
92
- const diagramLabels = content ? getDiagramTypeLabels(content) : [];
93
- const diagramSuffix = formatDiagramTypeSuffix(diagramLabels);
94
- debug(` • ${file}${diagramSuffix}`);
95
- }
96
- selectedFiles = filesWithDiagrams;
97
- } else {
98
- // --diagram mode: show only documents with diagrams, let user select
99
- const choices = await Promise.all(
100
- filesWithDiagrams.map(async (file) => {
101
- // Convert filename to flat path to find corresponding documentation structure item
102
- const flatName = file.replace(/\.md$/, "").replace(/\.\w+(-\w+)?$/, "");
103
- const docItem = documentStructure.find((item) => {
104
- const itemFlattenedPath = item.path.replace(/^\//, "").replace(/\//g, "-");
105
- return itemFlattenedPath === flatName;
106
- });
107
-
108
- // Read content to detect diagram types
109
- const content = await readFileContent(docsDir, file);
110
- const diagramLabels = content ? getDiagramTypeLabels(content) : [];
111
- const diagramSuffix = formatDiagramTypeSuffix(diagramLabels);
112
-
113
- // Use title if available, otherwise fall back to filename
114
- let displayName = docItem?.title;
115
- if (displayName) {
116
- displayName = `${displayName} (${file})${diagramSuffix}`;
117
- } else {
118
- displayName = `${file}${diagramSuffix}`;
119
- }
120
-
121
- return {
122
- name: displayName,
123
- value: file,
124
- };
125
- }),
126
- );
127
-
128
- // Let user select multiple files from filtered list
129
- selectedFiles = await options.prompts.checkbox({
130
- message: getActionText("Select documents with diagrams to {action}:", docAction),
131
- source: (term) => {
132
- if (!term) return choices;
133
-
134
- return choices.filter((choice) =>
135
- choice.name.toLowerCase().includes(term.toLowerCase()),
136
- );
137
- },
138
- validate: (answer) => {
139
- if (answer.length === 0) {
140
- return "Please select at least one document";
141
- }
142
- return true;
143
- },
144
- });
145
-
146
- if (!selectedFiles || selectedFiles.length === 0) {
147
- throw new Error("No documents selected");
148
- }
149
- }
150
- } else {
151
- // Normal flow: let user select documents from all files
152
- // Convert files to choices with titles
153
- const choices = mainLanguageFiles.map((file) => {
154
- // Convert filename to flat path to find corresponding documentation structure item
155
- const flatName = file.replace(/\.md$/, "").replace(/\.\w+(-\w+)?$/, "");
156
- const docItem = documentStructure.find((item) => {
157
- const itemFlattenedPath = item.path.replace(/^\//, "").replace(/\//g, "-");
158
- return itemFlattenedPath === flatName;
159
- });
160
-
161
- // Use title if available, otherwise fall back to filename
162
- let displayName = docItem?.title;
163
- if (displayName) {
164
- displayName = `${displayName} (${file})`;
165
- } else {
166
- displayName = file;
167
- }
168
-
169
- return {
170
- name: displayName,
171
- value: file,
172
- };
173
- });
174
-
175
- // Let user select multiple files
176
- selectedFiles = await options.prompts.checkbox({
177
- message: getActionText("Select documents to {action}:", docAction),
178
- source: (term) => {
179
- if (!term) return choices;
180
-
181
- return choices.filter((choice) =>
182
- choice.name.toLowerCase().includes(term.toLowerCase()),
183
- );
184
- },
185
- validate: (answer) => {
186
- if (answer.length === 0) {
187
- return "Please select at least one document";
188
- }
189
- return true;
190
- },
191
- });
192
-
193
- if (!selectedFiles || selectedFiles.length === 0) {
194
- throw new Error("No documents selected");
195
- }
196
- }
197
-
198
- // Process selected files and convert to found items
199
- foundItems = await processSelectedFiles(selectedFiles, documentStructure, docsDir);
200
- } catch (error) {
201
- debug(getActionText(`\nFailed to select documents to {action}: ${error.message}`, docAction));
202
- process.exit(0);
203
- }
204
- } else {
205
- // Process the provided docs array
206
- for (const docPath of docs) {
207
- const foundItem = await findItemByPath(documentStructure, docPath, boardId, docsDir, locale);
208
-
209
- if (!foundItem) {
210
- debug(`⚠️ Item with path "${docPath}" not found in documentStructure`);
211
- continue;
212
- }
213
-
214
- foundItems.push({
215
- ...foundItem,
216
- });
217
- }
218
-
219
- if (foundItems.length === 0) {
220
- throw new Error("None of the specified document paths were found in documentStructure");
221
- }
222
- }
223
-
224
- // Prompt for feedback if not provided
225
- // Skip feedback prompt if --diagram or --diagram-all flag is set
226
- let userFeedback = feedback;
227
- if (!userFeedback && (requiredFeedback || foundItems?.length > 1) && !shouldUpdateDiagrams) {
228
- const feedbackMessage = getFeedbackMessage(docAction);
229
-
230
- userFeedback = await options.prompts.input({
231
- message: feedbackMessage,
232
- });
233
- }
234
-
235
- // Add feedback to all results if provided
236
- foundItems = addFeedbackToItems(foundItems, userFeedback);
237
-
238
- // if reset is true, set content to null for all items
239
- if (reset) {
240
- foundItems = foundItems.map((item) => ({
241
- ...item,
242
- content: null,
243
- }));
244
- }
245
-
246
- return {
247
- selectedDocs: foundItems,
248
- feedback: userFeedback,
249
- selectedPaths: foundItems.map((item) => item.path),
250
- };
251
- }
@@ -1,52 +0,0 @@
1
- name: documentIconGenerate
2
- description: Generate appropriate Iconify icon names for document structure root nodes based on their title and description
3
- model:
4
- reasoning_effort: low
5
- task_render_mode: hide
6
- instructions:
7
- url: ../../prompts/common/document-structure/document-icon-generate.md
8
- input_schema:
9
- type: object
10
- properties:
11
- documentList:
12
- type: array
13
- items:
14
- type: object
15
- properties:
16
- path:
17
- type: string
18
- description: Document path for mapping purposes
19
- title:
20
- type: string
21
- description: Document title to analyze for icon selection
22
- description:
23
- type: string
24
- description: Document description to analyze for icon selection
25
- required:
26
- - path
27
- - title
28
- - description
29
- description: List of root-level document items (parentId is null) that need icons generated
30
- required:
31
- - documentList
32
- output_schema:
33
- type: object
34
- properties:
35
- documentList:
36
- type: array
37
- items:
38
- type: object
39
- properties:
40
- path:
41
- type: string
42
- description: Document path (same as input for mapping)
43
- icon:
44
- type: string
45
- description: Iconify icon name in the format collection:icon-name (e.g., lucide:book)
46
- required:
47
- - path
48
- - icon
49
- description: List of document items with generated Iconify icon names
50
- required:
51
- - documentList
52
-
@@ -1,48 +0,0 @@
1
- name: documentTitleStreamline
2
- description: Streamline document titles by shortening them while preserving meaning for better sidebar navigation
3
- model:
4
- reasoning_effort: low
5
- task_render_mode: hide
6
- instructions:
7
- url: ../../prompts/common/document-structure/document-title-streamline.md
8
- input_schema:
9
- type: object
10
- properties:
11
- documentList:
12
- type: array
13
- items:
14
- type: object
15
- properties:
16
- path:
17
- type: string
18
- description: Document path for mapping purposes
19
- title:
20
- type: string
21
- description: Document title to streamline
22
- required:
23
- - path
24
- - title
25
- description: List of document items with titles to streamline
26
- required:
27
- - documentList
28
- output_schema:
29
- type: object
30
- properties:
31
- documentList:
32
- type: array
33
- items:
34
- type: object
35
- properties:
36
- path:
37
- type: string
38
- description: Document path (same as input for mapping)
39
- title:
40
- type: string
41
- description: Streamlined document title (max 24 characters for English, 12 characters for character-based languages)
42
- required:
43
- - path
44
- - title
45
- description: List of streamlined document items with shortened titles
46
- required:
47
- - documentList
48
-
@@ -1,129 +0,0 @@
1
- import { promises as fs } from "node:fs";
2
- import { join } from "node:path";
3
- import { loadConfigFromFile, processConfigFields } from "../../utils/utils.mjs";
4
-
5
- /**
6
- * Ensure all root-level document entries have icons
7
- * Batch processing: Collects all entries without icons and generates them in a single call
8
- * Conditionally saves the updated structure if icons were generated
9
- * This is a reusable agent that can be used in structure planning and before publishing
10
- */
11
- export default async function ensureDocumentIcons(inputOrParams, options) {
12
- // Handle multiple calling patterns:
13
- // 1. As function skill: (input, options) where input.documentStructure exists
14
- // 2. As function skill: (input, options) where input.originalDocumentStructure exists
15
- // 3. As standalone function: ({ documentStructure }, options)
16
- const documentStructure =
17
- inputOrParams?.documentStructure ||
18
- inputOrParams?.originalDocumentStructure ||
19
- (Array.isArray(inputOrParams) ? inputOrParams : null);
20
-
21
- if (!documentStructure || !Array.isArray(documentStructure)) {
22
- // Return input unchanged if no documentStructure to process
23
- return inputOrParams || {};
24
- }
25
-
26
- // Batch collect all root-level items that need icon generation
27
- // Only process root-level items (parentId is null, undefined, or empty string)
28
- // Only generate icons for items that don't have one
29
- const itemsNeedingIcon = documentStructure.filter((item) => {
30
- // Only process root-level items
31
- const isRootLevel = !item.parentId || item.parentId === "null" || item.parentId === "";
32
- if (!isRootLevel) return false;
33
-
34
- // Must have title and description for icon generation
35
- if (!item.title || !item.description) return false;
36
-
37
- // Only generate if icon is missing
38
- const hasNoIcon = !item.icon || !item.icon.trim();
39
- return hasNoIcon;
40
- });
41
-
42
- // If all items already have icons, skip
43
- if (itemsNeedingIcon.length === 0) {
44
- return inputOrParams || {};
45
- }
46
-
47
- // Prepare batch list for icon generation
48
- const documentList = itemsNeedingIcon.map((item) => ({
49
- path: item.path,
50
- title: item.title,
51
- description: item.description,
52
- }));
53
-
54
- const iconAgent = options?.context?.agents?.["documentIconGenerate"];
55
- if (!iconAgent) {
56
- console.warn("⚠️ documentIconGenerate agent not found. Skipping icon generation.");
57
- return inputOrParams || {};
58
- }
59
-
60
- let iconsGenerated = false;
61
-
62
- try {
63
- // Batch generate all missing icons in a single call
64
- const iconResult = await options.context.invoke(iconAgent, {
65
- documentList,
66
- });
67
-
68
- // Batch update all document items with generated icons using path as the key
69
- if (iconResult.documentList && Array.isArray(iconResult.documentList)) {
70
- const iconMap = new Map(iconResult.documentList.map((item) => [item.path, item.icon]));
71
-
72
- for (const item of documentStructure) {
73
- const generatedIcon = iconMap.get(item.path);
74
- if (generatedIcon) {
75
- item.icon = generatedIcon;
76
- iconsGenerated = true;
77
- }
78
- }
79
- }
80
-
81
- // Conditionally save the updated structure if icons were generated
82
- // Use the same save pattern as save-output.mjs for consistency
83
- if (iconsGenerated) {
84
- // Try to get outputDir from multiple sources (same as create flow)
85
- let outputDir =
86
- inputOrParams?.outputDir ||
87
- options?.context?.userContext?.outputDir ||
88
- options?.context?.config?.outputDir;
89
-
90
- // If still not found, load from config file and process defaults
91
- if (!outputDir) {
92
- try {
93
- const config = await loadConfigFromFile();
94
- const processedConfig = await processConfigFields(config || {});
95
- outputDir = processedConfig?.outputDir;
96
- } catch {
97
- // Ignore config load errors
98
- }
99
- }
100
-
101
- if (outputDir) {
102
- try {
103
- // Use the same save pattern as save-output.mjs
104
- const savePath = outputDir;
105
- const fileName = "structure-plan.json";
106
- const content = JSON.stringify(documentStructure, null, 2);
107
-
108
- await fs.mkdir(savePath, { recursive: true });
109
- const filePath = join(savePath, fileName);
110
- await fs.writeFile(filePath, content, "utf8");
111
- } catch (saveError) {
112
- console.warn("⚠️ Failed to save updated structure:", saveError.message);
113
- // Continue even if save fails
114
- }
115
- }
116
- }
117
- } catch (error) {
118
- console.warn("⚠️ Failed to generate document icons:", error.message);
119
- console.warn("Continuing without icons.");
120
- }
121
-
122
- // Return input unchanged (documentStructure is modified in place)
123
- return inputOrParams || {};
124
- }
125
-
126
- ensureDocumentIcons.taskTitle = "Ensure document icons";
127
- ensureDocumentIcons.description =
128
- "Check each root-level document entry for icons - if missing, generate one; if present, skip";
129
- ensureDocumentIcons.task_render_mode = "hide";
@@ -1,6 +0,0 @@
1
- export default async function exit() {
2
- process.exit(0);
3
- }
4
-
5
- exit.description =
6
- "Exit the chat session. Equivalent to saying goodbye, quit, exit, close, or see you. Must print a bye message before calling this tool, as it will exit the process immediately.";
@@ -1,50 +0,0 @@
1
- name: feedbackRefiner
2
- description: Learn from your feedback to improve future documentation
3
- instructions:
4
- url: ../../prompts/utils/feedback-refiner.md
5
-
6
- input_schema:
7
- type: object
8
- properties:
9
- feedback:
10
- type: string
11
- description: Tell us what you think about the documentation
12
- stage:
13
- type: string
14
- description: Which part of the process this feedback is about (document_structure, document_refine, translation_refine)
15
- paths:
16
- type: array
17
- items:
18
- type: string
19
- description: Specific documents this feedback applies to (optional)
20
- existingPreferences:
21
- type: string
22
- description: Your existing preferences to avoid duplicates (optional)
23
- required:
24
- - feedback
25
- - stage
26
-
27
- output_schema:
28
- type: object
29
- properties:
30
- rule:
31
- type: string
32
- description: General rule created from your feedback
33
- scope:
34
- type: string
35
- description: Where this rule applies (global, structure, document, translation)
36
- save:
37
- type: boolean
38
- description: Should we remember this preference for next time?
39
- limitToInputPaths:
40
- type: boolean
41
- description: Apply only to the specific documents mentioned?
42
- reason:
43
- type: string
44
- description: Why we made this decision and how the rule was created
45
- required:
46
- - rule
47
- - scope
48
- - save
49
- - limitToInputPaths
50
- - reason