@aigne/doc-smith 0.9.8-alpha.2 → 0.9.8-alpha.4

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 (256) hide show
  1. package/CLAUDE.md +43 -0
  2. package/README.md +94 -250
  3. package/aigne.yaml +2 -149
  4. package/doc-smith/SKILL.md +117 -0
  5. package/doc-smith/references/changeset_schema.md +118 -0
  6. package/doc-smith/references/document_structure_schema.md +139 -0
  7. package/doc-smith/references/document_update_guide.md +193 -0
  8. package/doc-smith/references/structure_confirmation_guide.md +133 -0
  9. package/doc-smith/references/structure_planning_guide.md +146 -0
  10. package/doc-smith/references/user_intent_guide.md +172 -0
  11. package/doc-smith.yaml +114 -0
  12. package/main-system-prompt.md +56 -0
  13. package/package.json +3 -69
  14. package/scripts/README.md +90 -0
  15. package/scripts/install.sh +86 -0
  16. package/scripts/uninstall.sh +52 -0
  17. package/CHANGELOG.md +0 -994
  18. package/LICENSE +0 -93
  19. package/agentic-agents/common/base-info.md +0 -53
  20. package/agentic-agents/common/planner.md +0 -168
  21. package/agentic-agents/common/worker.md +0 -93
  22. package/agentic-agents/create/index.yaml +0 -118
  23. package/agentic-agents/create/objective.md +0 -44
  24. package/agentic-agents/create/set-custom-prompt.mjs +0 -27
  25. package/agentic-agents/detail/index.yaml +0 -95
  26. package/agentic-agents/detail/objective.md +0 -9
  27. package/agentic-agents/detail/set-custom-prompt.mjs +0 -88
  28. package/agentic-agents/predict-resources/index.yaml +0 -44
  29. package/agentic-agents/predict-resources/instructions.md +0 -61
  30. package/agentic-agents/structure/design-rules.md +0 -39
  31. package/agentic-agents/structure/index.yaml +0 -86
  32. package/agentic-agents/structure/objective.md +0 -14
  33. package/agentic-agents/structure/review-criteria.md +0 -55
  34. package/agentic-agents/structure/set-custom-prompt.mjs +0 -78
  35. package/agentic-agents/utils/init-workspace-cache.mjs +0 -171
  36. package/agentic-agents/utils/load-base-sources.mjs +0 -20
  37. package/agentic-agents/workspace-cache-sharing-design.md +0 -671
  38. package/agents/chat/chat-system.md +0 -38
  39. package/agents/chat/index.mjs +0 -59
  40. package/agents/chat/skills/generate-document.yaml +0 -15
  41. package/agents/chat/skills/list-documents.mjs +0 -15
  42. package/agents/chat/skills/update-document.yaml +0 -24
  43. package/agents/clear/choose-contents.mjs +0 -192
  44. package/agents/clear/clear-auth-tokens.mjs +0 -88
  45. package/agents/clear/clear-deployment-config.mjs +0 -49
  46. package/agents/clear/clear-document-config.mjs +0 -36
  47. package/agents/clear/clear-document-structure.mjs +0 -102
  48. package/agents/clear/clear-generated-docs.mjs +0 -142
  49. package/agents/clear/clear-media-description.mjs +0 -129
  50. package/agents/clear/index.yaml +0 -26
  51. package/agents/create/analyze-diagram-type-llm.yaml +0 -160
  52. package/agents/create/analyze-diagram-type.mjs +0 -297
  53. package/agents/create/check-document-structure.yaml +0 -30
  54. package/agents/create/check-need-generate-structure.mjs +0 -105
  55. package/agents/create/document-structure-tools/add-document.mjs +0 -85
  56. package/agents/create/document-structure-tools/delete-document.mjs +0 -116
  57. package/agents/create/document-structure-tools/move-document.mjs +0 -109
  58. package/agents/create/document-structure-tools/update-document.mjs +0 -84
  59. package/agents/create/generate-diagram-image.yaml +0 -60
  60. package/agents/create/generate-structure.yaml +0 -117
  61. package/agents/create/index.yaml +0 -49
  62. package/agents/create/refine-document-structure.yaml +0 -12
  63. package/agents/create/replace-d2-with-image.mjs +0 -625
  64. package/agents/create/update-document-structure.yaml +0 -54
  65. package/agents/create/user-add-document/add-documents-to-structure.mjs +0 -90
  66. package/agents/create/user-add-document/find-documents-to-add-links.yaml +0 -47
  67. package/agents/create/user-add-document/index.yaml +0 -46
  68. package/agents/create/user-add-document/prepare-documents-to-translate.mjs +0 -22
  69. package/agents/create/user-add-document/print-add-document-summary.mjs +0 -63
  70. package/agents/create/user-add-document/review-documents-with-new-links.mjs +0 -110
  71. package/agents/create/user-remove-document/find-documents-with-invalid-links.mjs +0 -78
  72. package/agents/create/user-remove-document/index.yaml +0 -40
  73. package/agents/create/user-remove-document/prepare-documents-to-translate.mjs +0 -22
  74. package/agents/create/user-remove-document/print-remove-document-summary.mjs +0 -53
  75. package/agents/create/user-remove-document/remove-documents-from-structure.mjs +0 -99
  76. package/agents/create/user-remove-document/review-documents-with-invalid-links.mjs +0 -115
  77. package/agents/create/user-review-document-structure.mjs +0 -140
  78. package/agents/create/utils/init-current-content.mjs +0 -34
  79. package/agents/create/utils/merge-document-structures.mjs +0 -30
  80. package/agents/evaluate/code-snippet.mjs +0 -97
  81. package/agents/evaluate/document-structure.yaml +0 -67
  82. package/agents/evaluate/document.yaml +0 -82
  83. package/agents/evaluate/generate-report.mjs +0 -85
  84. package/agents/evaluate/index.yaml +0 -46
  85. package/agents/history/index.yaml +0 -6
  86. package/agents/history/view.mjs +0 -78
  87. package/agents/init/check.mjs +0 -16
  88. package/agents/init/index.mjs +0 -275
  89. package/agents/init/validate.mjs +0 -16
  90. package/agents/localize/choose-language.mjs +0 -107
  91. package/agents/localize/index.yaml +0 -58
  92. package/agents/localize/record-translation-history.mjs +0 -23
  93. package/agents/localize/translate-document.yaml +0 -24
  94. package/agents/localize/translate-multilingual.yaml +0 -51
  95. package/agents/media/batch-generate-media-description.yaml +0 -46
  96. package/agents/media/generate-media-description.yaml +0 -50
  97. package/agents/media/load-media-description.mjs +0 -256
  98. package/agents/prefs/index.mjs +0 -203
  99. package/agents/publish/index.yaml +0 -26
  100. package/agents/publish/publish-docs.mjs +0 -356
  101. package/agents/publish/translate-meta.mjs +0 -103
  102. package/agents/schema/document-structure-item.yaml +0 -26
  103. package/agents/schema/document-structure-refine-item.yaml +0 -23
  104. package/agents/schema/document-structure.yaml +0 -29
  105. package/agents/update/batch-generate-document.yaml +0 -27
  106. package/agents/update/batch-update-document.yaml +0 -7
  107. package/agents/update/check-diagram-flag.mjs +0 -116
  108. package/agents/update/check-document.mjs +0 -162
  109. package/agents/update/check-generate-diagram.mjs +0 -106
  110. package/agents/update/check-sync-image-flag.mjs +0 -55
  111. package/agents/update/check-update-is-single.mjs +0 -53
  112. package/agents/update/document-tools/update-document-content.mjs +0 -303
  113. package/agents/update/generate-diagram.yaml +0 -63
  114. package/agents/update/generate-document.yaml +0 -70
  115. package/agents/update/handle-document-update.yaml +0 -103
  116. package/agents/update/index.yaml +0 -79
  117. package/agents/update/pre-check-generate-diagram.yaml +0 -44
  118. package/agents/update/save-and-translate-document.mjs +0 -76
  119. package/agents/update/sync-images-and-exit.mjs +0 -148
  120. package/agents/update/update-document-detail.yaml +0 -71
  121. package/agents/update/update-single/update-single-document-detail.mjs +0 -280
  122. package/agents/update/update-single-document.yaml +0 -7
  123. package/agents/update/user-review-document.mjs +0 -272
  124. package/agents/utils/action-success.mjs +0 -16
  125. package/agents/utils/analyze-document-feedback-intent.yaml +0 -32
  126. package/agents/utils/analyze-feedback-intent.mjs +0 -136
  127. package/agents/utils/analyze-structure-feedback-intent.yaml +0 -29
  128. package/agents/utils/check-detail-result.mjs +0 -38
  129. package/agents/utils/check-feedback-refiner.mjs +0 -81
  130. package/agents/utils/choose-docs.mjs +0 -293
  131. package/agents/utils/document-icon-generate.yaml +0 -52
  132. package/agents/utils/document-title-streamline.yaml +0 -48
  133. package/agents/utils/ensure-document-icons.mjs +0 -129
  134. package/agents/utils/exit.mjs +0 -6
  135. package/agents/utils/feedback-refiner.yaml +0 -50
  136. package/agents/utils/find-item-by-path.mjs +0 -114
  137. package/agents/utils/find-user-preferences-by-path.mjs +0 -37
  138. package/agents/utils/format-document-structure.mjs +0 -35
  139. package/agents/utils/generate-document-or-skip.mjs +0 -41
  140. package/agents/utils/handle-diagram-operations.mjs +0 -263
  141. package/agents/utils/load-all-document-content.mjs +0 -30
  142. package/agents/utils/load-document-all-content.mjs +0 -84
  143. package/agents/utils/load-sources.mjs +0 -405
  144. package/agents/utils/map-reasoning-effort-level.mjs +0 -15
  145. package/agents/utils/post-generate.mjs +0 -144
  146. package/agents/utils/read-current-document-content.mjs +0 -46
  147. package/agents/utils/save-doc-translation.mjs +0 -61
  148. package/agents/utils/save-doc.mjs +0 -88
  149. package/agents/utils/save-output.mjs +0 -26
  150. package/agents/utils/save-sidebar.mjs +0 -51
  151. package/agents/utils/skip-if-content-exists.mjs +0 -27
  152. package/agents/utils/streamline-document-titles-if-needed.mjs +0 -88
  153. package/agents/utils/transform-detail-data-sources.mjs +0 -45
  154. package/agents/utils/update-branding.mjs +0 -84
  155. package/assets/report-template/report.html +0 -198
  156. package/docs-mcp/analyze-content-relevance.yaml +0 -50
  157. package/docs-mcp/analyze-docs-relevance.yaml +0 -59
  158. package/docs-mcp/docs-search.yaml +0 -42
  159. package/docs-mcp/get-docs-detail.mjs +0 -41
  160. package/docs-mcp/get-docs-structure.mjs +0 -16
  161. package/docs-mcp/read-doc-content.mjs +0 -119
  162. package/prompts/common/document/content-rules-core.md +0 -20
  163. package/prompts/common/document/markdown-syntax-rules.md +0 -65
  164. package/prompts/common/document/media-file-list-usage-rules.md +0 -18
  165. package/prompts/common/document/openapi-usage-rules.md +0 -189
  166. package/prompts/common/document/role-and-personality.md +0 -16
  167. package/prompts/common/document/user-preferences.md +0 -9
  168. package/prompts/common/document-structure/conflict-resolution-guidance.md +0 -16
  169. package/prompts/common/document-structure/document-icon-generate.md +0 -116
  170. package/prompts/common/document-structure/document-structure-rules.md +0 -43
  171. package/prompts/common/document-structure/document-title-streamline.md +0 -86
  172. package/prompts/common/document-structure/glossary.md +0 -7
  173. package/prompts/common/document-structure/intj-traits.md +0 -5
  174. package/prompts/common/document-structure/openapi-usage-rules.md +0 -28
  175. package/prompts/common/document-structure/output-constraints.md +0 -18
  176. package/prompts/common/document-structure/user-locale-rules.md +0 -10
  177. package/prompts/common/document-structure/user-preferences.md +0 -9
  178. package/prompts/detail/custom/admonition-usage-rules.md +0 -94
  179. package/prompts/detail/custom/code-block-usage-rules.md +0 -163
  180. package/prompts/detail/custom/custom-components/x-card-usage-rules.md +0 -63
  181. package/prompts/detail/custom/custom-components/x-cards-usage-rules.md +0 -83
  182. package/prompts/detail/custom/custom-components/x-field-desc-usage-rules.md +0 -120
  183. package/prompts/detail/custom/custom-components/x-field-group-usage-rules.md +0 -80
  184. package/prompts/detail/custom/custom-components/x-field-usage-rules.md +0 -189
  185. package/prompts/detail/custom/custom-components-usage-rules.md +0 -18
  186. package/prompts/detail/diagram/generate-image-system.md +0 -135
  187. package/prompts/detail/diagram/generate-image-user.md +0 -32
  188. package/prompts/detail/diagram/guide.md +0 -29
  189. package/prompts/detail/diagram/official-examples.md +0 -712
  190. package/prompts/detail/diagram/pre-check.md +0 -23
  191. package/prompts/detail/diagram/role-and-personality.md +0 -2
  192. package/prompts/detail/diagram/rules.md +0 -46
  193. package/prompts/detail/diagram/system-prompt.md +0 -1139
  194. package/prompts/detail/diagram/user-prompt.md +0 -43
  195. package/prompts/detail/generate/detail-example.md +0 -457
  196. package/prompts/detail/generate/document-rules.md +0 -45
  197. package/prompts/detail/generate/system-prompt.md +0 -61
  198. package/prompts/detail/generate/user-prompt.md +0 -99
  199. package/prompts/detail/jsx/rules.md +0 -6
  200. package/prompts/detail/update/system-prompt.md +0 -121
  201. package/prompts/detail/update/user-prompt.md +0 -41
  202. package/prompts/evaluate/document-structure.md +0 -93
  203. package/prompts/evaluate/document.md +0 -149
  204. package/prompts/media/media-description/system-prompt.md +0 -43
  205. package/prompts/media/media-description/user-prompt.md +0 -17
  206. package/prompts/structure/check-document-structure.md +0 -93
  207. package/prompts/structure/document-rules.md +0 -21
  208. package/prompts/structure/find-documents-to-add-links.md +0 -52
  209. package/prompts/structure/generate/system-prompt.md +0 -13
  210. package/prompts/structure/generate/user-prompt.md +0 -137
  211. package/prompts/structure/review/structure-review-system.md +0 -81
  212. package/prompts/structure/structure-example.md +0 -89
  213. package/prompts/structure/structure-getting-started.md +0 -10
  214. package/prompts/structure/update/system-prompt.md +0 -93
  215. package/prompts/structure/update/user-prompt.md +0 -43
  216. package/prompts/translate/admonition.md +0 -20
  217. package/prompts/translate/code-block.md +0 -33
  218. package/prompts/translate/glossary.md +0 -6
  219. package/prompts/translate/translate-document.md +0 -305
  220. package/prompts/utils/analyze-document-feedback-intent.md +0 -54
  221. package/prompts/utils/analyze-structure-feedback-intent.md +0 -43
  222. package/prompts/utils/feedback-refiner.md +0 -105
  223. package/types/document-schema.mjs +0 -55
  224. package/types/document-structure-schema.mjs +0 -261
  225. package/utils/auth-utils.mjs +0 -275
  226. package/utils/blocklet.mjs +0 -104
  227. package/utils/check-document-has-diagram.mjs +0 -95
  228. package/utils/conflict-detector.mjs +0 -149
  229. package/utils/constants/index.mjs +0 -620
  230. package/utils/constants/linter.mjs +0 -102
  231. package/utils/d2-utils.mjs +0 -198
  232. package/utils/debug.mjs +0 -3
  233. package/utils/delete-diagram-images.mjs +0 -99
  234. package/utils/deploy.mjs +0 -86
  235. package/utils/docs-finder-utils.mjs +0 -623
  236. package/utils/evaluate/report-utils.mjs +0 -132
  237. package/utils/extract-api.mjs +0 -32
  238. package/utils/file-utils.mjs +0 -960
  239. package/utils/history-utils.mjs +0 -203
  240. package/utils/icon-map.mjs +0 -26
  241. package/utils/image-compress.mjs +0 -75
  242. package/utils/kroki-utils.mjs +0 -173
  243. package/utils/linter/index.mjs +0 -50
  244. package/utils/load-config.mjs +0 -107
  245. package/utils/markdown/index.mjs +0 -26
  246. package/utils/markdown-checker.mjs +0 -694
  247. package/utils/mermaid-validator.mjs +0 -140
  248. package/utils/mermaid-worker-pool.mjs +0 -250
  249. package/utils/mermaid-worker.mjs +0 -233
  250. package/utils/openapi/index.mjs +0 -28
  251. package/utils/preferences-utils.mjs +0 -175
  252. package/utils/request.mjs +0 -10
  253. package/utils/store/index.mjs +0 -45
  254. package/utils/sync-diagram-to-translations.mjs +0 -262
  255. package/utils/upload-files.mjs +0 -231
  256. package/utils/utils.mjs +0 -1354
