@aigne/doc-smith 0.9.8-alpha.3 → 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 (257) 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/completer.md +0 -54
  21. package/agentic-agents/common/planner.md +0 -168
  22. package/agentic-agents/common/worker.md +0 -93
  23. package/agentic-agents/create/index.yaml +0 -129
  24. package/agentic-agents/create/objective.md +0 -44
  25. package/agentic-agents/create/set-custom-prompt.mjs +0 -27
  26. package/agentic-agents/detail/index.yaml +0 -95
  27. package/agentic-agents/detail/objective.md +0 -9
  28. package/agentic-agents/detail/set-custom-prompt.mjs +0 -88
  29. package/agentic-agents/predict-resources/index.yaml +0 -44
  30. package/agentic-agents/predict-resources/instructions.md +0 -61
  31. package/agentic-agents/structure/design-rules.md +0 -39
  32. package/agentic-agents/structure/index.yaml +0 -86
  33. package/agentic-agents/structure/objective.md +0 -14
  34. package/agentic-agents/structure/review-criteria.md +0 -55
  35. package/agentic-agents/structure/set-custom-prompt.mjs +0 -78
  36. package/agentic-agents/utils/init-workspace-cache.mjs +0 -171
  37. package/agentic-agents/utils/load-base-sources.mjs +0 -20
  38. package/agentic-agents/workspace-cache-sharing-design.md +0 -671
  39. package/agents/chat/chat-system.md +0 -38
  40. package/agents/chat/index.mjs +0 -59
  41. package/agents/chat/skills/generate-document.yaml +0 -15
  42. package/agents/chat/skills/list-documents.mjs +0 -15
  43. package/agents/chat/skills/update-document.yaml +0 -24
  44. package/agents/clear/choose-contents.mjs +0 -192
  45. package/agents/clear/clear-auth-tokens.mjs +0 -88
  46. package/agents/clear/clear-deployment-config.mjs +0 -49
  47. package/agents/clear/clear-document-config.mjs +0 -36
  48. package/agents/clear/clear-document-structure.mjs +0 -102
  49. package/agents/clear/clear-generated-docs.mjs +0 -142
  50. package/agents/clear/clear-media-description.mjs +0 -129
  51. package/agents/clear/index.yaml +0 -26
  52. package/agents/create/analyze-diagram-type-llm.yaml +0 -160
  53. package/agents/create/analyze-diagram-type.mjs +0 -297
  54. package/agents/create/check-document-structure.yaml +0 -30
  55. package/agents/create/check-need-generate-structure.mjs +0 -105
  56. package/agents/create/document-structure-tools/add-document.mjs +0 -85
  57. package/agents/create/document-structure-tools/delete-document.mjs +0 -116
  58. package/agents/create/document-structure-tools/move-document.mjs +0 -109
  59. package/agents/create/document-structure-tools/update-document.mjs +0 -84
  60. package/agents/create/generate-diagram-image.yaml +0 -60
  61. package/agents/create/generate-structure.yaml +0 -117
  62. package/agents/create/index.yaml +0 -49
  63. package/agents/create/refine-document-structure.yaml +0 -12
  64. package/agents/create/replace-d2-with-image.mjs +0 -625
  65. package/agents/create/update-document-structure.yaml +0 -54
  66. package/agents/create/user-add-document/add-documents-to-structure.mjs +0 -90
  67. package/agents/create/user-add-document/find-documents-to-add-links.yaml +0 -47
  68. package/agents/create/user-add-document/index.yaml +0 -46
  69. package/agents/create/user-add-document/prepare-documents-to-translate.mjs +0 -22
  70. package/agents/create/user-add-document/print-add-document-summary.mjs +0 -63
  71. package/agents/create/user-add-document/review-documents-with-new-links.mjs +0 -110
  72. package/agents/create/user-remove-document/find-documents-with-invalid-links.mjs +0 -78
  73. package/agents/create/user-remove-document/index.yaml +0 -40
  74. package/agents/create/user-remove-document/prepare-documents-to-translate.mjs +0 -22
  75. package/agents/create/user-remove-document/print-remove-document-summary.mjs +0 -53
  76. package/agents/create/user-remove-document/remove-documents-from-structure.mjs +0 -99
  77. package/agents/create/user-remove-document/review-documents-with-invalid-links.mjs +0 -115
  78. package/agents/create/user-review-document-structure.mjs +0 -140
  79. package/agents/create/utils/init-current-content.mjs +0 -34
  80. package/agents/create/utils/merge-document-structures.mjs +0 -30
  81. package/agents/evaluate/code-snippet.mjs +0 -97
  82. package/agents/evaluate/document-structure.yaml +0 -67
  83. package/agents/evaluate/document.yaml +0 -82
  84. package/agents/evaluate/generate-report.mjs +0 -85
  85. package/agents/evaluate/index.yaml +0 -46
  86. package/agents/history/index.yaml +0 -6
  87. package/agents/history/view.mjs +0 -78
  88. package/agents/init/check.mjs +0 -16
  89. package/agents/init/index.mjs +0 -275
  90. package/agents/init/validate.mjs +0 -16
  91. package/agents/localize/choose-language.mjs +0 -107
  92. package/agents/localize/index.yaml +0 -58
  93. package/agents/localize/record-translation-history.mjs +0 -23
  94. package/agents/localize/translate-document.yaml +0 -24
  95. package/agents/localize/translate-multilingual.yaml +0 -51
  96. package/agents/media/batch-generate-media-description.yaml +0 -46
  97. package/agents/media/generate-media-description.yaml +0 -50
  98. package/agents/media/load-media-description.mjs +0 -256
  99. package/agents/prefs/index.mjs +0 -203
  100. package/agents/publish/index.yaml +0 -26
  101. package/agents/publish/publish-docs.mjs +0 -356
  102. package/agents/publish/translate-meta.mjs +0 -103
  103. package/agents/schema/document-structure-item.yaml +0 -26
  104. package/agents/schema/document-structure-refine-item.yaml +0 -23
  105. package/agents/schema/document-structure.yaml +0 -29
  106. package/agents/update/batch-generate-document.yaml +0 -27
  107. package/agents/update/batch-update-document.yaml +0 -7
  108. package/agents/update/check-diagram-flag.mjs +0 -116
  109. package/agents/update/check-document.mjs +0 -162
  110. package/agents/update/check-generate-diagram.mjs +0 -106
  111. package/agents/update/check-sync-image-flag.mjs +0 -55
  112. package/agents/update/check-update-is-single.mjs +0 -53
  113. package/agents/update/document-tools/update-document-content.mjs +0 -303
  114. package/agents/update/generate-diagram.yaml +0 -63
  115. package/agents/update/generate-document.yaml +0 -70
  116. package/agents/update/handle-document-update.yaml +0 -103
  117. package/agents/update/index.yaml +0 -79
  118. package/agents/update/pre-check-generate-diagram.yaml +0 -44
  119. package/agents/update/save-and-translate-document.mjs +0 -76
  120. package/agents/update/sync-images-and-exit.mjs +0 -148
  121. package/agents/update/update-document-detail.yaml +0 -71
  122. package/agents/update/update-single/update-single-document-detail.mjs +0 -280
  123. package/agents/update/update-single-document.yaml +0 -7
  124. package/agents/update/user-review-document.mjs +0 -272
  125. package/agents/utils/action-success.mjs +0 -16
  126. package/agents/utils/analyze-document-feedback-intent.yaml +0 -32
  127. package/agents/utils/analyze-feedback-intent.mjs +0 -136
  128. package/agents/utils/analyze-structure-feedback-intent.yaml +0 -29
  129. package/agents/utils/check-detail-result.mjs +0 -38
  130. package/agents/utils/check-feedback-refiner.mjs +0 -81
  131. package/agents/utils/choose-docs.mjs +0 -293
  132. package/agents/utils/document-icon-generate.yaml +0 -52
  133. package/agents/utils/document-title-streamline.yaml +0 -48
  134. package/agents/utils/ensure-document-icons.mjs +0 -129
  135. package/agents/utils/exit.mjs +0 -6
  136. package/agents/utils/feedback-refiner.yaml +0 -50
  137. package/agents/utils/find-item-by-path.mjs +0 -114
  138. package/agents/utils/find-user-preferences-by-path.mjs +0 -37
  139. package/agents/utils/format-document-structure.mjs +0 -35
  140. package/agents/utils/generate-document-or-skip.mjs +0 -41
  141. package/agents/utils/handle-diagram-operations.mjs +0 -263
  142. package/agents/utils/load-all-document-content.mjs +0 -30
  143. package/agents/utils/load-document-all-content.mjs +0 -84
  144. package/agents/utils/load-sources.mjs +0 -405
  145. package/agents/utils/map-reasoning-effort-level.mjs +0 -15
  146. package/agents/utils/post-generate.mjs +0 -144
  147. package/agents/utils/read-current-document-content.mjs +0 -46
  148. package/agents/utils/save-doc-translation.mjs +0 -61
  149. package/agents/utils/save-doc.mjs +0 -88
  150. package/agents/utils/save-output.mjs +0 -26
  151. package/agents/utils/save-sidebar.mjs +0 -51
  152. package/agents/utils/skip-if-content-exists.mjs +0 -27
  153. package/agents/utils/streamline-document-titles-if-needed.mjs +0 -88
  154. package/agents/utils/transform-detail-data-sources.mjs +0 -45
  155. package/agents/utils/update-branding.mjs +0 -84
  156. package/assets/report-template/report.html +0 -198
  157. package/docs-mcp/analyze-content-relevance.yaml +0 -50
  158. package/docs-mcp/analyze-docs-relevance.yaml +0 -59
  159. package/docs-mcp/docs-search.yaml +0 -42
  160. package/docs-mcp/get-docs-detail.mjs +0 -41
  161. package/docs-mcp/get-docs-structure.mjs +0 -16
  162. package/docs-mcp/read-doc-content.mjs +0 -119
  163. package/prompts/common/document/content-rules-core.md +0 -20
  164. package/prompts/common/document/markdown-syntax-rules.md +0 -65
  165. package/prompts/common/document/media-file-list-usage-rules.md +0 -18
  166. package/prompts/common/document/openapi-usage-rules.md +0 -189
  167. package/prompts/common/document/role-and-personality.md +0 -16
  168. package/prompts/common/document/user-preferences.md +0 -9
  169. package/prompts/common/document-structure/conflict-resolution-guidance.md +0 -16
  170. package/prompts/common/document-structure/document-icon-generate.md +0 -116
  171. package/prompts/common/document-structure/document-structure-rules.md +0 -43
  172. package/prompts/common/document-structure/document-title-streamline.md +0 -86
  173. package/prompts/common/document-structure/glossary.md +0 -7
  174. package/prompts/common/document-structure/intj-traits.md +0 -5
  175. package/prompts/common/document-structure/openapi-usage-rules.md +0 -28
  176. package/prompts/common/document-structure/output-constraints.md +0 -18
  177. package/prompts/common/document-structure/user-locale-rules.md +0 -10
  178. package/prompts/common/document-structure/user-preferences.md +0 -9
  179. package/prompts/detail/custom/admonition-usage-rules.md +0 -94
  180. package/prompts/detail/custom/code-block-usage-rules.md +0 -163
  181. package/prompts/detail/custom/custom-components/x-card-usage-rules.md +0 -63
  182. package/prompts/detail/custom/custom-components/x-cards-usage-rules.md +0 -83
  183. package/prompts/detail/custom/custom-components/x-field-desc-usage-rules.md +0 -120
  184. package/prompts/detail/custom/custom-components/x-field-group-usage-rules.md +0 -80
  185. package/prompts/detail/custom/custom-components/x-field-usage-rules.md +0 -189
  186. package/prompts/detail/custom/custom-components-usage-rules.md +0 -18
  187. package/prompts/detail/diagram/generate-image-system.md +0 -135
  188. package/prompts/detail/diagram/generate-image-user.md +0 -32
  189. package/prompts/detail/diagram/guide.md +0 -29
  190. package/prompts/detail/diagram/official-examples.md +0 -712
  191. package/prompts/detail/diagram/pre-check.md +0 -23
  192. package/prompts/detail/diagram/role-and-personality.md +0 -2
  193. package/prompts/detail/diagram/rules.md +0 -46
  194. package/prompts/detail/diagram/system-prompt.md +0 -1139
  195. package/prompts/detail/diagram/user-prompt.md +0 -43
  196. package/prompts/detail/generate/detail-example.md +0 -457
  197. package/prompts/detail/generate/document-rules.md +0 -45
  198. package/prompts/detail/generate/system-prompt.md +0 -61
  199. package/prompts/detail/generate/user-prompt.md +0 -99
  200. package/prompts/detail/jsx/rules.md +0 -6
  201. package/prompts/detail/update/system-prompt.md +0 -121
  202. package/prompts/detail/update/user-prompt.md +0 -41
  203. package/prompts/evaluate/document-structure.md +0 -93
  204. package/prompts/evaluate/document.md +0 -149
  205. package/prompts/media/media-description/system-prompt.md +0 -43
  206. package/prompts/media/media-description/user-prompt.md +0 -17
  207. package/prompts/structure/check-document-structure.md +0 -93
  208. package/prompts/structure/document-rules.md +0 -21
  209. package/prompts/structure/find-documents-to-add-links.md +0 -52
  210. package/prompts/structure/generate/system-prompt.md +0 -13
  211. package/prompts/structure/generate/user-prompt.md +0 -137
  212. package/prompts/structure/review/structure-review-system.md +0 -81
  213. package/prompts/structure/structure-example.md +0 -89
  214. package/prompts/structure/structure-getting-started.md +0 -10
  215. package/prompts/structure/update/system-prompt.md +0 -93
  216. package/prompts/structure/update/user-prompt.md +0 -43
  217. package/prompts/translate/admonition.md +0 -20
  218. package/prompts/translate/code-block.md +0 -33
  219. package/prompts/translate/glossary.md +0 -6
  220. package/prompts/translate/translate-document.md +0 -305
  221. package/prompts/utils/analyze-document-feedback-intent.md +0 -54
  222. package/prompts/utils/analyze-structure-feedback-intent.md +0 -43
  223. package/prompts/utils/feedback-refiner.md +0 -105
  224. package/types/document-schema.mjs +0 -55
  225. package/types/document-structure-schema.mjs +0 -261
  226. package/utils/auth-utils.mjs +0 -275
  227. package/utils/blocklet.mjs +0 -104
  228. package/utils/check-document-has-diagram.mjs +0 -95
  229. package/utils/conflict-detector.mjs +0 -149
  230. package/utils/constants/index.mjs +0 -620
  231. package/utils/constants/linter.mjs +0 -102
  232. package/utils/d2-utils.mjs +0 -198
  233. package/utils/debug.mjs +0 -3
  234. package/utils/delete-diagram-images.mjs +0 -99
  235. package/utils/deploy.mjs +0 -86
  236. package/utils/docs-finder-utils.mjs +0 -623
  237. package/utils/evaluate/report-utils.mjs +0 -132
  238. package/utils/extract-api.mjs +0 -32
  239. package/utils/file-utils.mjs +0 -960
  240. package/utils/history-utils.mjs +0 -203
  241. package/utils/icon-map.mjs +0 -26
  242. package/utils/image-compress.mjs +0 -75
  243. package/utils/kroki-utils.mjs +0 -173
  244. package/utils/linter/index.mjs +0 -50
  245. package/utils/load-config.mjs +0 -107
  246. package/utils/markdown/index.mjs +0 -26
  247. package/utils/markdown-checker.mjs +0 -694
  248. package/utils/mermaid-validator.mjs +0 -140
  249. package/utils/mermaid-worker-pool.mjs +0 -250
  250. package/utils/mermaid-worker.mjs +0 -233
  251. package/utils/openapi/index.mjs +0 -28
  252. package/utils/preferences-utils.mjs +0 -175
  253. package/utils/request.mjs +0 -10
  254. package/utils/store/index.mjs +0 -45
  255. package/utils/sync-diagram-to-translations.mjs +0 -262
  256. package/utils/upload-files.mjs +0 -231
  257. package/utils/utils.mjs +0 -1354
