@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,90 +0,0 @@
1
- import { getActiveRulesForScope } from "../../../utils/preferences-utils.mjs";
2
- import { printDocumentStructure } from "../../../utils/docs-finder-utils.mjs";
3
-
4
- export default async function addDocumentsToStructure(input = {}, options = {}) {
5
- const { originalDocumentStructure = [] } = input;
6
- const analyzeIntent = options.context?.agents?.["analyzeStructureFeedbackIntent"];
7
- const updateDocumentStructure = options.context?.agents?.["updateDocumentStructure"];
8
- const allFeedback = [];
9
- let currentStructure = [...originalDocumentStructure];
10
- let isFirstAdd = true;
11
-
12
- printDocumentStructure(originalDocumentStructure);
13
-
14
- // update website structure
15
- if (!options.context.userContext) {
16
- options.context.userContext = {};
17
- }
18
-
19
- // Add document
20
- while (true) {
21
- let feedback = await options.prompts.input({
22
- message: isFirstAdd
23
- ? "You can add a new document.\n" +
24
- " • e.g. Add a new document 'Troubleshooting'\n\n" +
25
- "Press Enter to finish:"
26
- : "You can continue adding documents, or press Enter to finish:",
27
- });
28
-
29
- feedback = feedback.trim();
30
-
31
- // end the loop
32
- if (!feedback) {
33
- break;
34
- }
35
-
36
- try {
37
- // validate feedback
38
- const { intentType } = await options.context.invoke(analyzeIntent, {
39
- feedback,
40
- });
41
-
42
- if (intentType !== "add") {
43
- console.log(`⚠️ You can only add documents at this stage.`);
44
- continue;
45
- }
46
- options.context.userContext.currentStructure = currentStructure;
47
-
48
- const structureRules = getActiveRulesForScope("structure", []);
49
- const globalRules = getActiveRulesForScope("global", []);
50
- const allApplicableRules = [...structureRules, ...globalRules];
51
- const userPreferences = allApplicableRules.map((rule) => rule.rule).join("\n\n");
52
-
53
- await options.context.invoke(updateDocumentStructure, {
54
- ...input,
55
- dataSourceChunk: input.dataSources[0].dataSourceChunk,
56
- feedback,
57
- documentStructure: currentStructure,
58
- needDataSources: true,
59
- userPreferences,
60
- });
61
-
62
- allFeedback.push(feedback);
63
-
64
- currentStructure = options.context.userContext.currentStructure;
65
- printDocumentStructure(currentStructure);
66
- isFirstAdd = false;
67
- } catch (error) {
68
- console.error("Error processing feedback:", {
69
- type: error.name,
70
- message: error.message,
71
- });
72
- process.exit(0);
73
- }
74
- }
75
-
76
- if (currentStructure.length > originalDocumentStructure.length) {
77
- const originalPaths = new Set(originalDocumentStructure.map((doc) => doc.path));
78
- const newDocuments = currentStructure.filter((doc) => !originalPaths.has(doc.path));
79
-
80
- return {
81
- originalDocumentStructure: currentStructure,
82
- documentStructure: JSON.parse(JSON.stringify(currentStructure)),
83
- newDocuments,
84
- allFeedback,
85
- };
86
- } else {
87
- console.log("No documents were added");
88
- process.exit(0);
89
- }
90
- }
@@ -1,47 +0,0 @@
1
- name: findDocumentsToAddLinks
2
- description: Use AI to analyze document structure and determine which documents should reference newly added documents
3
- task_render_mode: hide
4
- instructions:
5
- - role: system
6
- url: ../../../prompts/structure/find-documents-to-add-links.md
7
- input_schema:
8
- type: object
9
- properties:
10
- originalDocumentStructure:
11
- type: array
12
- description: Original document structure before adding documents
13
- documentStructure:
14
- type: array
15
- description: Updated document structure after adding documents
16
- newDocuments:
17
- type: array
18
- description: Array of newly added documents
19
- required:
20
- - originalDocumentStructure
21
- - documentStructure
22
- - newDocuments
23
- output_schema:
24
- type: object
25
- properties:
26
- documentsWithNewLinks:
27
- type: array
28
- description: Array of existing documents that should add links to new documents
29
- items:
30
- type: object
31
- properties:
32
- path:
33
- type: string
34
- description: The path of the existing document that should be updated
35
- newLinks:
36
- type: array
37
- description: Array of new document paths that should be added as links to this document
38
- items:
39
- type: string
40
- required:
41
- - path
42
- - newLinks
43
- required:
44
- - documentsWithNewLinks
45
-
46
-
47
-
@@ -1,46 +0,0 @@
1
- type: team
2
- name: userAddDocument
3
- description: Add documents to the documentation structure
4
- skills:
5
- - url: ../../init/index.mjs
6
- default_input:
7
- skipIfExists: true
8
- - ../../utils/load-sources.mjs
9
- - ./add-documents-to-structure.mjs
10
- - url: ../../utils/save-output.mjs
11
- default_input:
12
- saveKey: documentStructure
13
- savePath:
14
- $get: outputDir
15
- fileName: structure-plan.json
16
- - ../../utils/save-sidebar.mjs
17
- - ../../utils/ensure-document-icons.mjs
18
- - ../../utils/format-document-structure.mjs
19
- - ../../media/load-media-description.mjs
20
- - type: team
21
- skills:
22
- - ../../update/check-document.mjs
23
- iterate_on: newDocuments
24
- concurrency: 5
25
- - ./find-documents-to-add-links.yaml
26
- - ./review-documents-with-new-links.mjs
27
- - type: team
28
- name: batchAddNewLinks
29
- description: Batch add new links to documents
30
- skills:
31
- - ../utils/init-current-content.mjs
32
- - ../../utils/transform-detail-data-sources.mjs
33
- - ../../update/update-single/update-single-document-detail.mjs
34
- iterate_on: documentsToUpdate
35
- concurrency: 5
36
- - ./prepare-documents-to-translate.mjs
37
- - type: team
38
- name: batchTranslateDocuments
39
- description: Batch translate documents to multiple languages
40
- skills:
41
- - ../../localize/translate-multilingual.yaml
42
- iterate_on: documentsToTranslate
43
- concurrency: 5
44
- - ../../utils/post-generate.mjs
45
- - ./print-add-document-summary.mjs
46
- mode: sequential
@@ -1,22 +0,0 @@
1
- export default async function prepareDocumentsToTranslate(input, options) {
2
- const { documentsWithNewLinks = [] } = input;
3
- const documentsToTranslate = [];
4
-
5
- documentsWithNewLinks.forEach((doc) => {
6
- const content = options.context.userContext.currentContents[doc.path];
7
-
8
- if (content) {
9
- documentsToTranslate.push({
10
- ...doc,
11
- content,
12
- });
13
- } else {
14
- console.warn(`⚠️ Could not find content from userContext at path: ${doc.path}`);
15
- }
16
- });
17
-
18
- return {
19
- documentsToUpdate: [], // clear, reduce token consumption
20
- documentsToTranslate,
21
- };
22
- }
@@ -1,63 +0,0 @@
1
- import chalk from "chalk";
2
-
3
- import { recordUpdate } from "../../../utils/history-utils.mjs";
4
- /**
5
- * Print summary of added documents and documents with new links
6
- */
7
- export default async function printAddDocumentSummary({
8
- newDocuments = [],
9
- documentsWithNewLinks = [],
10
- allFeedback = [],
11
- }) {
12
- let message = `\n---\n`;
13
- message += `${chalk.bold.cyan("📊 Summary")}\n\n`;
14
-
15
- // Record the update
16
- if (allFeedback.length > 0) {
17
- recordUpdate({
18
- operation: "structure_update",
19
- feedback: allFeedback.join("\n"),
20
- });
21
- }
22
-
23
- // Display added documents
24
- if (newDocuments && newDocuments.length > 0) {
25
- message += `✨ Added Documents:\n`;
26
- message += ` Total: ${newDocuments.length} document(s)\n\n`;
27
- newDocuments.forEach((doc, index) => {
28
- message += ` ${chalk.cyan(`${index + 1}. ${doc.path}`)}`;
29
- if (doc.title && doc.title !== doc.path) {
30
- message += ` - ${chalk.yellow(doc.title)}`;
31
- }
32
- message += `\n\n`;
33
- });
34
- } else {
35
- message += `✨ Added Documents:\n`;
36
- message += `${chalk.gray(" No documents were added.\n\n")}`;
37
- }
38
-
39
- // Display documents with new links
40
- if (documentsWithNewLinks && documentsWithNewLinks.length > 0) {
41
- message += `✅ Documents updated (Added new links):\n`;
42
- message += ` Total: ${documentsWithNewLinks.length} document(s)\n\n`;
43
- documentsWithNewLinks.forEach((doc, index) => {
44
- message += ` ${chalk.cyan(`${index + 1}. ${doc.path}`)}`;
45
- if (doc.title && doc.title !== doc.path) {
46
- message += ` - ${chalk.yellow(doc.title)}`;
47
- }
48
- message += `\n`;
49
- if (doc.newLinks && doc.newLinks.length > 0) {
50
- message += ` New links added: ${chalk.gray(doc.newLinks.join(", "))}\n`;
51
- }
52
- message += `\n`;
53
- });
54
- } else {
55
- message += `✅ Documents updated (Added new links):\n`;
56
- message += `${chalk.gray(" No documents needed to be updated.\n\n")}`;
57
- }
58
-
59
- return { message };
60
- }
61
-
62
- printAddDocumentSummary.taskTitle = "Print add document summary";
63
- printAddDocumentSummary.description = "Display summary of added documents";
@@ -1,110 +0,0 @@
1
- import { join } from "node:path";
2
- import chalk from "chalk";
3
- import pLimit from "p-limit";
4
- import { generateFileName, pathToFlatName } from "../../../utils/docs-finder-utils.mjs";
5
- import { pathExists } from "../../../utils/file-utils.mjs";
6
-
7
- /**
8
- * Review documentsWithNewLinks and let user select which documents should be updated
9
- */
10
- export default async function reviewDocumentsWithNewLinks(
11
- { documentsWithNewLinks = [], documentStructure = [], locale = "en", docsDir },
12
- options,
13
- ) {
14
- // If no documents to review, return empty array
15
- if (!documentsWithNewLinks || documentsWithNewLinks.length === 0) {
16
- return { documentsWithNewLinks: [], documentsToUpdate: [] };
17
- }
18
-
19
- // Build choices with file existence check
20
- const limit = pLimit(50);
21
- const choices = await Promise.all(
22
- documentsWithNewLinks.map((document, index) =>
23
- limit(async () => {
24
- // Find corresponding document in documentStructure to get title
25
- const structureDoc = documentStructure.find((item) => item.path === document.path);
26
- const title = structureDoc?.title || document.path;
27
-
28
- // Generate filename from document path
29
- const flatName = pathToFlatName(document.path);
30
- const filename = generateFileName(flatName, locale);
31
-
32
- // Check file existence if docsDir is provided
33
- let fileExists = true;
34
- let missingFileText = "";
35
- if (docsDir) {
36
- const filePath = join(docsDir, filename);
37
- fileExists = await pathExists(filePath);
38
- if (!fileExists) {
39
- missingFileText = chalk.red(" - file not found");
40
- }
41
- }
42
-
43
- return {
44
- name: `${title} (${filename})${missingFileText}`,
45
- value: index,
46
- checked: fileExists, // Only check if file exists
47
- disabled: !fileExists, // Disable if file doesn't exist
48
- description: `New Links: ${document.newLinks.join(", ")}`,
49
- };
50
- }),
51
- ),
52
- );
53
-
54
- // Let user select which documents to update (default: all selected)
55
- const selectedDocs = await options.prompts.checkbox({
56
- message:
57
- "Select documents that need new links added (all selected by default, press Enter to confirm, or unselect all to skip):",
58
- choices,
59
- });
60
-
61
- // Filter documentsWithNewLinks based on user selection
62
- const filteredDocs = selectedDocs.map((index) => documentsWithNewLinks[index]).filter(Boolean);
63
-
64
- if (filteredDocs.length === 0) {
65
- console.log(`\n⚠️ No documents selected. Skipping link updates.\n`);
66
- } else {
67
- console.log(
68
- `\n✅ Selected ${filteredDocs.length} out of ${documentsWithNewLinks.length} documents to update.\n`,
69
- );
70
- }
71
-
72
- // save original documentsWithNewLinks to user context
73
- options.context.userContext.originalDocumentsWithNewLinks = filteredDocs;
74
-
75
- if (filteredDocs.length === 0) {
76
- return {
77
- documentsWithNewLinks: [],
78
- documentsToUpdate: [],
79
- };
80
- }
81
-
82
- // Prepare documents: add necessary fields for update (e.g. feedback)
83
- const preparedDocs = [];
84
-
85
- for (const doc of filteredDocs) {
86
- if (!doc.path) continue;
87
-
88
- // Find corresponding document in documentStructure to get additional fields
89
- const structureDoc = documentStructure.find((item) => item.path === doc.path);
90
-
91
- // Generate feedback message for adding new links
92
- const newLinksList = doc.newLinks.join(", ");
93
- const feedback = `Add the following links to this document: ${newLinksList}. Identify suitable places within the existing content — such as relevant sections, navigation items — and insert the links naturally to maintain context and readability.`;
94
-
95
- preparedDocs.push({
96
- ...structureDoc,
97
- feedback,
98
- newLinks: doc.newLinks,
99
- });
100
- }
101
-
102
- return {
103
- documentsWithNewLinks: preparedDocs, // for print summary
104
- documentsToUpdate: JSON.parse(JSON.stringify(preparedDocs)), // for batch update
105
- };
106
- }
107
-
108
- reviewDocumentsWithNewLinks.taskTitle = "Review documents to update";
109
- reviewDocumentsWithNewLinks.description =
110
- "Let the user review and select which documents should be updated with new links";
@@ -1,78 +0,0 @@
1
- import { join } from "node:path";
2
- import {
3
- buildAllowedLinksFromStructure,
4
- generateFileName,
5
- pathToFlatName,
6
- readFileContent,
7
- } from "../../../utils/docs-finder-utils.mjs";
8
- import { pathExists } from "../../../utils/file-utils.mjs";
9
- import { checkMarkdown, getLinkFromError } from "../../../utils/markdown-checker.mjs";
10
-
11
- export default async function findDocumentsWithInvalidLinks({
12
- documentStructure = [],
13
- docsDir,
14
- locale = "en",
15
- }) {
16
- if (!Array.isArray(documentStructure) || documentStructure.length === 0) {
17
- return {
18
- documentsWithInvalidLinks: [],
19
- };
20
- }
21
-
22
- if (!docsDir) {
23
- return {
24
- documentsWithInvalidLinks: [],
25
- error: "docsDir is required to check document links",
26
- };
27
- }
28
-
29
- // Check each document for invalid links
30
- const allowedLinks = buildAllowedLinksFromStructure(documentStructure);
31
- const documentsWithInvalidLinks = [];
32
-
33
- for (const doc of documentStructure) {
34
- if (!doc.path) continue;
35
-
36
- // Generate filename from document path
37
- const flatName = pathToFlatName(doc.path);
38
- const fileName = generateFileName(flatName, locale);
39
-
40
- // Check if file exists before reading
41
- const filePath = join(docsDir, fileName);
42
- const fileExists = await pathExists(filePath);
43
-
44
- if (!fileExists) {
45
- // Skip if file doesn't exist
46
- continue;
47
- }
48
-
49
- // Read document content
50
- const content = await readFileContent(docsDir, fileName);
51
-
52
- if (!content) {
53
- // Skip if content cannot be read
54
- continue;
55
- }
56
-
57
- // Use checkMarkdown to check for dead links
58
- const allErrors = await checkMarkdown(content, doc.path, {
59
- allowedLinks,
60
- baseDir: docsDir,
61
- });
62
-
63
- // Filter only dead link errors and extract invalid links
64
- const invalidLinks = allErrors.map(getLinkFromError).filter(Boolean);
65
-
66
- if (invalidLinks.length > 0) {
67
- documentsWithInvalidLinks.push({
68
- path: doc.path,
69
- title: doc.title || doc.path,
70
- invalidLinks,
71
- });
72
- }
73
- }
74
-
75
- return {
76
- documentsWithInvalidLinks,
77
- };
78
- }
@@ -1,40 +0,0 @@
1
- type: team
2
- name: userRemoveDocument
3
- description: Remove documents from the documentation structure
4
- skills:
5
- - url: ../../init/index.mjs
6
- default_input:
7
- skipIfExists: true
8
- - ../../utils/load-sources.mjs
9
- - ./remove-documents-from-structure.mjs
10
- - url: ../../utils/save-output.mjs
11
- default_input:
12
- saveKey: documentStructure
13
- savePath:
14
- $get: outputDir
15
- fileName: structure-plan.json
16
- - ../../utils/save-sidebar.mjs
17
- - ./find-documents-with-invalid-links.mjs
18
- - ./review-documents-with-invalid-links.mjs
19
- - ../../utils/format-document-structure.mjs
20
- - ../../media/load-media-description.mjs
21
- - type: team
22
- name: batchRemoveInvalidLinks
23
- description: Batch remove invalid links from documents
24
- skills:
25
- - ../utils/init-current-content.mjs
26
- - ../../utils/transform-detail-data-sources.mjs
27
- - ../../update/update-single/update-single-document-detail.mjs
28
- iterate_on: documentsToUpdate
29
- concurrency: 5
30
- - ./prepare-documents-to-translate.mjs
31
- - type: team
32
- name: batchTranslateDocuments
33
- description: Batch translate documents to multiple languages
34
- skills:
35
- - ../../localize/translate-multilingual.yaml
36
- iterate_on: documentsToTranslate
37
- concurrency: 5
38
- - ../../utils/post-generate.mjs
39
- - ./print-remove-document-summary.mjs
40
- mode: sequential
@@ -1,22 +0,0 @@
1
- export default async function prepareDocumentsToTranslate(input, options) {
2
- const { documentsWithInvalidLinks = [] } = input;
3
- const documentsToTranslate = [];
4
-
5
- documentsWithInvalidLinks.forEach((doc) => {
6
- const content = options.context.userContext.currentContents[doc.path];
7
-
8
- if (content) {
9
- documentsToTranslate.push({
10
- ...doc,
11
- content,
12
- });
13
- } else {
14
- console.warn(`⚠️ Could not find content from userContext at path: ${doc.path}`);
15
- }
16
- });
17
-
18
- return {
19
- documentsToUpdate: [], // clear, reduce token consumption
20
- documentsToTranslate,
21
- };
22
- }
@@ -1,53 +0,0 @@
1
- import chalk from "chalk";
2
-
3
- /**
4
- * Print summary of removed documents and documents with invalid links
5
- */
6
- export default async function printRemoveDocumentSummary({
7
- deletedDocuments = [],
8
- documentsWithInvalidLinks = [],
9
- }) {
10
- let message = `\n---\n`;
11
- message += `${chalk.bold.cyan("📊 Summary")}\n\n`;
12
-
13
- // Display removed documents
14
- if (deletedDocuments && deletedDocuments.length > 0) {
15
- message += `🗑️ Removed Documents:\n`;
16
- message += ` Total: ${deletedDocuments.length} document(s)\n\n`;
17
- deletedDocuments.forEach((doc, index) => {
18
- message += ` ${chalk.cyan(`${index + 1}. ${doc.path}`)}`;
19
- if (doc.title && doc.title !== doc.path) {
20
- message += ` - ${chalk.yellow(doc.title)}`;
21
- }
22
- message += `\n\n`;
23
- });
24
- } else {
25
- message += `🗑️ Removed Documents:\n`;
26
- message += `${chalk.gray(" No documents were removed.\n\n")}`;
27
- }
28
-
29
- // Display documents with invalid links
30
- if (documentsWithInvalidLinks && documentsWithInvalidLinks.length > 0) {
31
- message += `✅ Documents fixed (Removed invalid links):\n`;
32
- message += ` Total: ${documentsWithInvalidLinks.length} document(s)\n\n`;
33
- documentsWithInvalidLinks.forEach((doc, index) => {
34
- message += ` ${chalk.cyan(`${index + 1}. ${doc.path}`)}`;
35
- if (doc.title && doc.title !== doc.path) {
36
- message += ` - ${chalk.yellow(doc.title)}`;
37
- }
38
- message += `\n`;
39
- if (doc.invalidLinks && doc.invalidLinks.length > 0) {
40
- message += ` Invalid links fixed: ${chalk.gray(doc.invalidLinks.join(", "))}\n`;
41
- }
42
- message += `\n`;
43
- });
44
- } else {
45
- message += `✅ Documents fixed (Removed invalid links):\n`;
46
- message += `${chalk.gray(" No documents needed to be fixed.\n\n")}`;
47
- }
48
-
49
- return { message };
50
- }
51
-
52
- printRemoveDocumentSummary.taskTitle = "Print remove document summary";
53
- printRemoveDocumentSummary.description = "Display summary of removed documents";
@@ -1,99 +0,0 @@
1
- import deleteDocument from "../document-structure-tools/delete-document.mjs";
2
- import { buildDocumentTree, buildChoicesFromTree } from "../../../utils/docs-finder-utils.mjs";
3
-
4
- export default async function removeDocumentsFromStructure(input = {}, options = {}) {
5
- const { originalDocumentStructure, locale = "en", docsDir } = input;
6
-
7
- if (!Array.isArray(originalDocumentStructure) || originalDocumentStructure.length === 0) {
8
- console.warn(
9
- "🗑️ Remove Documents\n • No document structure found. Please generate documents first.",
10
- );
11
- process.exit(0);
12
- }
13
-
14
- // Initialize currentStructure in userContext
15
- options.context.userContext.currentStructure = [...originalDocumentStructure];
16
-
17
- // Build tree structure
18
- const { rootNodes } = buildDocumentTree(originalDocumentStructure);
19
-
20
- // Build choices with tree structure visualization
21
- const choices = await buildChoicesFromTree(rootNodes, "", 0, { locale, docsDir });
22
-
23
- // Let user select documents to delete
24
- let selectedPaths = [];
25
- try {
26
- selectedPaths = await options.prompts.checkbox({
27
- message: "Select documents to remove (Press Enter with no selection to finish):",
28
- choices,
29
- });
30
- } catch {
31
- // User cancelled or no selection made
32
- console.log("No documents were removed.");
33
- process.exit(0);
34
- }
35
-
36
- // If no documents selected, exit
37
- if (!selectedPaths || selectedPaths.length === 0) {
38
- console.log("No documents were removed.");
39
- process.exit(0);
40
- }
41
-
42
- // Delete each selected document with cascade deletion
43
- const deletedDocuments = [];
44
- const errors = [];
45
-
46
- for (const path of selectedPaths) {
47
- try {
48
- const deleteResult = await deleteDocument(
49
- {
50
- path,
51
- recursive: true,
52
- },
53
- options,
54
- );
55
-
56
- if (deleteResult.error) {
57
- errors.push({
58
- path,
59
- error: deleteResult.error.message,
60
- });
61
- } else {
62
- deletedDocuments.push(...deleteResult.deletedDocuments);
63
- }
64
- } catch (error) {
65
- errors.push({
66
- path,
67
- error: error.message,
68
- });
69
- }
70
- }
71
-
72
- // Check if there are errors
73
- if (errors.length > 0) {
74
- console.warn(
75
- `🗑️ Remove Documents\n • Failed to remove documents:\n${errors
76
- .map((e) => ` - ${e.path}: ${e.error}`)
77
- .join("\n")}`,
78
- );
79
- process.exit(0);
80
- }
81
-
82
- if (deletedDocuments.length === 0) {
83
- console.log("No documents were removed.");
84
- process.exit(0);
85
- }
86
-
87
- // Get final updated document structure
88
- const updatedStructure = options.context.userContext.currentStructure;
89
-
90
- return {
91
- documentStructure: updatedStructure,
92
- originalDocumentStructure: JSON.parse(JSON.stringify(updatedStructure)),
93
- deletedDocuments,
94
- };
95
- }
96
-
97
- removeDocumentsFromStructure.taskTitle = "Remove documents from structure";
98
- removeDocumentsFromStructure.description =
99
- "Select and remove documents from the documentation structure";