@@ -1,136 +0,0 @@
1
- import { AIAgent } from "@aigne/core";
2
- import z from "zod";
3
-
4
- /**
5
- * Analyze user feedback to determine the intent type for document updates
6
- * Returns one of: "addDiagram", "deleteDiagram", "updateDiagram", "updateDocument"
7
- * Returns null if feedback is empty or invalid
8
- */
9
- export default async function analyzeFeedbackIntent({ feedback, shouldUpdateDiagrams }, options) {
10
- // Check if feedback exists and is not empty
11
- // If feedback is empty and --diagram flag is set, default to updateDiagram
12
- // Otherwise return null
13
- if (!feedback || typeof feedback !== "string" || !feedback.trim()) {
14
- // If --diagram flag is set, default to updateDiagram (user wants to update diagrams)
15
- if (shouldUpdateDiagrams) {
16
- return { intentType: "updateDiagram" };
17
- }
18
- return { intentType: null };
19
- }
20
-
21
- // Always analyze user feedback first, even if --diagram flag is set
22
- // This ensures user's explicit intent (e.g., "remove image", "delete diagram") is respected
23
- // The --diagram flag should only be a hint, not override explicit user commands
24
-
25
- const instructions = `<role>
26
- You are a feedback intent analyzer. Your task is to determine which type of content modifications are needed based on the user's feedback.
27
-
28
- You must analyze the user's feedback and classify it into one of the following intent types:
29
- - addDiagram: User wants to add a new diagram/image/chart
30
- - deleteDiagram: User wants to remove/delete a diagram/image/chart
31
- - updateDiagram: User wants to modify/update an existing diagram/image/chart
32
- - updateDocument: User wants to update document content (text, sections, etc.) without diagram operations
33
- </role>
34
-
35
- <intent_classification_rules>
36
- **deleteDiagram** - Use this when user explicitly wants to remove or delete a diagram/image/chart:
37
- - Keywords: remove, delete, 删除, 移除, 去掉, 清除
38
- - Combined with: diagram, image, picture, chart, graph, 图表, 图片, 图, 架构图
39
- - Examples:
40
- - "Remove the diagram"
41
- - "Delete the image"
42
- - "删除这张图片"
43
- - "Remove the second diagram"
44
- - "去掉架构图"
45
- - "Remove image from page 3"
46
- - "Delete the chart showing the flow"
47
-
48
- **addDiagram** - Use this when user wants to add a new diagram:
49
- - Keywords: add, create, insert, 添加, 创建, 插入
50
- - Combined with: diagram, image, picture, chart, graph, 图表, 图片, 图
51
- - Examples:
52
- - "Add a diagram showing the architecture"
53
- - "Create a flow chart"
54
- - "添加一个架构图"
55
-
56
- **updateDiagram** - Use this when user wants to modify an existing diagram:
57
- - Keywords: update, modify, change, improve, 更新, 修改, 改进
58
- - Combined with: diagram, image, picture, chart, graph, 图表, 图片, 图
59
- - Examples:
60
- - "Update the diagram to show the new process"
61
- - "Modify the chart to include more details"
62
- - "更新架构图"
63
-
64
- **updateDocument** - Use this for all other content modifications:
65
- - Text changes, section updates, content improvements
66
- - No mention of diagrams/images/charts
67
- - Examples:
68
- - "Update the introduction section"
69
- - "Fix the typo in paragraph 2"
70
- - "Improve the explanation"
71
- </intent_classification_rules>
72
-
73
- <user_feedback>
74
- {{feedback}}
75
- </user_feedback>
76
-
77
- <analysis_guidelines>
78
- 1. Pay close attention to action verbs (remove, delete, add, update, etc.)
79
- 2. Identify the target object (diagram, image, chart, or general content)
80
- 3. If feedback mentions removing/deleting a diagram/image/chart → deleteDiagram
81
- 4. If feedback mentions adding a diagram/image/chart → addDiagram
82
- 5. If feedback mentions updating a diagram/image/chart → updateDiagram
83
- 6. If feedback is about general content without diagram references → updateDocument
84
- 7. When in doubt, prioritize the most explicit action mentioned in the feedback
85
- </analysis_guidelines>`;
86
-
87
- try {
88
- const analyzeUpdateFeedbackIntentAgent = AIAgent.from({
89
- name: "analyzeUpdateFeedbackIntent",
90
- description:
91
- "Analyze user feedback to determine if document are needed for content modifications",
92
- task_render_mode: "hide",
93
- instructions,
94
- inputSchema: z.object({
95
- feedback: z.string().describe("User feedback for content modifications"),
96
- }),
97
- outputSchema: z.object({
98
- intentType: z
99
- .enum(["addDiagram", "deleteDiagram", "updateDiagram", "updateDocument"])
100
- .describe(
101
- "The primary type of user intention: one of addDiagram, deleteDiagram, updateDiagram, updateDocument",
102
- ),
103
- }),
104
- });
105
-
106
- const { intentType } = await options.context.invoke(analyzeUpdateFeedbackIntentAgent, {
107
- feedback: feedback.trim(),
108
- });
109
-
110
- // If --diagram flag is set and user didn't explicitly request delete/add,
111
- // default to updateDiagram (for backward compatibility)
112
- // But if user explicitly requested delete/add, respect that intent
113
- if (
114
- shouldUpdateDiagrams &&
115
- intentType &&
116
- !["deleteDiagram", "addDiagram"].includes(intentType)
117
- ) {
118
- return { intentType: "updateDiagram" };
119
- }
120
-
121
- return { intentType };
122
- } catch (error) {
123
- // If analysis fails and --diagram flag is set, default to updateDiagram
124
- // Otherwise return null to fall back to default document update flow
125
- if (shouldUpdateDiagrams) {
126
- console.warn(
127
- `Failed to analyze feedback intent, defaulting to updateDiagram due to --diagram flag: ${error.message}`,
128
- );
129
- return { intentType: "updateDiagram" };
130
- }
131
- console.warn(`Failed to analyze feedback intent: ${error.message}`);
132
- return { intentType: null };
133
- }
134
- }
135
-
136
- analyzeFeedbackIntent.task_render_mode = "hide";
@@ -1,29 +0,0 @@
1
- name: analyzeStructureFeedbackIntent
2
- description: Analyze user feedback to determine if data sources are needed for structure modifications
3
- task_render_mode: hide
4
- instructions:
5
- url: ../../prompts/utils/analyze-structure-feedback-intent.md
6
- input_schema:
7
- type: object
8
- properties:
9
- feedback:
10
- type: string
11
- description: User feedback for structure modifications
12
- required:
13
- - feedback
14
- output_schema:
15
- type: object
16
- properties:
17
- needDataSources:
18
- type: boolean
19
- description: Whether data sources are needed - true for add/edit operations that need context, false for delete/move/reorder operations
20
- intentType:
21
- type: string
22
- description: The primary type of user intention
23
- reason:
24
- type: string
25
- description: Explanation of why data sources are or aren't needed
26
- required:
27
- - needDataSources
28
- - intentType
29
- - reason
@@ -1,38 +0,0 @@
1
- import { buildAllowedLinksFromStructure } from "../../utils/docs-finder-utils.mjs";
2
- import { checkMarkdown } from "../../utils/markdown-checker.mjs";
3
-
4
- export default async function checkDetailResult({ documentStructure, reviewContent, docsDir }) {
5
- if (!reviewContent || reviewContent.trim() === "") {
6
- return {
7
- isApproved: false,
8
- detailFeedback: "Review content is empty",
9
- };
10
- }
11
-
12
- let isApproved = true;
13
- const detailFeedback = [];
14
-
15
- // Create a set of allowed links, including both original paths and processed .md paths
16
- const allowedLinks = buildAllowedLinksFromStructure(documentStructure);
17
-
18
- // Run comprehensive markdown validation with all checks
19
- try {
20
- const markdownErrors = await checkMarkdown(reviewContent, "result", {
21
- allowedLinks,
22
- baseDir: docsDir,
23
- });
24
-
25
- if (markdownErrors.length > 0) {
26
- isApproved = false;
27
- detailFeedback.push(...markdownErrors);
28
- }
29
- } catch (error) {
30
- isApproved = false;
31
- detailFeedback.push(`Found markdown validation error in result: ${error.message}`);
32
- }
33
-
34
- return {
35
- isApproved,
36
- detailFeedback: detailFeedback.join("\n"),
37
- };
38
- }
@@ -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,293 +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
- hasBananaImages,
13
- getDiagramTypeLabels,
14
- formatDiagramTypeSuffix,
15
- } from "../../utils/check-document-has-diagram.mjs";
16
- import { debug } from "../../utils/debug.mjs";
17
- import { DOC_ACTION } from "../../utils/constants/index.mjs";
18
-
19
- function getFeedbackMessage(action) {
20
- if (action === DOC_ACTION.translate) {
21
- return "Any specific translation preferences or instructions? (Press Enter to skip):";
22
- }
23
- return "How would you like to improve this document? (Press Enter to skip)";
24
- }
25
-
26
- export default async function chooseDocs(
27
- {
28
- docs,
29
- documentStructure,
30
- boardId,
31
- docsDir,
32
- isTranslate,
33
- feedback,
34
- locale,
35
- reset = false,
36
- requiredFeedback = true,
37
- action,
38
- shouldUpdateDiagrams = false,
39
- shouldAutoSelectDiagrams = false,
40
- shouldSyncImages = false,
41
- ...rest
42
- },
43
- options,
44
- ) {
45
- let foundItems = [];
46
- let selectedFiles = [];
47
- const docAction = action || (isTranslate ? DOC_ACTION.translate : DOC_ACTION.update);
48
-
49
- // If docs is empty or not provided, let user select multiple documents
50
- if (!docs || docs.length === 0) {
51
- try {
52
- // Get all main language .md files in docsDir
53
- const mainLanguageFiles = await getMainLanguageFiles(docsDir, locale, documentStructure);
54
-
55
- if (mainLanguageFiles.length === 0) {
56
- throw new Error(
57
- `No documents found in the docs directory. You can generate them with ${chalk.yellow(
58
- "`aigne doc create`",
59
- )}`,
60
- );
61
- }
62
-
63
- // If --diagram-sync flag is set, filter documents by banana images only
64
- if (shouldSyncImages) {
65
- debug("🔄 Filtering documents with banana images...");
66
-
67
- // Read content for all files and filter by banana images only
68
- const filesWithImages = [];
69
- for (const fileName of mainLanguageFiles) {
70
- const content = await readFileContent(docsDir, fileName);
71
- if (content && hasBananaImages(content)) {
72
- filesWithImages.push(fileName);
73
- }
74
- }
75
-
76
- if (filesWithImages.length === 0) {
77
- debug("ℹ️ No documents found with banana images (DIAGRAM_IMAGE_START markers).");
78
- return {
79
- selectedDocs: [],
80
- feedback: "",
81
- selectedPaths: [],
82
- };
83
- }
84
-
85
- debug(`✅ Found ${filesWithImages.length} document(s) with banana images.`);
86
- debug("📋 Auto-selecting all documents with banana images...");
87
- // Show diagram types for each document
88
- for (const file of filesWithImages) {
89
- const content = await readFileContent(docsDir, file);
90
- const diagramLabels = content ? getDiagramTypeLabels(content) : [];
91
- const diagramSuffix = formatDiagramTypeSuffix(diagramLabels);
92
- debug(` • ${file}${diagramSuffix}`);
93
- }
94
- selectedFiles = filesWithImages;
95
- }
96
- // If --diagram flag is set, filter documents by diagram content
97
- else if (shouldUpdateDiagrams) {
98
- debug("🔄 Filtering documents with diagram content...");
99
-
100
- // Read content for all files and filter by diagram content
101
- const filesWithDiagrams = [];
102
- for (const fileName of mainLanguageFiles) {
103
- const content = await readFileContent(docsDir, fileName);
104
- if (content && hasDiagramContent(content)) {
105
- filesWithDiagrams.push(fileName);
106
- }
107
- }
108
-
109
- if (filesWithDiagrams.length === 0) {
110
- debug(
111
- "ℹ️ No documents found with diagram content (d2 code blocks, placeholders, or diagram images).",
112
- );
113
- return {
114
- selectedDocs: [],
115
- feedback: "",
116
- selectedPaths: [],
117
- };
118
- }
119
-
120
- debug(`✅ Found ${filesWithDiagrams.length} document(s) with diagram content.`);
121
-
122
- // If --diagram-all, auto-select all; otherwise let user choose
123
- if (shouldAutoSelectDiagrams) {
124
- debug("📋 Auto-selecting all documents with diagrams...");
125
- // Show diagram types for each document in auto-select mode
126
- for (const file of filesWithDiagrams) {
127
- const content = await readFileContent(docsDir, file);
128
- const diagramLabels = content ? getDiagramTypeLabels(content) : [];
129
- const diagramSuffix = formatDiagramTypeSuffix(diagramLabels);
130
- debug(` • ${file}${diagramSuffix}`);
131
- }
132
- selectedFiles = filesWithDiagrams;
133
- } else {
134
- // --diagram mode: show only documents with diagrams, let user select
135
- const choices = await Promise.all(
136
- filesWithDiagrams.map(async (file) => {
137
- // Convert filename to flat path to find corresponding documentation structure item
138
- const flatName = file.replace(/\.md$/, "").replace(/\.\w+(-\w+)?$/, "");
139
- const docItem = documentStructure.find((item) => {
140
- const itemFlattenedPath = item.path.replace(/^\//, "").replace(/\//g, "-");
141
- return itemFlattenedPath === flatName;
142
- });
143
-
144
- // Read content to detect diagram types
145
- const content = await readFileContent(docsDir, file);
146
- const diagramLabels = content ? getDiagramTypeLabels(content) : [];
147
- const diagramSuffix = formatDiagramTypeSuffix(diagramLabels);
148
-
149
- // Use title if available, otherwise fall back to filename
150
- let displayName = docItem?.title;
151
- if (displayName) {
152
- displayName = `${displayName} (${file})${diagramSuffix}`;
153
- } else {
154
- displayName = `${file}${diagramSuffix}`;
155
- }
156
-
157
- return {
158
- name: displayName,
159
- value: file,
160
- };
161
- }),
162
- );
163
-
164
- // Let user select multiple files from filtered list
165
- selectedFiles = await options.prompts.checkbox({
166
- message: getActionText("Select documents with diagrams to {action}:", docAction),
167
- source: (term) => {
168
- if (!term) return choices;
169
-
170
- return choices.filter((choice) =>
171
- choice.name.toLowerCase().includes(term.toLowerCase()),
172
- );
173
- },
174
- validate: (answer) => {
175
- if (answer.length === 0) {
176
- return "Please select at least one document";
177
- }
178
- return true;
179
- },
180
- });
181
-
182
- if (!selectedFiles || selectedFiles.length === 0) {
183
- throw new Error("No documents selected");
184
- }
185
- }
186
- } else {
187
- // Normal flow: let user select documents from all files
188
- // Convert files to choices with titles
189
- const choices = mainLanguageFiles.map((file) => {
190
- // Convert filename to flat path to find corresponding documentation structure item
191
- const flatName = file.replace(/\.md$/, "").replace(/\.\w+(-\w+)?$/, "");
192
- const docItem = documentStructure.find((item) => {
193
- const itemFlattenedPath = item.path.replace(/^\//, "").replace(/\//g, "-");
194
- return itemFlattenedPath === flatName;
195
- });
196
-
197
- // Use title if available, otherwise fall back to filename
198
- let displayName = docItem?.title;
199
- if (displayName) {
200
- displayName = `${displayName} (${file})`;
201
- } else {
202
- displayName = file;
203
- }
204
-
205
- return {
206
- name: displayName,
207
- value: file,
208
- };
209
- });
210
-
211
- // Let user select multiple files
212
- selectedFiles = await options.prompts.checkbox({
213
- message: getActionText("Select documents to {action}:", docAction),
214
- source: (term) => {
215
- if (!term) return choices;
216
-
217
- return choices.filter((choice) =>
218
- choice.name.toLowerCase().includes(term.toLowerCase()),
219
- );
220
- },
221
- validate: (answer) => {
222
- if (answer.length === 0) {
223
- return "Please select at least one document";
224
- }
225
- return true;
226
- },
227
- });
228
-
229
- if (!selectedFiles || selectedFiles.length === 0) {
230
- throw new Error("No documents selected");
231
- }
232
- }
233
-
234
- // Process selected files and convert to found items
235
- foundItems = await processSelectedFiles(selectedFiles, documentStructure, docsDir);
236
- } catch (error) {
237
- debug(getActionText(`\nFailed to select documents to {action}: ${error.message}`, docAction));
238
- process.exit(0);
239
- }
240
- } else {
241
- // Process the provided docs array
242
- for (const docPath of docs) {
243
- const foundItem = await findItemByPath(documentStructure, docPath, boardId, docsDir, locale);
244
-
245
- if (!foundItem) {
246
- debug(`⚠️ Item with path "${docPath}" not found in documentStructure`);
247
- continue;
248
- }
249
-
250
- foundItems.push({
251
- ...foundItem,
252
- });
253
- }
254
-
255
- if (foundItems.length === 0) {
256
- throw new Error("None of the specified document paths were found in documentStructure");
257
- }
258
- }
259
-
260
- // Prompt for feedback if not provided
261
- // Skip feedback prompt if --diagram, --diagram-all, or --diagram-sync flag is set
262
- let userFeedback = feedback;
263
- if (
264
- !userFeedback &&
265
- (requiredFeedback || foundItems?.length > 1) &&
266
- !shouldUpdateDiagrams &&
267
- !shouldSyncImages &&
268
- !rest.isChat
269
- ) {
270
- const feedbackMessage = getFeedbackMessage(docAction);
271
-
272
- userFeedback = await options.prompts.input({
273
- message: feedbackMessage,
274
- });
275
- }
276
-
277
- // Add feedback to all results if provided
278
- foundItems = addFeedbackToItems(foundItems, userFeedback);
279
-
280
- // if reset is true, set content to null for all items
281
- if (reset) {
282
- foundItems = foundItems.map((item) => ({
283
- ...item,
284
- content: null,
285
- }));
286
- }
287
-
288
- return {
289
- selectedDocs: foundItems,
290
- feedback: userFeedback,
291
- selectedPaths: foundItems.map((item) => item.path),
292
- };
293
- }
@@ -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
-