@@ -1,115 +0,0 @@
1
- import {
2
- buildAllowedLinksFromStructure,
3
- generateFileName,
4
- pathToFlatName,
5
- } from "../../../utils/docs-finder-utils.mjs";
6
-
7
- /**
8
- * Generate feedback message for fixing invalid links in a document
9
- */
10
- function generateInvalidLinksFeedback(invalidLinks, documentPath, documentStructure) {
11
- const invalidLinksList = invalidLinks.map((link) => `- ${link}`).join("\n");
12
-
13
- // Build allowed links from document structure for replacement suggestions
14
- const allowedLinks = buildAllowedLinksFromStructure(documentStructure);
15
- const allowedLinksArray = Array.from(allowedLinks)
16
- .filter((link) => link !== documentPath) // Exclude current document path
17
- .sort();
18
-
19
- const allowedLinksList =
20
- allowedLinksArray.length > 0
21
- ? allowedLinksArray.map((link) => `- ${link}`).join("\n")
22
- : "(No available links)";
23
-
24
- return `This document contains invalid links that need to be fixed. Please handle them according to the following instructions:
25
-
26
- **Invalid Links Found:**
27
- ${invalidLinksList}
28
-
29
- **Available Valid Links:**
30
- ${allowedLinksList}
31
-
32
- **Instructions for fixing invalid links:**
33
-
34
- 1. For each invalid link found in the document:
35
- - Using the document context and the list of available valid links, try to find a suitable replacement link from the available valid links.
36
- - When choosing a replacement, exclude the current document path (${documentPath}); linking to the current document is not logical.
37
- - **Do not consider the original invalid link or its related text**; they are outdated and should be replaced.
38
-
39
- 2. If a suitable replacement link is found:
40
- - Update **all related fields** associated with the invalid link (e.g., link URL, link text, surrounding context) according to the matched link from the available valid links.
41
- - Ensure that after updating the link, the surrounding content remains consistent and natural. If there is a mismatch, update the corresponding content to keep everything aligned.
42
-
43
- 3. If no suitable replacement link can be found:
44
- - Remove the invalid link completely, including the link text and any associated content that only makes sense with that link.
45
- - **Do not affect other unrelated content** in the document; only remove content that is directly tied to the invalid link.
46
-
47
- 4. Ensure the document remains coherent and readable after the changes.`;
48
- }
49
-
50
- export default async function reviewDocumentsWithInvalidLinks(input = {}, options = {}) {
51
- const { documentsWithInvalidLinks = [], documentStructure = [], locale = "en" } = input;
52
-
53
- // If no documents with invalid links, return empty array
54
- if (!Array.isArray(documentsWithInvalidLinks) || documentsWithInvalidLinks.length === 0) {
55
- return {
56
- documentsWithInvalidLinks: [],
57
- documentsToUpdate: [],
58
- };
59
- }
60
-
61
- // Create choices for user selection, default all checked
62
- const choices = documentsWithInvalidLinks.map((doc) => {
63
- const flatName = pathToFlatName(doc.path);
64
- const filename = generateFileName(flatName, locale);
65
-
66
- return {
67
- name: `${doc.title} (${filename})`,
68
- value: doc.path,
69
- checked: true, // Default all selected
70
- description: `Invalid Links(${doc.invalidLinks?.length || 0}): ${doc.invalidLinks?.join(", ")}`,
71
- };
72
- });
73
-
74
- // Let user select documents (default all selected)
75
- const selectedPaths = await options.prompts.checkbox({
76
- message:
77
- "Select documents with invalid links to fix (all selected by default, press Enter to confirm, or unselect all to skip):",
78
- choices,
79
- });
80
-
81
- // Filter documents based on user selection
82
- const selectedPathsSet = new Set(selectedPaths);
83
- const filteredDocs = documentsWithInvalidLinks.filter((doc) => selectedPathsSet.has(doc.path));
84
-
85
- if (filteredDocs.length === 0) {
86
- return {
87
- documentsWithInvalidLinks: [],
88
- documentsToUpdate: [],
89
- };
90
- }
91
-
92
- // Prepare documents: add necessary fields for update (without content)
93
- const preparedDocs = [];
94
-
95
- for (const doc of filteredDocs) {
96
- if (!doc.path) continue;
97
-
98
- // Find corresponding document in documentStructure to get additional fields
99
- const structureDoc = documentStructure.find((item) => item.path === doc.path);
100
-
101
- // Generate feedback message for fixing invalid links
102
- const feedback = generateInvalidLinksFeedback(doc.invalidLinks, doc.path, documentStructure);
103
-
104
- preparedDocs.push({
105
- ...structureDoc,
106
- feedback,
107
- invalidLinks: doc.invalidLinks,
108
- });
109
- }
110
-
111
- return {
112
- documentsWithInvalidLinks: preparedDocs, // for print summary
113
- documentsToUpdate: JSON.parse(JSON.stringify(preparedDocs)), // for batch update
114
- };
115
- }
@@ -1,140 +0,0 @@
1
- import { getActiveRulesForScope } from "../../utils/preferences-utils.mjs";
2
- import { recordUpdate } from "../../utils/history-utils.mjs";
3
- import { printDocumentStructure } from "../../utils/docs-finder-utils.mjs";
4
- import equal from "fast-deep-equal";
5
-
6
- export default async function userReviewDocumentStructure({ documentStructure, ...rest }, options) {
7
- // Check if documentation structure exists
8
- if (!documentStructure || !Array.isArray(documentStructure) || documentStructure.length === 0) {
9
- console.log("No documentation structure was generated to review.");
10
- return { documentStructure };
11
- }
12
-
13
- // Print current documentation structure in a user-friendly format
14
- if (!rest.isChat) {
15
- printDocumentStructure(documentStructure);
16
-
17
- // Ask user if they want to review the documentation structure
18
- const needReview = await options.prompts.select({
19
- message: "Would you like to refine the documentation structure?",
20
- choices: [
21
- {
22
- name: "No, looks good",
23
- value: "no",
24
- },
25
- {
26
- name: "Yes, optimize the structure (e.g. rename 'Getting Started' to 'Quick Start', move 'API Reference' before 'Configuration')",
27
- value: "yes",
28
- },
29
- ],
30
- });
31
-
32
- if (needReview === "no") {
33
- return { documentStructure };
34
- }
35
- }
36
-
37
- let currentStructure = documentStructure;
38
-
39
- const MAX_ITERATIONS = 100;
40
- let iterationCount = 0;
41
-
42
- // share current structure with updateDocumentStructure agent
43
- options.context.userContext.currentStructure = currentStructure;
44
- while (iterationCount < MAX_ITERATIONS) {
45
- iterationCount++;
46
-
47
- // Ask for feedback
48
- const feedback = rest.isChat
49
- ? rest.feedback
50
- : await options.prompts.input({
51
- message:
52
- "How would you like to improve the structure?\n" +
53
- "Examples:\n" +
54
- " • Add a new document 'Troubleshooting'\n" +
55
- " • Remove the 'Legacy Features' document\n" +
56
- " • Move 'Installation' to the top of the structure\n\n" +
57
- " Press Enter to finish reviewing:",
58
- });
59
-
60
- // If no feedback, break the loop
61
- if (!feedback?.trim()) {
62
- break;
63
- }
64
-
65
- // Get the refineDocumentStructure agent
66
- const refineAgent = options.context.agents["generateStructureExp"];
67
- if (!refineAgent) {
68
- console.log(
69
- "Unable to process your feedback - the documentation structure update feature is unavailable.",
70
- );
71
- console.log("Please try again later or contact support if this continues.");
72
- break;
73
- }
74
-
75
- // Get user preferences
76
- const structureRules = getActiveRulesForScope("structure", []);
77
- const globalRules = getActiveRulesForScope("global", []);
78
- const allApplicableRules = [...structureRules, ...globalRules];
79
- const ruleTexts = allApplicableRules.map((rule) => rule.rule);
80
- const userPreferences = ruleTexts.length > 0 ? ruleTexts.join("\n\n") : "";
81
-
82
- try {
83
- // Call refineDocumentStructure agent with feedback
84
- const { message, ...result } = await options.context.invoke(refineAgent, {
85
- ...rest,
86
- // dataSourceChunk: rest.dataSources[0].dataSourceChunk,
87
- userFeedback: feedback.trim(),
88
- // documentStructure: currentStructure,
89
- // userPreferences,
90
- });
91
-
92
- // currentStructure = options.context.userContext.currentStructure;
93
- currentStructure = result.documentStructure;
94
-
95
- if (rest.isChat && equal(currentStructure, documentStructure)) {
96
- throw new Error(
97
- `The suggested structure changes did not modify the existing documentation structure. ${message}`,
98
- );
99
- }
100
-
101
- // Check if feedback should be saved as user preference
102
- const feedbackRefinerAgent = options.context.agents["checkFeedbackRefiner"];
103
- if (feedbackRefinerAgent) {
104
- try {
105
- await options.context.invoke(feedbackRefinerAgent, {
106
- documentStructureFeedback: feedback.trim(),
107
- stage: "structure",
108
- });
109
- } catch (refinerError) {
110
- console.warn("Could not save feedback as a user preference:", refinerError.message);
111
- console.warn("Your feedback was applied but not saved as a preference.");
112
- }
113
- }
114
-
115
- // Record update in history
116
- recordUpdate({
117
- operation: "structure_update",
118
- feedback: feedback.trim(),
119
- });
120
-
121
- // Print current documentation structure in a user-friendly format
122
- printDocumentStructure(currentStructure);
123
-
124
- if (rest.isChat) {
125
- break;
126
- }
127
- } catch (error) {
128
- console.error("Error processing your feedback:");
129
- console.error(`Type: ${error.name}`);
130
- console.error(`Message: ${error.message}`);
131
- console.error(`Stack: ${error.stack}`);
132
- console.log("\nPlease try rephrasing your feedback or continue with the current structure.");
133
- break;
134
- }
135
- }
136
-
137
- return { documentStructure: currentStructure };
138
- }
139
-
140
- userReviewDocumentStructure.taskTitle = "User review and modify documentation structure";
@@ -1,34 +0,0 @@
1
- import { readFileContent } from "../../../utils/docs-finder-utils.mjs";
2
- import { getFileName, userContextAt } from "../../../utils/utils.mjs";
3
-
4
- /**
5
- * Initialize currentContents in userContext for document update
6
- * Reads document content from file system and sets it in userContext
7
- * Uses getFileName utility to generate filename consistently
8
- */
9
- export default async function initCurrentContent(input, options) {
10
- const { path, docsDir, locale = "en" } = input;
11
-
12
- if (!path) {
13
- return {};
14
- }
15
-
16
- // Generate filename using unified utility function
17
- const fileName = getFileName(path, locale);
18
-
19
- // Read document content
20
- const content = docsDir ? await readFileContent(docsDir, fileName) : null;
21
-
22
- if (!content) {
23
- console.warn(`⚠️ Could not read content from ${fileName}`);
24
- return {};
25
- }
26
-
27
- // Initialize currentContents[path] in userContext
28
- const contentContext = userContextAt(options, `currentContents.${path}`);
29
- contentContext.set(content);
30
-
31
- return {};
32
- }
33
-
34
- initCurrentContent.task_render_mode = "hide";
@@ -1,30 +0,0 @@
1
- export default async function mergeDocumentStructures(input, options) {
2
- if (input.projectName) {
3
- options.context.userContext.projectName = input.projectName;
4
- }
5
- if (input.projectDesc) {
6
- options.context.userContext.projectDesc = input.projectDesc;
7
- }
8
-
9
- input.projectName = options.context.userContext.projectName;
10
- input.projectDesc = options.context.userContext.projectDesc;
11
-
12
- options.context.userContext.originalDocumentStructure ??= [];
13
-
14
- const originalStructures = [...options.context.userContext.originalDocumentStructure];
15
-
16
- if (input.structures) {
17
- for (const item of input.structures) {
18
- const index = originalStructures.findIndex((s) => s.path === item.path);
19
- if (index !== -1) {
20
- originalStructures[index] = item;
21
- } else {
22
- originalStructures.push(item);
23
- }
24
- }
25
- }
26
-
27
- options.context.userContext.originalDocumentStructure = originalStructures;
28
-
29
- return {};
30
- }
@@ -1,97 +0,0 @@
1
- import pMap from "p-map";
2
- import pRetry from "p-retry";
3
- import {
4
- CODE_LANGUAGE_MAP_LINTER,
5
- CODE_LANGUAGE_MAP_SUFFIX,
6
- } from "../../utils/constants/linter.mjs";
7
- import { debug } from "../../utils/debug.mjs";
8
- import { lintCode } from "../../utils/linter/index.mjs";
9
- import { getMarkdownAst, traverseMarkdownAst } from "../../utils/markdown/index.mjs";
10
-
11
- const severityMapLevel = {
12
- error: "critical",
13
- warning: "minor",
14
- };
15
-
16
- export default async function evaluateDocumentCode({ content }) {
17
- const ast = getMarkdownAst({ markdown: content });
18
- const checkPromiseList = [];
19
- const checkListResult = [];
20
- let totalCount = 0;
21
- let ignoreCount = 0;
22
- let errorCount = 0;
23
-
24
- traverseMarkdownAst({
25
- ast,
26
- test: "code",
27
- visitor(node) {
28
- const linter = CODE_LANGUAGE_MAP_LINTER[node.lang];
29
- if (linter) {
30
- const suffix = CODE_LANGUAGE_MAP_SUFFIX[node.lang];
31
- checkPromiseList.push({ linter, code: node.value, suffix });
32
- totalCount += 1;
33
- } else {
34
- ignoreCount += 1;
35
- }
36
- },
37
- });
38
- const checkList = await pMap(
39
- checkPromiseList,
40
- async (item) => {
41
- try {
42
- const result = await pRetry(() => lintCode(item), {
43
- onFailedAttempt: ({ error, attemptNumber, retriesLeft }) => {
44
- debug(
45
- `Attempt ${attemptNumber} failed: ${error.message}. There are ${retriesLeft} retries left.`,
46
- );
47
- },
48
- retries: 3,
49
- });
50
- // lint occurs error, ignore
51
- if (!result.success) {
52
- debug("Lint failed", item, result);
53
- return [];
54
- }
55
-
56
- if (!result.issues || result.issues.length === 0) {
57
- debug("Lint result empty issues", item, result);
58
- return [];
59
- }
60
-
61
- errorCount += 1;
62
- return result.issues.map((x) => {
63
- return {
64
- ...x,
65
- level: severityMapLevel[x.severity],
66
- };
67
- });
68
- } catch (error) {
69
- debug("Lint occurred error", error);
70
- return [];
71
- }
72
- },
73
- { concurrency: 5 },
74
- );
75
- checkListResult.push(...checkList.flat());
76
-
77
- return {
78
- codeEvaluation: {
79
- details: checkListResult,
80
- totalCount,
81
- ignoreCount,
82
- errorCount,
83
- },
84
- };
85
- }
86
-
87
- evaluateDocumentCode.description = "Traverse markdown code blocks and evaluate them.";
88
-
89
- evaluateDocumentCode.input_schema = {
90
- type: "object",
91
- properties: {
92
- content: {
93
- type: "string",
94
- description: "Source markdown content to be evaluated.",
95
- },
96
- },
97
- };
@@ -1,67 +0,0 @@
1
- name: evaluateDocumentStructure
2
- description: Evaluates the results generated by the document-structure agent to ensure they meet expectations, especially in scenarios with previous generation results and user feedback.
3
- instructions:
4
- url: ../../prompts/evaluate/document-structure.md
5
- model:
6
- model: gpt-5
7
- temperature: 1
8
- task_render_mode: collapse
9
- task_title: Evaluate the structure of the documentation
10
- input_schema:
11
- type: object
12
- properties:
13
- documentStructureYaml:
14
- type: string
15
- description: Documentation structure data
16
- purposes:
17
- type: string
18
- description: User-selected document goals
19
- audiences:
20
- type: string
21
- description: User-selected target audiences
22
- coverageDepth:
23
- type: string
24
- description: User-selected content depth
25
- required:
26
- - documentStructureYaml
27
- - purposes
28
- - audiences
29
- - coverageDepth
30
- output_schema:
31
- type: object
32
- properties:
33
- structureEvaluation:
34
- type: object
35
- properties:
36
- details:
37
- type: array
38
- items:
39
- type: object
40
- properties:
41
- dimension:
42
- type: string
43
- enum: [purposeCoverage, audienceCoverage, depthCoverage]
44
- description: Dimension associated with this observation
45
- level:
46
- type: string
47
- enum: [excellent, good, meets, minor, critical]
48
- description: Evaluation level applied to the observation
49
- topic:
50
- type: string
51
- description: Short identifier for the purpose/audience/depth aspect being judged
52
- description:
53
- type: string
54
- description: Why the level was assigned
55
- line:
56
- type: integer
57
- description: Integer line number within the source document/module (use 0 if unknown)
58
- required:
59
- - dimension
60
- - level
61
- - topic
62
- - description
63
- description: List of detailed evaluations for each purpose dimension
64
- required:
65
- - details
66
- required:
67
- - structureEvaluation
@@ -1,82 +0,0 @@
1
- name: evaluateDocument
2
- description: Evaluates the quality of generated document content, ensuring compliance with user-configured goals, audiences, and knowledge level requirements.
3
- instructions:
4
- url: ../../prompts/evaluate/document.md
5
- model:
6
- model: gpt-5
7
- temperature: 1
8
- task_render_mode: collapse
9
- task_title: Evaluate document for '{{ title }}'
10
- input_schema:
11
- type: object
12
- properties:
13
- path:
14
- type: string
15
- description: Document path to be evaluated
16
- content:
17
- type: string
18
- description: Document content to be evaluated
19
- translationsString:
20
- type: string
21
- description: Document translation content
22
- description:
23
- type: string
24
- description: Document content planning description
25
- purposes:
26
- type: string
27
- description: User-selected document goals
28
- audiences:
29
- type: string
30
- description: User-selected target audiences
31
- readerKnowledgeLevel:
32
- type: string
33
- description: User-selected reader knowledge level
34
- allDocumentContentList:
35
- type: array
36
- description: All document content list for better evaluate
37
- required:
38
- - content
39
- - description
40
- - purposes
41
- - audiences
42
- - readerKnowledgeLevel
43
- output_schema:
44
- type: object
45
- properties:
46
- documentEvaluation:
47
- type: object
48
- properties:
49
- details:
50
- type: array
51
- description: Detailed observations contributing to the final score
52
- items:
53
- type: object
54
- properties:
55
- dimension:
56
- type: string
57
- enum: [readability, coherence, contentQuality, consistency, purposeAlignment, audienceAlignment, knowledgeLevelAlignment]
58
- description: Dimension associated with this observation
59
- level:
60
- type: string
61
- enum: [excellent, good, meets, minor, critical]
62
- description: Evaluation level applied to the observation
63
- topic:
64
- type: string
65
- description: Short identifier for the assessed passage or section
66
- line:
67
- type: integer
68
- description: Source line number related to the observation (0 if unknown)
69
- description:
70
- type: string
71
- description: Impact-focused explanation of the observation
72
- required:
73
- - dimension
74
- - level
75
- - topic
76
- - line
77
- - description
78
- required:
79
- - details
80
- required:
81
- - documentEvaluation
82
- includeInputInOutput: true
@@ -1,85 +0,0 @@
1
- import { writeFile } from "node:fs/promises";
2
- import { join } from "node:path";
3
- import { pick } from "@aigne/core/utils/type-utils.js";
4
- import isInCi from "is-in-ci";
5
- import openTerminal from "open";
6
-
7
- import { DOC_SMITH_DIR } from "../../utils/constants/index.mjs";
8
- import {
9
- copyHtmlReportTemplate,
10
- createReportStructure,
11
- ensureDirectoryExists,
12
- generateReportSuccessMessage,
13
- generateTimestampForFolder,
14
- } from "../../utils/evaluate/report-utils.mjs";
15
- import { toRelativePath } from "../../utils/utils.mjs";
16
-
17
- /**
18
- * Generate and save evaluation report by aggregating results from both structure and document evaluation agents
19
- * @param {Object} params - Parameters object containing all evaluation data
20
- * @param {Object} params.purposeCoverage - Purpose coverage evaluation from evaluate/document-structure agent
21
- * @param {Object} params.audienceCoverage - Audience coverage evaluation from evaluate/document-structure agent
22
- * @param {Object} params.coverageDepthAlignment - Coverage depth alignment evaluation from evaluate/document-structure agent
23
- * @param {Array} params.originalDocumentStructure - Array of document evaluation results from evaluate/document agent
24
- * @param {Object} [params.metadata] - Additional metadata for the report
25
- * @param {string} [params.basePath] - Base path for saving reports, defaults to current working directory
26
- * @returns {Promise<string>} Path to the saved report file
27
- */
28
- export default async function generateEvaluationReport({
29
- structureEvaluation,
30
- originalDocumentStructure,
31
- metadata = {},
32
- basePath = process.cwd(),
33
- projectName,
34
- projectDesc,
35
- projectLogo,
36
- documentPurpose,
37
- targetAudienceTypes,
38
- readerKnowledgeLevel,
39
- documentationDepth,
40
- targetAudience,
41
- open = true,
42
- }) {
43
- const timestamp = new Date().toISOString();
44
- const timestampForFolder = generateTimestampForFolder();
45
- const documentEvaluations = originalDocumentStructure.map((x) =>
46
- pick(x, ["title", "description", "path", "parentId", "documentEvaluation", "codeEvaluation"]),
47
- );
48
-
49
- // Create report structure
50
- const report = createReportStructure({
51
- timestamp,
52
- metadata,
53
- structureEvaluation,
54
- documentEvaluations,
55
- projectName,
56
- projectDesc,
57
- projectLogo,
58
- documentPurpose,
59
- targetAudienceTypes,
60
- readerKnowledgeLevel,
61
- documentationDepth,
62
- targetAudience,
63
- });
64
-
65
- const saveDir = join(basePath, DOC_SMITH_DIR, "evaluate", timestampForFolder);
66
- const jsonReportPath = join(saveDir, "integrity-report.json");
67
-
68
- await ensureDirectoryExists(saveDir);
69
- await writeFile(jsonReportPath, JSON.stringify(report, null, 2), "utf8");
70
-
71
- // Copy HTML report template
72
- const htmlReportPath = await copyHtmlReportTemplate(saveDir, report);
73
-
74
- // Generate success message
75
- const message = generateReportSuccessMessage(toRelativePath(jsonReportPath), htmlReportPath);
76
- if (open && !isInCi) {
77
- openTerminal(htmlReportPath);
78
- }
79
-
80
- return {
81
- message,
82
- };
83
- }
84
-
85
- generateEvaluationReport.taskTitle = "Generate evaluation report";