@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,46 +0,0 @@
1
- type: team
2
- name: evaluate
3
- description: Evaluate document quality
4
- skills:
5
- - url: ../init/index.mjs
6
- default_input:
7
- skipIfExists: true
8
- checkOnly: true
9
- - url: ../init/check.mjs
10
- - ../utils/load-sources.mjs
11
- - ../utils/format-document-structure.mjs
12
- - type: transform
13
- name: transformData
14
- task_render_mode: hide
15
- jsonata: |
16
- $merge([
17
- $,
18
- {
19
- "documentStructure": originalDocumentStructure
20
- }
21
- ])
22
- - ./document-structure.yaml
23
- - ../utils/load-all-document-content.mjs
24
- - type: team
25
- name: batchEvaluateDocument
26
- skills:
27
- - ../utils/load-document-all-content.mjs
28
- - ./document.yaml
29
- - ./code-snippet.mjs
30
- - type: transform
31
- task_render_mode: hide
32
- jsonata: |
33
- $merge([
34
- $
35
- ])
36
- iterate_on: originalDocumentStructure
37
- concurrency: 5
38
- mode: sequential
39
- - ./generate-report.mjs
40
- mode: sequential
41
- input_schema:
42
- type: object
43
- properties:
44
- open:
45
- type: boolean
46
- description: Auto open generated report
@@ -1,6 +0,0 @@
1
- name: "history"
2
- description: "View and manage document update history"
3
- tasks:
4
- - name: "view"
5
- description: "View update history in compact format"
6
- agent: "viewHistory"
@@ -1,78 +0,0 @@
1
- import { createHash } from "node:crypto";
2
- import chalk from "chalk";
3
- import { getHistory } from "../../utils/history-utils.mjs";
4
-
5
- export default function viewHistory() {
6
- const history = getHistory();
7
-
8
- if (!history.entries || history.entries.length === 0) {
9
- console.log(chalk.yellow("\nNo update history found\n"));
10
- return {};
11
- }
12
-
13
- console.log(chalk.cyan("\n📜 Update History\n"));
14
-
15
- history.entries.forEach((entry) => {
16
- // Format: <short-hash> <date> <operation> <feedback>
17
- const hash = generateShortHash(entry.timestamp);
18
- const date = formatRelativeDate(entry.timestamp);
19
- const operation = entry.operation;
20
-
21
- // Handle document path (now a string)
22
- const documentInfo = entry.documentPath ? chalk.dim(` (${entry.documentPath})`) : "";
23
-
24
- // Git-style oneline format
25
- console.log(
26
- `${chalk.yellow(hash)} ${chalk.dim(date)} ${chalk.cyan(operation)}${documentInfo}: ${entry.feedback}`,
27
- );
28
- });
29
-
30
- console.log(); // Empty line at end
31
-
32
- return {};
33
- }
34
-
35
- /**
36
- * Generate a short hash from timestamp (git-style)
37
- */
38
- function generateShortHash(timestamp) {
39
- // Create a deterministic hash from timestamp only
40
- // This ensures the same timestamp always produces the same hash
41
- const hash = createHash("sha1").update(timestamp).digest("hex");
42
- return hash.substring(0, 8); // First 8 chars of SHA1 hash
43
- }
44
-
45
- /**
46
- * Format date in relative time (git-style)
47
- */
48
- function formatRelativeDate(timestamp) {
49
- const date = new Date(timestamp);
50
- const now = new Date();
51
- const diffMs = now - date;
52
- const diffSecs = Math.floor(diffMs / 1000);
53
- const diffMins = Math.floor(diffSecs / 60);
54
- const diffHours = Math.floor(diffMins / 60);
55
- const diffDays = Math.floor(diffHours / 24);
56
-
57
- if (diffSecs < 60) {
58
- return `${diffSecs} seconds ago`;
59
- }
60
- if (diffMins < 60) {
61
- return `${diffMins} minute${diffMins === 1 ? "" : "s"} ago`;
62
- }
63
- if (diffHours < 24) {
64
- return `${diffHours} hour${diffHours === 1 ? "" : "s"} ago`;
65
- }
66
- if (diffDays < 7) {
67
- return `${diffDays} day${diffDays === 1 ? "" : "s"} ago`;
68
- }
69
- // Show actual date for older entries
70
- return date.toLocaleDateString("en-US", {
71
- month: "short",
72
- day: "numeric",
73
- year: date.getFullYear() !== now.getFullYear() ? "numeric" : undefined,
74
- });
75
- }
76
-
77
- viewHistory.description = "View update history in compact format";
78
- viewHistory.taskTitle = "View update history";
@@ -1,16 +0,0 @@
1
- import chalk from "chalk";
2
- import { getMainLanguageFiles } from "../../utils/docs-finder-utils.mjs";
3
-
4
- export default async function checkNeedGenerate({ docsDir, locale, documentStructure }) {
5
- const mainLanguageFiles = await getMainLanguageFiles(docsDir, locale, documentStructure);
6
-
7
- if (mainLanguageFiles.length === 0) {
8
- console.log(
9
- `No documents found in the docs directory. You can generate them with ${chalk.yellow("`aigne doc create`")}`,
10
- );
11
- process.exit(0);
12
- }
13
- return {
14
- message: 'Documents found in the docs directory, skipping "create" step',
15
- };
16
- }
@@ -1,275 +0,0 @@
1
- import { mkdir, readFile, writeFile } from "node:fs/promises";
2
- import { dirname, join } from "node:path";
3
- import chalk from "chalk";
4
- import { stringify as yamlStringify } from "yaml";
5
- import {
6
- DEFAULT_REASONING_EFFORT_LEVEL,
7
- DEFAULT_THINKING_EFFORT_LEVEL,
8
- DIAGRAM_STYLES,
9
- } from "../../utils/constants/index.mjs";
10
- import loadConfig from "../../utils/load-config.mjs";
11
- import { detectSystemLanguage, getProjectInfo } from "../../utils/utils.mjs";
12
- import mapReasoningEffortLevel from "../utils/map-reasoning-effort-level.mjs";
13
- import { validateDocDir } from "./validate.mjs";
14
-
15
- /**
16
- * Guides the user through a multi-turn dialog to generate a YAML configuration file.
17
- * @param {Object} params
18
- * @param {string} params.outputPath - The path to the output file.
19
- * @param {string} params.fileName - The name of the file.
20
- * @returns {Promise<Object>}
21
- */
22
- export default async function init(input, options) {
23
- const config = await _init(input, options);
24
-
25
- // Set thinking effort (lite/standard/pro) and map to reasoningEffort
26
- options.context.userContext.thinkingEffort =
27
- config.thinking?.effort || DEFAULT_THINKING_EFFORT_LEVEL;
28
-
29
- // Set global reasoningEffort based on thinkingEffort
30
- options.context.userContext.reasoningEffort = mapReasoningEffortLevel(
31
- { level: DEFAULT_REASONING_EFFORT_LEVEL },
32
- options,
33
- )?.reasoningEffort;
34
-
35
- // for translation agent
36
- if (config.translateLanguages) {
37
- config.translates = config.translateLanguages.map((lang) => ({ language: lang }));
38
- }
39
-
40
- return {
41
- ...config,
42
- };
43
- }
44
-
45
- async function _init({
46
- outputPath = ".aigne/doc-smith",
47
- fileName = "config.yaml",
48
- skipIfExists = false,
49
- appUrl,
50
- checkOnly = false,
51
- }) {
52
- // Check if we're in checkOnly mode
53
- if (checkOnly) {
54
- const filePath = join(outputPath, fileName);
55
- const configContent = await readFile(filePath, "utf8").catch(() => null);
56
-
57
- if (!configContent || configContent.trim() === "") {
58
- console.log("⚠️ No configuration file found.");
59
- console.log(
60
- `🚀 Run ${chalk.cyan("aigne doc init")} to set up your documentation configuration.`,
61
- );
62
- process.exit(0);
63
- }
64
-
65
- // Config exists, load and return it
66
- return loadConfig({ config: filePath, appUrl });
67
- }
68
-
69
- if (skipIfExists) {
70
- const filePath = join(outputPath, fileName);
71
- const configContent = await readFile(filePath, "utf8").catch(() => null);
72
- // Only skip if file exists AND has non-empty content
73
- if (configContent && configContent.trim() !== "") {
74
- // load config from file
75
- const config = await loadConfig({ config: filePath, appUrl });
76
- const isValid = validateDocDir(config.docsDir);
77
- if (typeof isValid === "string") {
78
- console.log(
79
- `${chalk.red("Invalid docsDir")}: ${isValid}\nPlease check your configuration.`,
80
- );
81
- process.exit(1);
82
- }
83
- if (!isValid) {
84
- console.log(`${chalk.red("Invalid docsDir")}, please check your configuration.`);
85
- process.exit(1);
86
- }
87
- return config;
88
- }
89
- }
90
-
91
- const input = {};
92
-
93
- // 5. Language settings - use system language detection as default
94
- // const systemLanguage = detectSystemLanguage();
95
- // FIXME: 临时使用中文,框架优化后需要修改
96
- input.locale = "zh";
97
-
98
- // 6. Translation languages - default to empty
99
- input.translateLanguages = [];
100
-
101
- // 7. Documentation directory - use default value
102
- input.docsDir = `${outputPath}/docs`;
103
-
104
- // 8. Content sources - use "./" as default
105
- input.sourcesPath = ["./"];
106
-
107
- // 9. Custom rules - default to empty
108
- input.rules = "";
109
-
110
- // Save project info to config
111
- const projectInfo = await getProjectInfo();
112
- // Remove leading and trailing spaces (middle spaces are preserved and count toward limit)
113
- input.projectName = projectInfo.name.trim();
114
- input.projectDesc = projectInfo.description.trim();
115
- input.projectLogo = projectInfo.icon;
116
-
117
- // Generate YAML content
118
- const yamlContent = generateYAML(input, outputPath);
119
-
120
- // Save file
121
- try {
122
- const filePath = join(outputPath, fileName);
123
- const dirPath = dirname(filePath);
124
-
125
- // Create directory if it doesn't exist
126
- await mkdir(dirPath, { recursive: true });
127
-
128
- await writeFile(filePath, yamlContent, "utf8");
129
- console.log(
130
- `\n✅ Setup complete! Your configuration has been saved to: ${chalk.cyan(filePath)}`,
131
- );
132
- console.log("💡 You can edit this file at any time to change your settings.\n");
133
- console.log(`🚀 To generate your documentation, run: ${chalk.cyan("aigne doc create")}\n`);
134
-
135
- if (skipIfExists) {
136
- return loadConfig({ config: filePath, appUrl });
137
- }
138
-
139
- return {};
140
- } catch (error) {
141
- console.error(
142
- `❌ Sorry, I encountered an error while saving your configuration file: ${error.message}`,
143
- );
144
- return {
145
- inputGeneratorStatus: false,
146
- inputGeneratorError: error.message,
147
- };
148
- }
149
- }
150
-
151
- /**
152
- * Generate YAML configuration content
153
- * @param {Object} input - Input object
154
- * @returns {string} YAML string
155
- */
156
- export function generateYAML(input) {
157
- // Create the main configuration object that will be safely serialized
158
- const config = {
159
- // Project information (safely handled by yaml library)
160
- // Remove leading and trailing spaces (middle spaces are preserved and count toward limit)
161
- projectName: (input.projectName || "").trim(),
162
- projectDesc: (input.projectDesc || "").trim(),
163
- projectLogo: input.projectLogo || "",
164
-
165
- thinking: {
166
- effort: input.thinking?.effort || DEFAULT_THINKING_EFFORT_LEVEL,
167
- },
168
-
169
- // Custom rules and target audience (empty for user to fill)
170
- rules: input.rules || "",
171
- targetAudience: "",
172
-
173
- // Language settings
174
- locale: input.locale || "en",
175
- translateLanguages: input.translateLanguages?.filter((lang) => lang.trim()) || [],
176
-
177
- // Paths
178
- docsDir: input.docsDir || "./aigne/doc-smith/docs",
179
- sourcesPath: input.sourcesPath || [],
180
- media: {
181
- // Image filtering settings
182
- minImageWidth: input.minImageWidth || 800,
183
- },
184
- };
185
-
186
- // Generate comments and structure
187
- let yaml = "# Project information for documentation publishing\n";
188
-
189
- // Serialize the project info section safely with string quoting
190
- const projectSection = yamlStringify({
191
- projectName: config.projectName,
192
- projectDesc: config.projectDesc,
193
- projectLogo: config.projectLogo,
194
- }).trim();
195
-
196
- yaml += `${projectSection}\n\n`;
197
-
198
- const modelSection = yamlStringify({
199
- thinking: config.thinking,
200
- }).trim();
201
-
202
- yaml += `\
203
- # AI Thinking Configuration
204
- # thinking.effort: Determines the depth of reasoning and cognitive effort the AI uses when responding, available options:
205
- # - lite: Fast responses with basic reasoning
206
- # - standard: Balanced speed and reasoning capability
207
- # - pro: In-depth reasoning with longer response times
208
- ${modelSection}
209
- \n`;
210
-
211
- // Custom Documentation Rules and Requirements
212
- yaml += "# Custom Rules: Define specific documentation generation rules and requirements\n";
213
- const rulesSection = yamlStringify({ rules: config.rules }).trim();
214
- // Use literal style for multiline strings
215
- yaml += `${rulesSection.replace(/rules: ''/, "rules: |\n ")}\n\n`;
216
-
217
- // Target Audience Description
218
- yaml += "# Target Audience: Describe your specific target audience and their characteristics.\n";
219
- const targetAudienceSection = yamlStringify({ targetAudience: config.targetAudience }).trim();
220
- // Use literal style for multiline strings
221
- yaml += `${targetAudienceSection.replace(/targetAudience: ''/, "targetAudience: |\n ")}\n\n`;
222
-
223
- // Glossary Configuration
224
- yaml += "# Glossary: Define project-specific terms and definitions.\n";
225
- yaml +=
226
- '# glossary: "@glossary.md" # Path to a markdown file containing glossary definitions.\n\n';
227
-
228
- // Language settings - safely serialize
229
- const localeSection = yamlStringify({ locale: config.locale }).trim();
230
- yaml += `${localeSection.replace(/^locale:/, "locale:")}\n`;
231
-
232
- // Translation languages
233
- if (config.translateLanguages.length > 0) {
234
- const translateLanguagesSection = yamlStringify({
235
- translateLanguages: config.translateLanguages,
236
- }).trim();
237
- yaml += `${translateLanguagesSection.replace(/^translateLanguages:/, "translateLanguages:")}\n`;
238
- } else {
239
- yaml += "# translateLanguages: # A list of languages to translate the documentation to.\n";
240
- yaml += "# - zh # Example: Chinese translation\n";
241
- yaml += "# - en # Example: English translation\n";
242
- }
243
-
244
- // Directory and source path configurations - safely serialize
245
- const docsDirSection = yamlStringify({ docsDir: config.docsDir }).trim();
246
- yaml += `${docsDirSection} # The directory where the generated documentation will be saved.\n`;
247
-
248
- const sourcesPathSection = yamlStringify({ sourcesPath: config.sourcesPath }).trim();
249
- yaml += `${sourcesPathSection.replace(/^sourcesPath:/, "sourcesPath: # The source code paths to analyze.")}\n`;
250
-
251
- // Image filtering settings
252
- const mediaInfoSection = yamlStringify({
253
- media: config.media,
254
- }).trim();
255
- yaml += `# minImageWidth: Only images wider than this value (in pixels) will be used in the page generation.\n${mediaInfoSection}\n`;
256
-
257
- // Diagramming configuration
258
- yaml += "\n# Diagramming Configuration\n";
259
- yaml +=
260
- "# diagramming.effort: AI effort level for diagramming, 0-10, larger value means fewer diagrams\n";
261
- yaml += "diagramming:\n";
262
- yaml += " effort: 5 # AI effort level for diagramming, 0-10, large is less diagram\n";
263
- yaml +=
264
- " # Default diagram style: The primary style to use when no style is specified in feedback\n";
265
- yaml += " # This style will be applied if feedback doesn't specify a different style\n";
266
- yaml += " # Available options:\n";
267
- Object.entries(DIAGRAM_STYLES).forEach(([key, style]) => {
268
- yaml += ` # ${key.padEnd(16)} - ${style.name}: ${style.description}\n`;
269
- });
270
- yaml += ' # style: "modern"\n';
271
-
272
- return yaml;
273
- }
274
-
275
- init.description = "Create a configuration file for the documentation generation process.";
@@ -1,16 +0,0 @@
1
- import path from "node:path";
2
- export function validateDocDir(input) {
3
- const currentDir = process.cwd();
4
- const targetDir = path.resolve(input);
5
- const relativePath = path.relative(currentDir, targetDir);
6
- if (relativePath.length === 0) {
7
- return `Can't use current directory: ${targetDir}`;
8
- }
9
- if (relativePath.startsWith("..")) {
10
- return `Can't use directory outside current directory: ${targetDir}`;
11
- }
12
- if (path.isAbsolute(relativePath)) {
13
- return `Can't use absolute path: ${targetDir}`;
14
- }
15
- return true;
16
- }
@@ -1,107 +0,0 @@
1
- import { SUPPORTED_LANGUAGES } from "../../utils/constants/index.mjs";
2
- import { loadConfigFromFile, saveValueToConfig } from "../../utils/utils.mjs";
3
-
4
- /**
5
- * Interactively selects languages for translation.
6
- * @param {Object} params
7
- * @param {Array<string>} [params.langs] - Pre-selected languages.
8
- * @param {string} params.locale - The primary language code.
9
- * @param {Object} options - Options object with prompts.
10
- * @returns {Promise<Object>} The selected languages.
11
- */
12
- export default async function chooseLanguage({ langs, locale, selectedDocs }, options) {
13
- let selectedLanguages = [];
14
-
15
- // Load existing config to get current translation languages
16
- const existingConfig = await loadConfigFromFile();
17
- const currentTranslateLanguages = existingConfig?.translateLanguages || [];
18
-
19
- // Get primary language from config or parameter
20
- const primaryLanguage = locale || existingConfig?.locale || "en";
21
-
22
- // Filter out the primary language from available choices (like init.mjs)
23
- const availableTranslationLanguages = SUPPORTED_LANGUAGES.filter(
24
- (lang) => lang.code !== primaryLanguage,
25
- );
26
-
27
- // If languages are provided as a parameter, validate them
28
- if (langs && Array.isArray(langs) && langs.length > 0) {
29
- const validLanguages = langs.filter((lang) =>
30
- availableTranslationLanguages.some((availableLang) => availableLang.code === lang),
31
- );
32
-
33
- if (validLanguages.length > 0) {
34
- selectedLanguages = validLanguages;
35
- } else {
36
- console.log(`⚠️ Invalid languages provided: ${langs.join(", ")}`);
37
- console.log(
38
- `Available languages: ${availableTranslationLanguages.map((l) => l.code).join(", ")}`,
39
- );
40
- }
41
- }
42
-
43
- // If no valid languages were provided, let user select from available languages
44
- if (selectedLanguages.length === 0) {
45
- // Create choices from available translation languages with labels
46
- const choices = availableTranslationLanguages.map((lang) => ({
47
- name: `${lang.label} - ${lang.sample}`,
48
- value: lang.code,
49
- checked: currentTranslateLanguages.includes(lang.code), // Default to previously selected languages
50
- }));
51
-
52
- selectedLanguages = await options.prompts.checkbox({
53
- message: "Please select the languages you'd like to translate to:",
54
- choices: choices,
55
- validate: (answer) => {
56
- if (answer.length === 0) {
57
- return "You must select at least one language.";
58
- }
59
- return true;
60
- },
61
- });
62
- }
63
-
64
- if (selectedLanguages.length === 0) {
65
- throw new Error("You must select at least one language to continue.");
66
- }
67
-
68
- // Find new languages that need to be added
69
- const newLanguages = selectedLanguages.filter(
70
- (lang) => !currentTranslateLanguages.includes(lang),
71
- );
72
-
73
- if (newLanguages.length > 0) {
74
- // Add new languages to existing ones
75
- const updatedTranslateLanguages = [...currentTranslateLanguages, ...newLanguages];
76
- await saveValueToConfig("translateLanguages", updatedTranslateLanguages);
77
- }
78
-
79
- // Convert selectedLanguages to translates format
80
- const translates = selectedLanguages.map((lang) => ({ language: lang }));
81
-
82
- return {
83
- selectedLanguages,
84
- selectedDocs,
85
- translates,
86
- };
87
- }
88
-
89
- chooseLanguage.input_schema = {
90
- type: "object",
91
- properties: {
92
- langs: {
93
- type: "array",
94
- items: {
95
- type: "string",
96
- },
97
- description: "A list of pre-selected languages for translation.",
98
- },
99
-
100
- locale: {
101
- type: "string",
102
- description:
103
- "The primary language code, which will be excluded from the translation options.",
104
- },
105
- },
106
- required: [],
107
- };
@@ -1,58 +0,0 @@
1
- type: team
2
- name: localize
3
- alias:
4
- - translate
5
- description: Translate documents into other languages
6
- skills:
7
- - url: ../init/index.mjs
8
- default_input:
9
- skipIfExists: true
10
- checkOnly: true
11
- - ../utils/load-sources.mjs
12
- - url: ../init/check.mjs
13
- - type: transform
14
- task_render_mode: hide
15
- jsonata: |
16
- $merge([
17
- $,
18
- {
19
- 'documentStructure': originalDocumentStructure
20
- }
21
- ])
22
- - url: ../utils/choose-docs.mjs
23
- default_input:
24
- isTranslate: true
25
- - ../localize/choose-language.mjs
26
- - type: team
27
- name: batchTranslateDocument
28
- skills:
29
- - ../localize/translate-multilingual.yaml
30
- iterate_on: selectedDocs
31
- concurrency: 5
32
- - url: ../utils/check-feedback-refiner.mjs
33
- default_input:
34
- stage: translation_refine
35
- - url: ./record-translation-history.mjs
36
- - url: ../utils/action-success.mjs
37
- default_input:
38
- action: '✅ Translation completed'
39
- input_schema:
40
- type: object
41
- properties:
42
- # glossary:
43
- # type: string
44
- # description: Glossary file for consistent terminology (use @filename.md)
45
- docs:
46
- type: array
47
- items:
48
- type: string
49
- description: Documents to update, use document path in document structure to specify
50
- langs:
51
- type: array
52
- items:
53
- type: string
54
- description: 'Target languages (available: en, zh, zh-TW, ja, fr, de, es, it, ru, ko, pt, ar)'
55
- feedback:
56
- type: string
57
- description: Tell us how to improve the translation style
58
- mode: sequential
@@ -1,23 +0,0 @@
1
- import { recordUpdate } from "../../utils/history-utils.mjs";
2
-
3
- export default function recordTranslationHistory({ selectedPaths, feedback }) {
4
- // Skip if no feedback provided
5
- if (!feedback?.trim()) {
6
- return {};
7
- }
8
-
9
- if (!Array.isArray(selectedPaths) || selectedPaths.length === 0) {
10
- return {};
11
- }
12
-
13
- // Record translation history for this document
14
- recordUpdate({
15
- operation: "translation_update",
16
- feedback: feedback.trim(),
17
- docPaths: selectedPaths,
18
- });
19
-
20
- return {};
21
- }
22
-
23
- recordTranslationHistory.task_render_mode = "hide";
@@ -1,24 +0,0 @@
1
- name: translateDocument
2
- description: Translate content to another language
3
- instructions:
4
- url: ../../prompts/translate/translate-document.md
5
- task_render_mode: collapse
6
- input_schema:
7
- type: object
8
- properties:
9
- language:
10
- type: string
11
- description: Target language (e.g., 'zh' for Chinese, 'ja' for Japanese)
12
- content:
13
- type: string
14
- description: Text content to translate
15
- glossary:
16
- type: string
17
- description: Glossary for consistent terminology
18
- feedback:
19
- type: string
20
- description: Tell us how to improve the translation style
21
- required:
22
- - language
23
- - content
24
- output_key: translation