@aigne/doc-smith 0.9.8-alpha.3 → 0.9.8-alpha.5

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 +5 -146
  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,356 +0,0 @@
1
- import { basename, join } from "node:path";
2
- import { publishDocs as publishDocsFn } from "@aigne/publish-docs";
3
- import { BrokerClient } from "@blocklet/payment-broker-client/node";
4
- import chalk from "chalk";
5
- import fs from "fs-extra";
6
-
7
- import {
8
- getAccessToken,
9
- getCachedAccessToken,
10
- getDiscussKitMountPoint,
11
- } from "../../utils/auth-utils.mjs";
12
- import {
13
- CLOUD_SERVICE_URL_PROD,
14
- DISCUSS_KIT_STORE_URL,
15
- DOC_SMITH_DIR,
16
- TMP_DIR,
17
- TMP_DOCS_DIR,
18
- } from "../../utils/constants/index.mjs";
19
- import { ensureTmpDir } from "../../utils/d2-utils.mjs";
20
- import { deploy } from "../../utils/deploy.mjs";
21
- import { getGithubRepoUrl, loadConfigFromFile, saveValueToConfig } from "../../utils/utils.mjs";
22
- import updateBranding from "../utils/update-branding.mjs";
23
- import { isRemoteFile, downloadAndUploadImage } from "../../utils/file-utils.mjs";
24
- import { joinURL } from "ufo";
25
-
26
- const BASE_URL = process.env.DOC_SMITH_BASE_URL || CLOUD_SERVICE_URL_PROD;
27
-
28
- export default async function publishDocs(
29
- {
30
- docsDir: rawDocsDir,
31
- appUrl,
32
- boardId,
33
- projectName,
34
- projectDesc,
35
- projectLogo,
36
- translatedMetadata,
37
- originalDocumentStructure,
38
- "with-branding": withBrandingOption,
39
- },
40
- options,
41
- ) {
42
- let message;
43
- let shouldWithBranding = withBrandingOption || false;
44
-
45
- try {
46
- // move work dir to tmp-dir
47
- await ensureTmpDir();
48
-
49
- const docsDir = join(DOC_SMITH_DIR, TMP_DIR, TMP_DOCS_DIR);
50
- await fs.rm(docsDir, { recursive: true, force: true });
51
- await fs.mkdir(docsDir, {
52
- recursive: true,
53
- });
54
- await fs.cp(rawDocsDir, docsDir, { recursive: true });
55
-
56
- // ----------------- main publish process flow -----------------------------
57
- // Check if DOC_DISCUSS_KIT_URL is set in environment variables
58
- const useEnvAppUrl = !!(
59
- process.env.DOC_SMITH_PUBLISH_URL ||
60
- process.env.DOC_DISCUSS_KIT_URL ||
61
- appUrl
62
- );
63
-
64
- // Check if appUrl is default and not saved in config (only when not using env variable)
65
- const config = await loadConfigFromFile();
66
- appUrl =
67
- process.env.DOC_SMITH_PUBLISH_URL ||
68
- process.env.DOC_DISCUSS_KIT_URL ||
69
- appUrl ||
70
- config?.appUrl;
71
- const hasInputAppUrl = !!appUrl;
72
-
73
- let shouldSyncBranding = void 0;
74
- let token = "";
75
- let client = null;
76
- let sessionId = null;
77
- let locale = config?.locale;
78
-
79
- if (!hasInputAppUrl) {
80
- const officialAccessToken = await getCachedAccessToken(BASE_URL);
81
-
82
- sessionId = "";
83
- if (officialAccessToken) {
84
- client = new BrokerClient({ baseUrl: BASE_URL, authToken: officialAccessToken });
85
- const info = await client.checkCacheSession({
86
- needShortUrl: true,
87
- sessionId: config?.checkoutId,
88
- });
89
- sessionId = info.sessionId;
90
- }
91
-
92
- const choice = await options.prompts.select({
93
- message: "Please select a platform to publish your documents:",
94
- choices: [
95
- ...(sessionId
96
- ? [
97
- {
98
- name: `${chalk.yellow("Resume previous website setup")} - ${chalk.green("Already paid.")} Continue where you left off. Your payment has already been processed.`,
99
- value: "new-instance-continue",
100
- },
101
- ]
102
- : []),
103
- {
104
- name: `${chalk.blue("DocSmith Cloud (docsmith.aigne.io)")} – ${chalk.green("Free")} hosting. Your documents will be publicly accessible. Best for open-source projects or community sharing.`,
105
- value: "default",
106
- },
107
- {
108
- name: `${chalk.blue("Your existing website")} - Integrate and publish directly on your current site (setup required)`,
109
- value: "custom",
110
- },
111
- {
112
- name: `${chalk.blue("New website")} - ${chalk.yellow("Paid service.")} We'll help you set up a brand-new website with custom domain and hosting. Great if you want a professional presence.`,
113
- value: "new-instance",
114
- },
115
- ],
116
- });
117
-
118
- if (choice === "custom") {
119
- console.log(
120
- `${chalk.bold("\n💡 Tips")}\n\n` +
121
- `Start here to run your own website:\n${chalk.cyan(DISCUSS_KIT_STORE_URL)}\n`,
122
- );
123
- const userInput = await options.prompts.input({
124
- message: "Please enter the URL of your website:",
125
- validate: (input) => {
126
- try {
127
- // Check if input contains protocol, if not, prepend https://
128
- const urlWithProtocol = input.includes("://") ? input : `https://${input}`;
129
- new URL(urlWithProtocol);
130
- return true;
131
- } catch {
132
- return "Please enter a valid URL";
133
- }
134
- },
135
- });
136
- // Ensure appUrl has protocol
137
- appUrl = userInput.includes("://") ? userInput : `https://${userInput}`;
138
- } else if (["new-instance", "new-instance-continue"].includes(choice)) {
139
- // resume previous website setup
140
- const isNewInstance = choice === "new-instance";
141
- if (!isNewInstance) {
142
- shouldSyncBranding = config?.shouldSyncBranding ?? void 0;
143
- if (shouldSyncBranding !== void 0) {
144
- shouldWithBranding = shouldWithBranding ?? shouldSyncBranding;
145
- }
146
- }
147
-
148
- if (options?.prompts?.confirm) {
149
- if (shouldSyncBranding === void 0) {
150
- shouldSyncBranding = await options.prompts.confirm({
151
- message: "Would you like to update the project branding (title, description, logo)?",
152
- default: true,
153
- });
154
- await saveValueToConfig(
155
- "shouldSyncBranding",
156
- shouldSyncBranding,
157
- "Should sync branding for documentation",
158
- );
159
- shouldWithBranding = shouldSyncBranding;
160
- } else {
161
- console.log(
162
- `Would you like to update the project branding (title, description, logo)? ${chalk.cyan(shouldSyncBranding ? "Yes" : "No")}`,
163
- );
164
- }
165
- }
166
-
167
- try {
168
- let id = "";
169
- if (!isNewInstance) {
170
- id = sessionId;
171
- console.log(`\nResuming your previous website setup...`);
172
- } else {
173
- console.log(`\nCreating a new website for your documentation...`);
174
- }
175
- const {
176
- appUrl: homeUrl,
177
- token: ltToken,
178
- sessionId: newSessionId,
179
- data,
180
- } = (await deploy(id, isNewInstance ? locale : undefined)) || {};
181
-
182
- sessionId = newSessionId;
183
- appUrl = homeUrl;
184
- token = ltToken;
185
- locale = data?.preferredLocale || locale;
186
- } catch (error) {
187
- const errorMsg = error?.message || "Unknown error occurred";
188
- return { message: `${chalk.red("❌ Failed to create website:")} ${errorMsg}` };
189
- }
190
- }
191
- }
192
-
193
- appUrl = appUrl ?? CLOUD_SERVICE_URL_PROD;
194
-
195
- const appUrlInfo = new URL(appUrl);
196
-
197
- const discussKitMountPoint = await getDiscussKitMountPoint(appUrlInfo.origin);
198
- const discussKitUrl = joinURL(appUrlInfo.origin, discussKitMountPoint);
199
-
200
- console.log(`\nPublishing your documentation to ${chalk.cyan(discussKitUrl)}`);
201
-
202
- const accessToken = await getAccessToken(appUrlInfo.origin, token, locale);
203
-
204
- process.env.DOC_ROOT_DIR = docsDir;
205
-
206
- const sidebarPath = join(docsDir, "_sidebar.md");
207
- const publishCacheFilePath = join(DOC_SMITH_DIR, "upload-cache.yaml");
208
-
209
- // Get project info from config
210
- const projectInfo = {
211
- name: projectName || config?.projectName || basename(process.cwd()),
212
- description: projectDesc || config?.projectDesc || "",
213
- icon: projectLogo || config?.projectLogo || "",
214
- };
215
- let finalPath = null;
216
-
217
- console.log(`Publishing docs collection: ${chalk.cyan(projectInfo.name || boardId)}\n`);
218
-
219
- // Handle project logo download if it's a URL
220
- if (projectInfo.icon && isRemoteFile(projectInfo.icon)) {
221
- const { url: uploadedImageUrl, downloadFinalPath } = await downloadAndUploadImage(
222
- projectInfo.icon,
223
- docsDir,
224
- discussKitUrl,
225
- accessToken,
226
- );
227
- projectInfo.icon = uploadedImageUrl;
228
- finalPath = downloadFinalPath;
229
- }
230
-
231
- if (shouldWithBranding) {
232
- updateBranding({ appUrl: discussKitUrl, projectInfo, accessToken, finalPath });
233
- }
234
-
235
- const iconMap = {};
236
- for (const item of originalDocumentStructure) {
237
- if (item.icon) {
238
- iconMap[item.title] = item.icon;
239
- }
240
- }
241
-
242
- // Construct boardMeta object
243
- const boardMeta = {
244
- category: config?.documentPurpose || [],
245
- githubRepoUrl: getGithubRepoUrl(),
246
- commitSha: config?.lastGitHead || "",
247
- languages: [
248
- ...(config?.locale ? [config.locale] : []),
249
- ...(config?.translateLanguages || []),
250
- ].filter((lang, index, arr) => arr.indexOf(lang) === index), // Remove duplicates
251
- };
252
- if (translatedMetadata) {
253
- boardMeta.translation = translatedMetadata;
254
- }
255
- const {
256
- success,
257
- boardId: newBoardId,
258
- error,
259
- docsUrl,
260
- } = await publishDocsFn({
261
- sidebarPath,
262
- accessToken,
263
- appUrl: discussKitUrl,
264
- boardId,
265
- autoCreateBoard: true,
266
- // Pass additional project information if available
267
- boardName: projectInfo.name,
268
- boardDesc: projectInfo.description,
269
- boardCover: projectInfo.icon,
270
- mediaFolder: rawDocsDir,
271
- cacheFilePath: publishCacheFilePath,
272
- boardMeta,
273
- iconMap,
274
- });
275
-
276
- // Save values to config.yaml if publish was successful
277
- if (success) {
278
- // Save appUrl to config only when not using environment variable
279
- if (!useEnvAppUrl) {
280
- await saveValueToConfig("appUrl", appUrlInfo.origin);
281
- }
282
-
283
- // Save boardId to config if it was auto-created
284
- if (boardId !== newBoardId) {
285
- await saveValueToConfig("boardId", newBoardId);
286
- }
287
- message = `✅ Documentation published successfully!\n📖 Docs available at: ${chalk.cyan(docsUrl)}`;
288
-
289
- await saveValueToConfig("checkoutId", "", "Checkout ID for document deployment service");
290
- await saveValueToConfig("shouldSyncBranding", "", "Should sync branding for documentation");
291
- } else {
292
- // If the error is 401 or 403, it means the access token is invalid
293
- try {
294
- const obj = JSON.parse(error);
295
- message = `❌ Publishing failed with error: \n💡 ${obj.message || error}`;
296
- } catch {
297
- if (error?.includes("401")) {
298
- message = `❌ Publishing failed due to an authorization error: \n💡 Please run ${chalk.cyan("aigne doc clear")} to reset your credentials and try again.`;
299
- } else if (error?.includes("403")) {
300
- message = `❌ Publishing failed due to an authorization error: \n💡 You’re not the creator of this document (Board ID: ${boardId}). You can change the board ID and try again. \n💡 Or run ${chalk.cyan("aigne doc clear")} to reset your credentials and try again.`;
301
- }
302
- }
303
- }
304
-
305
- // clean up tmp work dir
306
- await fs.rm(docsDir, { recursive: true, force: true });
307
- } catch (error) {
308
- message = `❌ Sorry, I encountered an error while publishing your documentation: \n\n${error.message}`;
309
-
310
- // clean up tmp work dir in case of error
311
- try {
312
- const docsDir = join(DOC_SMITH_DIR, TMP_DIR, TMP_DOCS_DIR);
313
- await fs.rm(docsDir, { recursive: true, force: true });
314
- } catch {
315
- // Ignore cleanup errors
316
- }
317
- }
318
-
319
- return message ? { message } : {};
320
- }
321
-
322
- publishDocs.input_schema = {
323
- type: "object",
324
- properties: {
325
- docsDir: {
326
- type: "string",
327
- description: "The directory of the documentation.",
328
- },
329
- appUrl: {
330
- type: "string",
331
- description: "The URL of the app.",
332
- },
333
- boardId: {
334
- type: "string",
335
- description: "The ID of the board.",
336
- },
337
- "with-branding": {
338
- type: "boolean",
339
- description: "Update the website branding (title, description, and logo).",
340
- },
341
- projectName: {
342
- type: "string",
343
- description: "The name of the project.",
344
- },
345
- projectDesc: {
346
- type: "string",
347
- description: "A description of the project.",
348
- },
349
- projectLogo: {
350
- type: "string",
351
- description: "The logo or icon of the project.",
352
- },
353
- },
354
- };
355
-
356
- publishDocs.description = "Publish the documentation to a website";
@@ -1,103 +0,0 @@
1
- import { join } from "node:path";
2
-
3
- import { AIAgent } from "@aigne/core";
4
- import fs from "fs-extra";
5
- import { parse as yamlParse, stringify as yamlStringify } from "yaml";
6
- import z from "zod";
7
-
8
- import { DOC_SMITH_DIR } from "../../utils/constants/index.mjs";
9
-
10
- export default async function translateMeta(
11
- { projectName, projectDesc, locale, translateLanguages = [] },
12
- options,
13
- ) {
14
- const languages = [...new Set([...(locale ? [locale] : []), ...(translateLanguages || [])])];
15
-
16
- const translationCacheFilePath = join(DOC_SMITH_DIR, "translation-cache.yaml");
17
- await fs.ensureFile(translationCacheFilePath);
18
- const translationCache = await fs.readFile(translationCacheFilePath, "utf-8");
19
- const parsedTranslationCache = yamlParse(translationCache || "{}");
20
-
21
- const titleTranslation = parsedTranslationCache[projectName] || {};
22
- const descTranslation = parsedTranslationCache[projectDesc] || {};
23
-
24
- const titleLanguages = languages.filter((lang) => !titleTranslation[lang]);
25
- const descLanguages = languages.filter((lang) => !descTranslation[lang]);
26
- const titleTranslationSchema = z.object(
27
- titleLanguages.reduce((shape, lang) => {
28
- shape[lang] = z.string();
29
- return shape;
30
- }, {}),
31
- );
32
- const descTranslationSchema = z.object(
33
- descLanguages.reduce((shape, lang) => {
34
- shape[lang] = z.string();
35
- return shape;
36
- }, {}),
37
- );
38
-
39
- const agent = AIAgent.from({
40
- name: "translateMeta",
41
- instructions:
42
- "You are an **Elite Polyglot Localization and Translation Specialist** with extensive professional experience across multiple domains. Your core mission is to produce translations that are not only **100% accurate** to the source meaning but are also **natively fluent, highly readable, and culturally appropriate** in the target language.",
43
- inputKey: "message",
44
- outputSchema: z.object({
45
- title: titleTranslationSchema.describe("Translated titles with language codes as keys"),
46
- desc: descTranslationSchema.describe("Translated descriptions with language codes as keys"),
47
- }),
48
- });
49
- if (titleLanguages.length > 0 || descLanguages.length > 0) {
50
- const translatedMetadata = await options.context.invoke(agent, {
51
- message: `Translate the following title and description into all target languages except the source language. Provide the translations in a JSON object with the language codes as keys. If the project title or description is empty, return an empty string for that field.
52
-
53
- Project Title: ${projectName || ""}
54
- Project Description: ${projectDesc || ""}
55
-
56
- Target Languages: { title: ${titleLanguages.join(", ")}, desc: ${descLanguages.join(", ")} }
57
- Source Language: ${locale}
58
-
59
- Respond with a JSON object in the following format:
60
- {
61
- "title": {
62
- "fr": "Translated Project Title in French",
63
- "es": "Translated Project Title in Spanish",
64
- ...
65
- },
66
- "desc": {
67
- "fr": "Translated Project Description in French",
68
- "es": "Translated Project Description in Spanish",
69
- ...
70
- }
71
- }
72
-
73
- If no translation is needed, respond with:
74
- {
75
- "title": {},
76
- "desc": {}
77
- }`,
78
- });
79
- Object.keys(translatedMetadata.title || {}).forEach((lang) => {
80
- if (translatedMetadata.title[lang]) {
81
- titleTranslation[lang] = translatedMetadata.title[lang];
82
- }
83
- });
84
- Object.keys(translatedMetadata.desc || {}).forEach((lang) => {
85
- if (translatedMetadata.desc[lang]) {
86
- descTranslation[lang] = translatedMetadata.desc[lang];
87
- }
88
- });
89
- }
90
- const saveResult = {
91
- ...parsedTranslationCache,
92
- [projectName]: titleTranslation,
93
- [projectDesc]: descTranslation,
94
- };
95
- await fs.writeFile(translationCacheFilePath, yamlStringify(saveResult), { encoding: "utf8" });
96
-
97
- return {
98
- translatedMetadata: {
99
- title: saveResult[projectName] || {},
100
- desc: saveResult[projectDesc] || {},
101
- },
102
- };
103
- }
@@ -1,26 +0,0 @@
1
- type: object
2
- description: Document structure item representing a node in the document hierarchy
3
- properties:
4
- title:
5
- type: string
6
- description:
7
- type: string
8
- path:
9
- type: string
10
- description: Path in URL format, cannot be empty, cannot contain spaces or special characters, must start with /, no need to include language level, e.g., /zh/about should return /about
11
- parentPath:
12
- type: string
13
- description: Parent node path, if null indicates it is a top-level node
14
- sourceIds:
15
- type: array
16
- description: Associated sourceId from `<data_sources>` for subsequent translation and content generation, must come from sourceId in `<data_sources>`, cannot have fake ids, **cannot be empty**
17
- items:
18
- type: string
19
- icon:
20
- type: string
21
- description: Lucide icon name for root-level documents (just support lucide:icon-name, not support other icon collections)
22
- required:
23
- - title
24
- - description
25
- - path
26
- - sourceIds
@@ -1,23 +0,0 @@
1
- type: object
2
- description: Document structure item representing a node in the document hierarchy
3
- properties:
4
- id:
5
- type: string
6
- description: Unique identifier for the document structure item
7
- title:
8
- type: string
9
- description:
10
- type: string
11
- path:
12
- type: string
13
- description: Path in URL format, cannot be empty, cannot contain spaces or special characters, must start with /, no need to include language level, e.g., /zh/about should return /about
14
- parentPath:
15
- type: string
16
- description: Parent node path, if null indicates it is a top-level node
17
- icon:
18
- type: string
19
- description: Iconify icon name, e.g., lucide:book, lucide:rocket, lucide:* etc.
20
- required:
21
- - title
22
- - description
23
- - path
@@ -1,29 +0,0 @@
1
- type: array
2
- items:
3
- type: object
4
- properties:
5
- title:
6
- type: string
7
- description:
8
- type: string
9
- path:
10
- type: string
11
- description: Path in URL format, cannot be empty, cannot contain spaces or special characters, must start with /, no need to include language level, e.g., /zh/about should return /about
12
- parentId:
13
- type:
14
- - string
15
- - "null"
16
- description: Parent node path, if null indicates it is a top-level node
17
- sourceIds:
18
- type: array
19
- description: Associated sourceId from `<data_sources>` for subsequent translation and content generation, must come from sourceId in `<data_sources>`, cannot have fake ids, **cannot be empty**
20
- items:
21
- type: string
22
- icon:
23
- type: string
24
- description: Lucide icon name for root-level documents (just support lucide:icon-name, not support other icon collections)
25
- required:
26
- - title
27
- - description
28
- - path
29
- - sourceIds
@@ -1,27 +0,0 @@
1
- type: team
2
- name: batchGenerateDocument
3
- description: Batch generate document details
4
- skills:
5
- - ./check-document.mjs
6
- input_schema:
7
- type: object
8
- properties:
9
- detailDataSource:
10
- type: string
11
- description: Context for documentation structure generation, used to assist generate documentation structure
12
- documentStructure: ../schema/document-structure.yaml
13
- translates:
14
- type: array
15
- items:
16
- type: object
17
- properties:
18
- language:
19
- type: string
20
- description: List of languages to translate documents to
21
- modifiedFiles:
22
- type: array
23
- items: { type: string }
24
- description: Array of modified files since last generation
25
- iterate_on: documentStructure
26
- concurrency: 5
27
- mode: sequential
@@ -1,7 +0,0 @@
1
-
2
- type: team
3
- name: batchUpdateDocument
4
- skills:
5
- - ../update/handle-document-update.yaml
6
- iterate_on: selectedDocs
7
- concurrency: 5
@@ -1,116 +0,0 @@
1
- /**
2
- * Check if --diagram or --diagram-all flag is set via command line arguments or environment variable
3
- * Returns the flag values and passes through all input
4
- *
5
- * --diagram: Filter to show only documents with diagrams, let user select
6
- * --diagram-all: Auto-select all documents with diagrams, no user selection
7
- */
8
- export default function checkDiagramFlag(input) {
9
- let shouldUpdateDiagrams = false;
10
- let shouldAutoSelectDiagrams = false;
11
-
12
- // Priority order: command line args > input params > environment variables
13
- // Check command line arguments first (highest priority)
14
- if (process.argv) {
15
- // Check for --diagram-all or -da (exact match)
16
- const hasDiagramAllFlag = process.argv.some((arg) => arg === "--diagram-all" || arg === "-da");
17
-
18
- const hasDiagramFlag = process.argv.some((arg) => arg === "--diagram" || arg === "-d");
19
-
20
- if (hasDiagramAllFlag) {
21
- shouldUpdateDiagrams = true;
22
- shouldAutoSelectDiagrams = true;
23
- // Return early if CLI arg found (highest priority)
24
- return {
25
- ...input,
26
- shouldUpdateDiagrams,
27
- shouldAutoSelectDiagrams,
28
- };
29
- } else if (hasDiagramFlag) {
30
- shouldUpdateDiagrams = true;
31
- shouldAutoSelectDiagrams = false;
32
- // Return early if CLI arg found (highest priority)
33
- return {
34
- ...input,
35
- shouldUpdateDiagrams,
36
- shouldAutoSelectDiagrams,
37
- };
38
- }
39
- }
40
-
41
- // Check input parameter (second priority - CLI framework might parse --diagram-all as separate parameter)
42
- if (input["diagram-all"] === true || input["diagram-all"] === "true") {
43
- shouldUpdateDiagrams = true;
44
- shouldAutoSelectDiagrams = true;
45
- // Return early if input param found (second priority)
46
- return {
47
- ...input,
48
- shouldUpdateDiagrams,
49
- shouldAutoSelectDiagrams,
50
- };
51
- } else if (input.diagram === true || input.diagram === "true") {
52
- shouldUpdateDiagrams = true;
53
- shouldAutoSelectDiagrams = false;
54
- // Return early if input param found (second priority)
55
- return {
56
- ...input,
57
- shouldUpdateDiagrams,
58
- shouldAutoSelectDiagrams,
59
- };
60
- }
61
-
62
- // Check environment variable (lowest priority)
63
- if (
64
- process.env.DOC_SMITH_UPDATE_DIAGRAMS === "all" ||
65
- process.env.DOC_SMITH_UPDATE_DIAGRAMS_ALL === "true" ||
66
- process.env.DOC_SMITH_UPDATE_DIAGRAMS_ALL === "1"
67
- ) {
68
- shouldUpdateDiagrams = true;
69
- shouldAutoSelectDiagrams = true;
70
- } else if (
71
- process.env.DOC_SMITH_UPDATE_DIAGRAMS === "true" ||
72
- process.env.DOC_SMITH_UPDATE_DIAGRAMS === "1"
73
- ) {
74
- shouldUpdateDiagrams = true;
75
- shouldAutoSelectDiagrams = false;
76
- }
77
-
78
- // Return all input plus the flags
79
- return {
80
- ...input,
81
- shouldUpdateDiagrams,
82
- shouldAutoSelectDiagrams,
83
- };
84
- }
85
-
86
- checkDiagramFlag.input_schema = {
87
- type: "object",
88
- properties: {
89
- diagram: {
90
- type: ["boolean", "string"],
91
- description:
92
- "Flag to trigger diagram update: true for user selection (can also use --diagram CLI arg)",
93
- },
94
- "diagram-all": {
95
- type: ["boolean", "string"],
96
- description:
97
- "Flag to auto-select all documents with diagrams (can also use --diagram-all CLI arg)",
98
- },
99
- },
100
- };
101
-
102
- checkDiagramFlag.output_schema = {
103
- type: "object",
104
- properties: {
105
- shouldUpdateDiagrams: {
106
- type: "boolean",
107
- description: "Whether to filter and update diagrams",
108
- },
109
- shouldAutoSelectDiagrams: {
110
- type: "boolean",
111
- description:
112
- "Whether to auto-select all documents with diagrams (true for --diagram-all, false for --diagram)",
113
- },
114
- },
115
- required: ["shouldUpdateDiagrams", "shouldAutoSelectDiagrams"],
116
- };