@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,51 +0,0 @@
1
- type: team
2
- name: translateMultilingual
3
- description: Batch translate documents to multiple languages
4
- skills:
5
- - type: team
6
- task_render_mode: collapse
7
- name: translate
8
- skills:
9
- - url: ../utils/find-user-preferences-by-path.mjs
10
- default_input:
11
- scope: translation
12
- - ../localize/translate-document.yaml
13
- - type: transform
14
- jsonata: |
15
- $merge([
16
- $,
17
- { "reviewContent": translation }
18
- ])
19
- reflection:
20
- reviewer: ../utils/check-detail-result.mjs
21
- is_approved: isApproved
22
- max_iterations: 5
23
- return_last_on_max_iterations: true
24
- task_title: Translate '{{ title }}' to '{{ language }}'
25
- - ../utils/save-doc-translation.mjs
26
- input_schema:
27
- type: object
28
- properties:
29
- translates:
30
- type: array
31
- items:
32
- type: object
33
- properties:
34
- language:
35
- type: string
36
- content:
37
- type: string
38
- output_schema:
39
- type: object
40
- properties:
41
- translates:
42
- type: array
43
- items:
44
- type: object
45
- properties:
46
- language:
47
- type: string
48
- translation:
49
- type: string
50
- iterate_on: translates
51
- concurrency: 3
@@ -1,46 +0,0 @@
1
- type: team
2
- name: batchGenerateMediaDescription
3
- description: Batch generate media (image/video) descriptions with concurrency
4
- skills:
5
- - url: ./generate-media-description.yaml
6
- task_render_mode: collapse
7
- task_title: Generate Media Description
8
- input_schema:
9
- type: object
10
- properties:
11
- mediaToDescribe:
12
- type: array
13
- items:
14
- type: object
15
- properties:
16
- name:
17
- type: string
18
- width:
19
- type: number
20
- height:
21
- type: number
22
- hash:
23
- type: string
24
- path:
25
- type: string
26
- type:
27
- type: string
28
- svgContent:
29
- type: string
30
- mediaFile:
31
- type: array
32
- items:
33
- type: object
34
- properties:
35
- type:
36
- type: string
37
- path:
38
- type: string
39
- filename:
40
- type: string
41
- mimeType:
42
- type: string
43
- description: Array of media files (images/videos) that need descriptions
44
- iterate_on: mediaToDescribe
45
- concurrency: 5
46
- mode: sequential
@@ -1,50 +0,0 @@
1
- name: generateMediaDescription
2
- description: Generate description for a single media file (image/video)
3
- model: gemini-2.5-flash
4
- modalities: ["text", "image"]
5
- instructions:
6
- - role: system
7
- url: ../../prompts/media/media-description/system-prompt.md
8
- - role: user
9
- url: ../../prompts/media/media-description/user-prompt.md
10
- input_file_key: mediaFile
11
- include_input_in_output: true
12
- input_schema:
13
- type: object
14
- properties:
15
- name:
16
- type: string
17
- description: Media file name
18
- width:
19
- type: number
20
- description: Media width in pixels
21
- height:
22
- type: number
23
- description: Media height in pixels
24
- hash:
25
- type: string
26
- path:
27
- type: string
28
- description: Media path
29
- type:
30
- type: string
31
- description: Media type (image/video)
32
- svgContent:
33
- type: string
34
- description: SVG content
35
- mediaFile:
36
- type: array
37
- items:
38
- type: object
39
- properties:
40
- type:
41
- type: string
42
- path:
43
- type: string
44
- filename:
45
- type: string
46
- mimeType:
47
- type: string
48
- required:
49
- - name
50
- output_key: description
@@ -1,256 +0,0 @@
1
- import { createHash } from "node:crypto";
2
- import { existsSync } from "node:fs";
3
- import { mkdir, readFile, stat, writeFile } from "node:fs/promises";
4
- import path from "node:path";
5
- import { parse, stringify } from "yaml";
6
- import { getMediaDescriptionCachePath } from "../../utils/file-utils.mjs";
7
-
8
- const SIZE_THRESHOLD = 10 * 1024 * 1024; // 10MB
9
- const SVG_SIZE_THRESHOLD = 50 * 1024; // 50KB for SVG files
10
-
11
- // Supported MIME types for Gemini AI
12
- const SUPPORTED_IMAGE_TYPES = new Set([
13
- "image/png",
14
- "image/jpeg",
15
- "image/webp",
16
- "image/heic",
17
- "image/heif",
18
- ]);
19
-
20
- const SUPPORTED_SVG_TYPES = new Set(["image/svg+xml"]);
21
-
22
- const SUPPORTED_VIDEO_TYPES = new Set([
23
- "video/mp4",
24
- "video/mpeg",
25
- "video/mov",
26
- "video/avi",
27
- "video/x-flv",
28
- "video/mpg",
29
- "video/webm",
30
- "video/wmv",
31
- "video/3gpp",
32
- ]);
33
-
34
- /**
35
- * Calculate hash for a media file
36
- * For files < 10MB: use file content
37
- * For files >= 10MB: use path + size + mtime to avoid memory issues
38
- * @param {string} absolutePath - The absolute path to the media file
39
- * @returns {Promise<string>} - The hash of the file
40
- */
41
- async function calculateMediaHash(absolutePath) {
42
- const stats = await stat(absolutePath);
43
-
44
- if (stats.size < SIZE_THRESHOLD) {
45
- // Small file: use full content
46
- const content = await readFile(absolutePath);
47
- return createHash("sha256").update(content).digest("hex");
48
- }
49
-
50
- // Large file: use path + size + mtime
51
- const hashInput = `${absolutePath}:${stats.size}:${stats.mtimeMs}`;
52
- return createHash("sha256").update(hashInput).digest("hex");
53
- }
54
-
55
- /**
56
- * Load media descriptions from cache and generate new ones if needed
57
- * @param {Object} input - Input parameters
58
- * @param {Array} input.mediaFiles - Array of media file objects from load-sources
59
- * @param {string} input.docsDir - Base directory for documentation
60
- * @param {Object} options - Agent options
61
- * @returns {Promise<Object>} - Updated assetsContent with media descriptions
62
- */
63
- export default async function loadMediaDescription(input, options) {
64
- const { mediaFiles = [], docsDir } = input;
65
-
66
- // Filter to get image, video and svg files with supported MIME types
67
- const mediaFilesToProcess = mediaFiles.filter((file) => {
68
- if (file.type === "image") {
69
- return SUPPORTED_IMAGE_TYPES.has(file.mimeType) || SUPPORTED_SVG_TYPES.has(file.mimeType);
70
- }
71
- if (file.type === "video") {
72
- return SUPPORTED_VIDEO_TYPES.has(file.mimeType);
73
- }
74
- return false;
75
- });
76
-
77
- // Path to media description cache file
78
- const cacheFilePath = getMediaDescriptionCachePath();
79
-
80
- // Load existing cache
81
- let cache = {};
82
- if (existsSync(cacheFilePath)) {
83
- try {
84
- const cacheContent = await readFile(cacheFilePath, "utf8");
85
- const parsedCache = parse(cacheContent);
86
- cache = parsedCache?.descriptions || {};
87
- } catch (error) {
88
- console.warn("Failed to read media description cache:", error.message);
89
- }
90
- }
91
-
92
- // Find media files without descriptions
93
- const mediaToDescribe = [];
94
- const mediaHashMap = new Map();
95
-
96
- const absoluteDocsDir = path.resolve(process.cwd(), docsDir);
97
-
98
- // Only process media files that need AI description
99
- for (const mediaFile of mediaFilesToProcess) {
100
- // Convert relative path to absolute path for consistent hashing
101
- // mediaFiles.path is relative to docsDir
102
- const absolutePath = path.join(absoluteDocsDir, mediaFile.path);
103
- const mediaHash = await calculateMediaHash(absolutePath);
104
- mediaHashMap.set(mediaFile.path, mediaHash);
105
-
106
- if (!cache[mediaHash]) {
107
- const isSvg = SUPPORTED_SVG_TYPES.has(mediaFile.mimeType);
108
-
109
- if (isSvg) {
110
- // For SVG files, check size and read content
111
- try {
112
- const stats = await stat(absolutePath);
113
- if (stats.size > SVG_SIZE_THRESHOLD) {
114
- console.warn(
115
- `SVG file ${mediaFile.path} exceeds ${SVG_SIZE_THRESHOLD / 1024}KB limit, skipping`,
116
- );
117
- continue;
118
- }
119
-
120
- const svgContent = await readFile(absolutePath, "utf8");
121
- mediaToDescribe.push({
122
- ...mediaFile,
123
- hash: mediaHash,
124
- path: mediaFile.path,
125
- svgContent,
126
- });
127
- } catch (error) {
128
- console.warn(`Failed to read SVG file ${mediaFile.path}:`, error.message);
129
- }
130
- } else {
131
- // For non-SVG media files, use mediaFile field
132
- mediaToDescribe.push({
133
- ...mediaFile,
134
- hash: mediaHash,
135
- path: mediaFile.path,
136
- mediaFile: [
137
- {
138
- type: "local",
139
- path: absolutePath,
140
- filename: mediaFile.name,
141
- mimeType: mediaFile.mimeType,
142
- },
143
- ],
144
- });
145
- }
146
- }
147
- }
148
-
149
- // Generate descriptions for media files without cache - use team agent for concurrent processing
150
- const newDescriptions = {};
151
- if (mediaToDescribe.length > 0) {
152
- try {
153
- // Use batch team agent for concurrent processing
154
- const results = await options.context.invoke(
155
- options.context.agents["batchGenerateMediaDescription"],
156
- {
157
- mediaToDescribe,
158
- },
159
- );
160
-
161
- // Process results - results is an array of individual results
162
- if (Array.isArray(results?.mediaToDescribe)) {
163
- for (const result of results.mediaToDescribe) {
164
- if (result?.hash && result?.description) {
165
- newDescriptions[result.hash] = {
166
- path: result.path,
167
- description: result.description,
168
- generatedAt: new Date().toISOString(),
169
- };
170
- }
171
- }
172
- }
173
-
174
- // Merge new descriptions into cache
175
- Object.assign(cache, newDescriptions);
176
-
177
- // Save updated cache
178
- await mkdir(path.dirname(cacheFilePath), { recursive: true });
179
- const cacheYaml = stringify({
180
- descriptions: cache,
181
- lastUpdated: new Date().toISOString(),
182
- });
183
- await writeFile(cacheFilePath, cacheYaml, "utf8");
184
-
185
- console.log(`Generated descriptions for ${Object.keys(newDescriptions).length} media files`);
186
- } catch (error) {
187
- console.error("Failed to generate media descriptions:", error.message);
188
- }
189
- }
190
-
191
- // Build enhanced assetsContent with descriptions
192
- let enhancedAssetsContent;
193
-
194
- if (mediaFiles.length > 0) {
195
- enhancedAssetsContent = "# Available Media Assets for Documentation\n\n";
196
- const assets = mediaFiles.map((x) => {
197
- const mediaHash = mediaHashMap.get(x.path);
198
- const description = cache[mediaHash]?.description;
199
- const result = {
200
- name: x.name,
201
- path: x.path,
202
- };
203
- if (description) {
204
- result.description = description;
205
- }
206
- return result;
207
- });
208
- enhancedAssetsContent += stringify(assets);
209
- }
210
-
211
- return {
212
- ...input,
213
- assetsContent: enhancedAssetsContent,
214
- mediaFiles,
215
- };
216
- }
217
-
218
- loadMediaDescription.input_schema = {
219
- type: "object",
220
- properties: {
221
- mediaFiles: {
222
- type: "array",
223
- items: {
224
- type: "object",
225
- properties: {
226
- name: { type: "string" },
227
- path: { type: "string" },
228
- type: { type: "string" },
229
- width: { type: "number" },
230
- height: { type: "number" },
231
- mimeType: { type: "string" },
232
- },
233
- },
234
- description: "Array of media file objects (images/videos)",
235
- },
236
- docsDir: {
237
- type: "string",
238
- description: "Base directory for documentation",
239
- },
240
- },
241
- required: ["mediaFiles", "docsDir"],
242
- };
243
-
244
- loadMediaDescription.output_schema = {
245
- type: "object",
246
- properties: {
247
- assetsContent: {
248
- type: "string",
249
- description: "Enhanced assets content with media descriptions",
250
- },
251
- mediaFiles: {
252
- type: "array",
253
- description: "Array of media file objects",
254
- },
255
- },
256
- };
@@ -1,203 +0,0 @@
1
- import { readPreferences, removeRule, writePreferences } from "../../utils/preferences-utils.mjs";
2
-
3
- /**
4
- * List all user preferences with formatted display
5
- * @returns {Object} Result with formatted message
6
- */
7
- function listPreferences() {
8
- const preferences = readPreferences();
9
-
10
- if (preferences.rules.length === 0) {
11
- return { message: "No saved preferences found." };
12
- }
13
-
14
- let message = "# User Preferences\n\n";
15
-
16
- // Add format explanation
17
- message += "**Format explanation:**\n";
18
- message += "- 🟢 = Active preference, ⚪ = Inactive preference\n";
19
- message += "- [scope] = Preference scope (global, structure, document, translation)\n";
20
- message += "- ID = Unique preference identifier\n";
21
- message += "- Paths = Specific file paths (if applicable)\n\n";
22
-
23
- preferences.rules.forEach((rule) => {
24
- const status = rule.active ? "🟢" : "⚪";
25
- const pathsInfo = rule.paths ? ` | Paths: ${rule.paths.join(", ")}` : "";
26
-
27
- // First line: status, scope, ID and paths info
28
- message += `${status} [${rule.scope}] ${rule.id}${pathsInfo}\n`;
29
-
30
- // Second line: rule content (truncated if too long)
31
- const maxRuleLength = 120;
32
- const ruleText =
33
- rule.rule.length > maxRuleLength ? `${rule.rule.substring(0, maxRuleLength)}...` : rule.rule;
34
- message += ` ${ruleText}\n `;
35
-
36
- // Add blank line after each record
37
- message += `\n`;
38
- });
39
-
40
- return { message };
41
- }
42
-
43
- /**
44
- * Remove preferences by IDs or interactive selection
45
- * @param {string[]} id - Array of preference IDs to remove
46
- * @param {Object} options - Options with prompts interface
47
- * @returns {Object} Result with success message
48
- */
49
- async function removePreferences(id, options) {
50
- const preferences = readPreferences();
51
- let targetIds = id;
52
-
53
- if (!targetIds || targetIds.length === 0) {
54
- // Interactive selection
55
- if (preferences.rules.length === 0) {
56
- return { message: "No preferences available to remove." };
57
- }
58
-
59
- const choices = preferences.rules.map((rule) => ({
60
- name: `${rule.active ? "🟢" : "⚪"} [${rule.scope}] ${rule.rule.substring(0, 60)}${rule.rule.length > 60 ? "..." : ""}`,
61
- value: rule.id,
62
- description: `ID: ${rule.id}`,
63
- }));
64
-
65
- targetIds = await options.prompts.checkbox({
66
- message: "Choose preferences to delete:",
67
- choices,
68
- validate: (answer) => {
69
- if (answer.length === 0) {
70
- return "Please choose at least one preference to delete";
71
- }
72
- return true;
73
- },
74
- });
75
-
76
- if (!targetIds || targetIds.length === 0) {
77
- return { message: "No preferences selected for deletion." };
78
- }
79
- }
80
-
81
- // Process the target IDs
82
- const results = [];
83
- for (const ruleId of targetIds) {
84
- const success = removeRule(ruleId);
85
- results.push({ id: ruleId, success });
86
- }
87
-
88
- const successCount = results.filter((r) => r.success).length;
89
- const failedCount = targetIds.length - successCount;
90
- const message =
91
- failedCount > 0
92
- ? `Successfully removed ${successCount} preferences, ${failedCount} failed.`
93
- : `Successfully removed ${successCount} preferences.`;
94
-
95
- return { message };
96
- }
97
-
98
- /**
99
- * Toggle preferences active status by IDs or interactive selection
100
- * @param {string[]} id - Array of preference IDs to toggle
101
- * @param {Object} options - Options with prompts interface
102
- * @returns {Object} Result with success message
103
- */
104
- async function togglePreferences(id, options) {
105
- const preferences = readPreferences();
106
- let targetIds = id;
107
-
108
- if (!targetIds || targetIds.length === 0) {
109
- // Interactive selection
110
- if (preferences.rules.length === 0) {
111
- return { message: "No preferences available to toggle." };
112
- }
113
-
114
- const choices = preferences.rules.map((rule) => ({
115
- name: `${rule.active ? "🟢" : "⚪"} [${rule.scope}] ${rule.rule.substring(0, 60)}${rule.rule.length > 60 ? "..." : ""}`,
116
- value: rule.id,
117
- description: `ID: ${rule.id}`,
118
- }));
119
-
120
- targetIds = await options.prompts.checkbox({
121
- message: "Choose preferences to enable/disable:",
122
- choices,
123
- validate: (answer) => {
124
- if (answer.length === 0) {
125
- return "Please choose at least one preference to toggle";
126
- }
127
- return true;
128
- },
129
- });
130
-
131
- if (!targetIds || targetIds.length === 0) {
132
- return { message: "No preferences selected to toggle." };
133
- }
134
- }
135
-
136
- // Process the target IDs
137
- const results = [];
138
- const prefs = readPreferences();
139
-
140
- for (const ruleId of targetIds) {
141
- const rule = prefs.rules.find((r) => r.id === ruleId);
142
- if (rule) {
143
- rule.active = !rule.active;
144
- results.push({ id: ruleId, success: true, newStatus: rule.active });
145
- } else {
146
- results.push({ id: ruleId, success: false, error: "Rule not found" });
147
- }
148
- }
149
-
150
- writePreferences(prefs);
151
-
152
- const successCount = results.filter((r) => r.success).length;
153
- const failedCount = targetIds.length - successCount;
154
- const message =
155
- failedCount > 0
156
- ? `Successfully toggled ${successCount} preferences, ${failedCount} failed.`
157
- : `Successfully toggled ${successCount} preferences.`;
158
-
159
- return { message };
160
- }
161
-
162
- export default async function prefs({ list, remove, toggle, id }, options) {
163
- if (list) {
164
- return listPreferences();
165
- }
166
-
167
- if (remove) {
168
- return await removePreferences(id, options);
169
- }
170
-
171
- if (toggle) {
172
- return await togglePreferences(id, options);
173
- }
174
-
175
- return { message: "Please choose an action: --list, --remove, or --toggle." };
176
- }
177
-
178
- prefs.input_schema = {
179
- type: "object",
180
- properties: {
181
- list: {
182
- type: "boolean",
183
- description: "Show all saved preferences",
184
- },
185
- remove: {
186
- type: "boolean",
187
- description: "Delete saved preferences",
188
- },
189
- toggle: {
190
- type: "boolean",
191
- description: "Enable/disable preferences",
192
- },
193
- id: {
194
- type: "array",
195
- items: {
196
- type: "string",
197
- },
198
- description: "Specific preference IDs to work with",
199
- },
200
- },
201
- };
202
-
203
- prefs.description = "Manage your saved documentation preferences";
@@ -1,26 +0,0 @@
1
- type: team
2
- name: publish
3
- alias:
4
- - pub
5
- - p
6
- description: Publish your documentation online
7
- skills:
8
- - url: ../init/index.mjs
9
- default_input:
10
- skipIfExists: true
11
- checkOnly: true
12
- - url: ../init/check.mjs
13
- - url: ../utils/load-sources.mjs
14
- - ../utils/save-sidebar.mjs
15
- - ../utils/ensure-document-icons.mjs
16
- - translate-meta.mjs
17
- - publish-docs.mjs
18
- input_schema:
19
- type: object
20
- properties:
21
- appUrl:
22
- type: string
23
- description: Website URL where docs will be published (optional - leave empty for interactive setup)
24
- with-branding:
25
- type: boolean
26
- description: Update your website branding (title, description, logo)