@aigne/doc-smith 0.8.10 → 0.8.11-beta.1

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 (260) hide show
  1. package/.aigne/doc-smith/config.yaml +2 -0
  2. package/.aigne/doc-smith/output/structure-plan.json +3 -3
  3. package/.aigne/doc-smith/upload-cache.yaml +252 -0
  4. package/.github/workflows/create-release-pr.yaml +21 -0
  5. package/.github/workflows/publish-docs.yml +67 -0
  6. package/.github/workflows/release.yml +3 -7
  7. package/.release-please-manifest.json +1 -1
  8. package/CHANGELOG.md +22 -0
  9. package/README.md +48 -115
  10. package/RELEASE.md +1 -2
  11. package/agents/clear/choose-contents.mjs +170 -0
  12. package/agents/clear/clear-auth-tokens.mjs +111 -0
  13. package/agents/clear/clear-document-config.mjs +39 -0
  14. package/agents/clear/clear-document-structure.mjs +106 -0
  15. package/agents/clear/clear-generated-docs.mjs +51 -0
  16. package/agents/clear/index.yaml +23 -0
  17. package/agents/evaluate/code-snippet.mjs +93 -0
  18. package/agents/evaluate/document-structure.yaml +70 -0
  19. package/agents/evaluate/document.yaml +79 -0
  20. package/agents/evaluate/generate-report.mjs +78 -0
  21. package/agents/evaluate/index.yaml +39 -0
  22. package/agents/generate/document-structure-tools/add-document.mjs +56 -0
  23. package/agents/generate/document-structure-tools/delete-document.mjs +49 -0
  24. package/agents/generate/document-structure-tools/move-document.mjs +82 -0
  25. package/agents/generate/document-structure-tools/update-document.mjs +50 -0
  26. package/agents/generate/generate-structure.yaml +1 -1
  27. package/agents/generate/update-document-structure.yaml +42 -0
  28. package/agents/generate/user-review-document-structure.mjs +6 -4
  29. package/agents/init/index.mjs +1 -1
  30. package/agents/publish/publish-docs.mjs +12 -3
  31. package/agents/translate/choose-language.mjs +1 -1
  32. package/agents/update/batch-update-document.yaml +7 -0
  33. package/agents/update/check-update-is-single.mjs +38 -0
  34. package/agents/update/document-tools/update-document-content.mjs +293 -0
  35. package/agents/update/index.yaml +4 -10
  36. package/agents/update/update-document-detail.yaml +52 -0
  37. package/agents/update/update-single-document.yaml +15 -0
  38. package/agents/update/user-review-document.mjs +248 -0
  39. package/agents/utils/choose-docs.mjs +4 -2
  40. package/agents/utils/format-document-structure.mjs +12 -2
  41. package/agents/utils/load-document-all-content.mjs +84 -0
  42. package/agents/utils/load-sources.mjs +4 -1
  43. package/aigne.yaml +59 -20
  44. package/assets/report-template/report.html +198 -0
  45. package/biome.json +14 -2
  46. package/docs/advanced-how-it-works.ja.md +101 -0
  47. package/docs/advanced-how-it-works.zh-TW.md +101 -0
  48. package/docs/advanced-how-it-works.zh.md +20 -20
  49. package/docs/advanced-quality-assurance.ja.md +96 -0
  50. package/docs/advanced-quality-assurance.zh-TW.md +96 -0
  51. package/docs/advanced-quality-assurance.zh.md +18 -18
  52. package/docs/advanced.ja.md +16 -0
  53. package/docs/advanced.zh-TW.md +16 -0
  54. package/docs/advanced.zh.md +4 -4
  55. package/docs/changelog.ja.md +309 -0
  56. package/docs/changelog.zh-TW.md +309 -0
  57. package/docs/changelog.zh.md +23 -23
  58. package/docs/cli-reference.ja.md +210 -0
  59. package/docs/cli-reference.zh-TW.md +210 -0
  60. package/docs/cli-reference.zh.md +21 -21
  61. package/docs/configuration-interactive-setup.ja.md +135 -0
  62. package/docs/configuration-interactive-setup.zh-TW.md +135 -0
  63. package/docs/configuration-interactive-setup.zh.md +29 -29
  64. package/docs/configuration-language-support.ja.md +94 -0
  65. package/docs/configuration-language-support.zh-TW.md +94 -0
  66. package/docs/configuration-language-support.zh.md +13 -13
  67. package/docs/configuration-llm-setup.ja.md +54 -0
  68. package/docs/configuration-llm-setup.zh-TW.md +54 -0
  69. package/docs/configuration-llm-setup.zh.md +12 -12
  70. package/docs/configuration-preferences.ja.md +129 -0
  71. package/docs/configuration-preferences.zh-TW.md +129 -0
  72. package/docs/configuration-preferences.zh.md +36 -36
  73. package/docs/configuration.ja.md +172 -0
  74. package/docs/configuration.zh-TW.md +172 -0
  75. package/docs/configuration.zh.md +49 -49
  76. package/docs/features-generate-documentation.ja.md +101 -0
  77. package/docs/features-generate-documentation.zh-TW.md +101 -0
  78. package/docs/features-generate-documentation.zh.md +17 -17
  79. package/docs/features-publish-your-docs.ja.md +107 -0
  80. package/docs/features-publish-your-docs.zh-TW.md +107 -0
  81. package/docs/features-publish-your-docs.zh.md +22 -22
  82. package/docs/features-translate-documentation.ja.md +79 -0
  83. package/docs/features-translate-documentation.zh-TW.md +79 -0
  84. package/docs/features-translate-documentation.zh.md +12 -12
  85. package/docs/features-update-and-refine.ja.md +138 -0
  86. package/docs/features-update-and-refine.zh-TW.md +138 -0
  87. package/docs/features-update-and-refine.zh.md +21 -21
  88. package/docs/features.ja.md +52 -0
  89. package/docs/features.zh-TW.md +52 -0
  90. package/docs/features.zh.md +8 -8
  91. package/docs/getting-started.ja.md +123 -0
  92. package/docs/getting-started.zh-TW.md +123 -0
  93. package/docs/getting-started.zh.md +24 -24
  94. package/docs/overview.ja.md +30 -0
  95. package/docs/overview.zh-TW.md +30 -0
  96. package/docs/overview.zh.md +8 -8
  97. package/package.json +19 -11
  98. package/prompts/common/document/content-rules-core.md +19 -0
  99. package/prompts/common/document/media-handling-rules.md +9 -0
  100. package/prompts/common/document/role-and-personality.md +15 -0
  101. package/prompts/common/document/user-preferences.md +9 -0
  102. package/prompts/common/document-structure/conflict-resolution-guidance.md +16 -0
  103. package/prompts/common/document-structure/document-structure-rules.md +45 -0
  104. package/prompts/common/document-structure/glossary.md +7 -0
  105. package/prompts/common/document-structure/intj-traits.md +5 -0
  106. package/prompts/common/document-structure/output-constraints.md +9 -0
  107. package/prompts/common/document-structure/user-locale-rules.md +10 -0
  108. package/prompts/common/document-structure/user-preferences.md +9 -0
  109. package/prompts/detail/custom/custom-components.md +9 -1
  110. package/prompts/detail/document-rules.md +6 -6
  111. package/prompts/detail/generate-document.md +5 -45
  112. package/prompts/detail/update-document.md +145 -0
  113. package/prompts/evaluate/document-structure.md +94 -0
  114. package/prompts/evaluate/document.md +149 -0
  115. package/prompts/structure/document-rules.md +1 -1
  116. package/prompts/structure/generate-structure-system.md +74 -0
  117. package/prompts/structure/generate-structure-user.md +41 -0
  118. package/prompts/structure/update-document-structure.md +118 -0
  119. package/prompts/translate/translate-document.md +1 -1
  120. package/prompts/utils/feedback-refiner.md +3 -3
  121. package/release-please-config.json +4 -3
  122. package/tests/agents/clear/choose-contents.test.mjs +280 -0
  123. package/tests/agents/clear/clear-auth-tokens.test.mjs +268 -0
  124. package/tests/agents/clear/clear-document-config.test.mjs +167 -0
  125. package/tests/agents/clear/clear-document-structure.test.mjs +374 -0
  126. package/tests/agents/clear/clear-generated-docs.test.mjs +222 -0
  127. package/tests/agents/evaluate/code-snippet.test.mjs +163 -0
  128. package/tests/agents/evaluate/fixtures/api-services.md +87 -0
  129. package/tests/agents/evaluate/fixtures/js-sdk.md +94 -0
  130. package/tests/agents/evaluate/generate-report.test.mjs +312 -0
  131. package/tests/agents/generate/check-document-structure.test.mjs +0 -6
  132. package/tests/agents/generate/document-structure-tools/add-document.test.mjs +449 -0
  133. package/tests/agents/generate/document-structure-tools/delete-document.test.mjs +410 -0
  134. package/tests/agents/generate/document-structure-tools/move-document.test.mjs +476 -0
  135. package/tests/agents/generate/document-structure-tools/update-document.test.mjs +548 -0
  136. package/tests/agents/generate/generate-structure.test.mjs +0 -6
  137. package/tests/agents/generate/user-review-document-structure.test.mjs +9 -9
  138. package/tests/agents/publish/publish-docs.test.mjs +2 -2
  139. package/tests/agents/update/check-update-is-single.test.mjs +300 -0
  140. package/tests/agents/update/document-tools/update-document-content.test.mjs +326 -0
  141. package/tests/agents/update/user-review-document.test.mjs +561 -0
  142. package/tests/agents/utils/format-document-structure.test.mjs +100 -0
  143. package/tests/utils/auth-utils.test.mjs +239 -1
  144. package/tests/utils/blocklet.test.mjs +9 -7
  145. package/tests/utils/constants.test.mjs +1 -1
  146. package/tests/utils/d2-utils.test.mjs +1 -1
  147. package/tests/utils/deploy.test.mjs +310 -366
  148. package/tests/utils/kroki-utils.test.mjs +2 -15
  149. package/tests/utils/linter/fixtures/css/keyword-error.css +1 -0
  150. package/tests/utils/linter/fixtures/css/missing-semicolon.css +1 -0
  151. package/tests/utils/linter/fixtures/css/syntax-error.css +1 -0
  152. package/tests/utils/linter/fixtures/css/undeclare-variable.css +1 -0
  153. package/tests/utils/linter/fixtures/css/unused-variable.css +2 -0
  154. package/tests/utils/linter/fixtures/css/valid-code.css +1 -0
  155. package/tests/utils/linter/fixtures/dockerfile/keyword-error.dockerfile +1 -0
  156. package/tests/utils/linter/fixtures/dockerfile/missing-semicolon.dockerfile +2 -0
  157. package/tests/utils/linter/fixtures/dockerfile/syntax-error.dockerfile +2 -0
  158. package/tests/utils/linter/fixtures/dockerfile/undeclare-variable.dockerfile +1 -0
  159. package/tests/utils/linter/fixtures/dockerfile/unused-variable.dockerfile +1 -0
  160. package/tests/utils/linter/fixtures/dockerfile/valid-code.dockerfile +2 -0
  161. package/tests/utils/linter/fixtures/go/keyword-error.go +5 -0
  162. package/tests/utils/linter/fixtures/go/missing-semicolon.go +5 -0
  163. package/tests/utils/linter/fixtures/go/syntax-error.go +6 -0
  164. package/tests/utils/linter/fixtures/go/undeclare-variable.go +5 -0
  165. package/tests/utils/linter/fixtures/go/unused-variable.go +5 -0
  166. package/tests/utils/linter/fixtures/go/valid-code.go +7 -0
  167. package/tests/utils/linter/fixtures/js/keyword-error.js +3 -0
  168. package/tests/utils/linter/fixtures/js/missing-semicolon.js +6 -0
  169. package/tests/utils/linter/fixtures/js/syntax-error.js +4 -0
  170. package/tests/utils/linter/fixtures/js/undeclare-variable.js +3 -0
  171. package/tests/utils/linter/fixtures/js/unused-variable.js +7 -0
  172. package/tests/utils/linter/fixtures/js/valid-code.js +15 -0
  173. package/tests/utils/linter/fixtures/json/keyword-error.json +1 -0
  174. package/tests/utils/linter/fixtures/json/missing-semicolon.json +1 -0
  175. package/tests/utils/linter/fixtures/json/syntax-error.json +1 -0
  176. package/tests/utils/linter/fixtures/json/undeclare-variable.json +1 -0
  177. package/tests/utils/linter/fixtures/json/unused-variable.json +1 -0
  178. package/tests/utils/linter/fixtures/json/valid-code.json +1 -0
  179. package/tests/utils/linter/fixtures/jsx/keyword-error.jsx +5 -0
  180. package/tests/utils/linter/fixtures/jsx/missing-semicolon.jsx +5 -0
  181. package/tests/utils/linter/fixtures/jsx/syntax-error.jsx +5 -0
  182. package/tests/utils/linter/fixtures/jsx/undeclare-variable.jsx +5 -0
  183. package/tests/utils/linter/fixtures/jsx/unused-variable.jsx +4 -0
  184. package/tests/utils/linter/fixtures/jsx/valid-code.jsx +5 -0
  185. package/tests/utils/linter/fixtures/python/keyword-error.py +3 -0
  186. package/tests/utils/linter/fixtures/python/missing-semicolon.py +2 -0
  187. package/tests/utils/linter/fixtures/python/syntax-error.py +3 -0
  188. package/tests/utils/linter/fixtures/python/undeclare-variable.py +3 -0
  189. package/tests/utils/linter/fixtures/python/unused-variable.py +6 -0
  190. package/tests/utils/linter/fixtures/python/valid-code.py +12 -0
  191. package/tests/utils/linter/fixtures/ruby/keyword-error.rb +2 -0
  192. package/tests/utils/linter/fixtures/ruby/missing-semicolon.rb +1 -0
  193. package/tests/utils/linter/fixtures/ruby/syntax-error.rb +2 -0
  194. package/tests/utils/linter/fixtures/ruby/undeclare-variable.rb +1 -0
  195. package/tests/utils/linter/fixtures/ruby/unused-variable.rb +2 -0
  196. package/tests/utils/linter/fixtures/ruby/valid-code.rb +1 -0
  197. package/tests/utils/linter/fixtures/sass/keyword-error.sass +2 -0
  198. package/tests/utils/linter/fixtures/sass/missing-semicolon.sass +3 -0
  199. package/tests/utils/linter/fixtures/sass/syntax-error.sass +3 -0
  200. package/tests/utils/linter/fixtures/sass/undeclare-variable.sass +2 -0
  201. package/tests/utils/linter/fixtures/sass/unused-variable.sass +4 -0
  202. package/tests/utils/linter/fixtures/sass/valid-code.sass +2 -0
  203. package/tests/utils/linter/fixtures/scss/keyword-error.scss +1 -0
  204. package/tests/utils/linter/fixtures/scss/missing-semicolon.scss +1 -0
  205. package/tests/utils/linter/fixtures/scss/syntax-error.scss +1 -0
  206. package/tests/utils/linter/fixtures/scss/undeclare-variable.scss +1 -0
  207. package/tests/utils/linter/fixtures/scss/unused-variable.scss +2 -0
  208. package/tests/utils/linter/fixtures/scss/valid-code.scss +1 -0
  209. package/tests/utils/linter/fixtures/shell/keyword-error.sh +5 -0
  210. package/tests/utils/linter/fixtures/shell/missing-semicolon.sh +3 -0
  211. package/tests/utils/linter/fixtures/shell/syntax-error.sh +4 -0
  212. package/tests/utils/linter/fixtures/shell/undeclare-variable.sh +3 -0
  213. package/tests/utils/linter/fixtures/shell/unused-variable.sh +4 -0
  214. package/tests/utils/linter/fixtures/shell/valid-code.sh +3 -0
  215. package/tests/utils/linter/fixtures/ts/keyword-error.ts +1 -0
  216. package/tests/utils/linter/fixtures/ts/missing-semicolon.ts +1 -0
  217. package/tests/utils/linter/fixtures/ts/syntax-error.ts +1 -0
  218. package/tests/utils/linter/fixtures/ts/undeclare-variable.ts +1 -0
  219. package/tests/utils/linter/fixtures/ts/unused-variable.ts +3 -0
  220. package/tests/utils/linter/fixtures/ts/valid-code.ts +3 -0
  221. package/tests/utils/linter/fixtures/tsx/keyword-error.tsx +5 -0
  222. package/tests/utils/linter/fixtures/tsx/missing-semicolon.tsx +5 -0
  223. package/tests/utils/linter/fixtures/tsx/syntax-error.tsx +5 -0
  224. package/tests/utils/linter/fixtures/tsx/undeclare-variable.tsx +6 -0
  225. package/tests/utils/linter/fixtures/tsx/unused-variable.tsx +6 -0
  226. package/tests/utils/linter/fixtures/tsx/valid-code.tsx +5 -0
  227. package/tests/utils/linter/fixtures/vue/keyword-error.vue +6 -0
  228. package/tests/utils/linter/fixtures/vue/missing-semicolon.vue +6 -0
  229. package/tests/utils/linter/fixtures/vue/syntax-error.vue +6 -0
  230. package/tests/utils/linter/fixtures/vue/undeclare-variable.vue +6 -0
  231. package/tests/utils/linter/fixtures/vue/unused-variable.vue +7 -0
  232. package/tests/utils/linter/fixtures/vue/valid-code.vue +6 -0
  233. package/tests/utils/linter/fixtures/yaml/keyword-error.yml +1 -0
  234. package/tests/utils/linter/fixtures/yaml/missing-semicolon.yml +2 -0
  235. package/tests/utils/linter/fixtures/yaml/syntax-error.yml +1 -0
  236. package/tests/utils/linter/fixtures/yaml/undeclare-variable.yml +1 -0
  237. package/tests/utils/linter/fixtures/yaml/unused-variable.yml +2 -0
  238. package/tests/utils/linter/fixtures/yaml/valid-code.yml +3 -0
  239. package/tests/utils/linter/index.test.mjs +440 -0
  240. package/tests/utils/linter/scan-results.mjs +42 -0
  241. package/tests/utils/markdown/index.test.mjs +478 -0
  242. package/tests/utils/mermaid-validator.test.mjs +2 -2
  243. package/tests/utils/utils.test.mjs +3 -1
  244. package/types/document-schema.mjs +54 -0
  245. package/types/document-structure-schema.mjs +244 -0
  246. package/utils/auth-utils.mjs +131 -6
  247. package/utils/conflict-detector.mjs +5 -1
  248. package/utils/{constants.mjs → constants/index.mjs} +109 -0
  249. package/utils/constants/linter.mjs +102 -0
  250. package/utils/d2-utils.mjs +2 -4
  251. package/utils/debug.mjs +3 -0
  252. package/utils/deploy.mjs +81 -385
  253. package/utils/evaluate/report-utils.mjs +131 -0
  254. package/utils/file-utils.mjs +36 -1
  255. package/utils/kroki-utils.mjs +1 -1
  256. package/utils/linter/index.mjs +50 -0
  257. package/utils/markdown/index.mjs +26 -0
  258. package/utils/markdown-checker.mjs +1 -1
  259. package/utils/utils.mjs +19 -7
  260. package/prompts/structure/generate-structure.md +0 -161
@@ -0,0 +1,106 @@
1
+ import { rm } from "node:fs/promises";
2
+ import { join } from "node:path";
3
+ import { pathExists, toDisplayPath } from "../../utils/file-utils.mjs";
4
+
5
+ export default async function clearDocumentStructure(input = {}, _options = {}) {
6
+ const { docsDir, workDir } = input;
7
+ const cwd = workDir || process.cwd();
8
+
9
+ // Fixed path where structure-plan.json is saved
10
+ const outputDir = join(cwd, ".aigne", "doc-smith", "output");
11
+ const structurePlanPath = join(outputDir, "structure-plan.json");
12
+
13
+ const results = [];
14
+ let hasError = false;
15
+
16
+ // Clear structure-plan.json
17
+ try {
18
+ const structureExists = await pathExists(structurePlanPath);
19
+ await rm(structurePlanPath, { force: true });
20
+
21
+ const structureDisplayPath = toDisplayPath(structurePlanPath);
22
+ const structureMessage = structureExists
23
+ ? `Cleared document structure plan (${structureDisplayPath})`
24
+ : `Document structure plan already empty (${structureDisplayPath})`;
25
+
26
+ results.push({
27
+ type: "structure",
28
+ cleared: structureExists,
29
+ message: structureMessage,
30
+ });
31
+ } catch (error) {
32
+ hasError = true;
33
+ results.push({
34
+ type: "structure",
35
+ error: true,
36
+ message: `Failed to clear document structure plan: ${error.message}`,
37
+ });
38
+ }
39
+
40
+ // Clear documents directory if provided
41
+ if (docsDir) {
42
+ try {
43
+ const docsExists = await pathExists(docsDir);
44
+ await rm(docsDir, { recursive: true, force: true });
45
+
46
+ const docsDisplayPath = toDisplayPath(docsDir);
47
+ const docsMessage = docsExists
48
+ ? `Cleared documents directory (${docsDisplayPath})`
49
+ : `Documents directory already empty (${docsDisplayPath})`;
50
+
51
+ results.push({
52
+ type: "documents",
53
+ cleared: docsExists,
54
+ message: docsMessage,
55
+ });
56
+ } catch (error) {
57
+ hasError = true;
58
+ results.push({
59
+ type: "documents",
60
+ error: true,
61
+ message: `Failed to clear documents directory: ${error.message}`,
62
+ });
63
+ }
64
+ }
65
+
66
+ // Prepare summary message
67
+ const clearedItems = results.filter((r) => r.cleared).length;
68
+ const errorItems = results.filter((r) => r.error).length;
69
+
70
+ let header;
71
+ if (errorItems > 0) {
72
+ header = "Document structure cleanup finished with some issues.";
73
+ } else if (clearedItems > 0) {
74
+ header = "Document structure cleared successfully!";
75
+ } else {
76
+ header = "Document structure already empty.";
77
+ }
78
+
79
+ const detailLines = results.map((item) => `- ${item.message}`).join("\n");
80
+ const message = [header, "", detailLines].filter(Boolean).join("\n");
81
+
82
+ return {
83
+ message,
84
+ results,
85
+ hasError,
86
+ clearedCount: clearedItems,
87
+ };
88
+ }
89
+
90
+ clearDocumentStructure.input_schema = {
91
+ type: "object",
92
+ properties: {
93
+ docsDir: {
94
+ type: "string",
95
+ description: "The documents directory to clear (optional)",
96
+ },
97
+ workDir: {
98
+ type: "string",
99
+ description: "The working directory (defaults to current directory)",
100
+ },
101
+ },
102
+ };
103
+
104
+ clearDocumentStructure.taskTitle = "Clear document structure and all generated documents";
105
+ clearDocumentStructure.description =
106
+ "Clear the document structure plan (structure-plan.json) and optionally the documents directory";
@@ -0,0 +1,51 @@
1
+ import { rm } from "node:fs/promises";
2
+ import { pathExists, resolveToAbsolute, toDisplayPath } from "../../utils/file-utils.mjs";
3
+
4
+ export default async function clearGeneratedDocs(input = {}, _options = {}) {
5
+ const { docsDir } = input;
6
+
7
+ if (!docsDir) {
8
+ return {
9
+ message: "No generated documents directory specified",
10
+ };
11
+ }
12
+
13
+ const generatedDocsPath = resolveToAbsolute(docsDir);
14
+
15
+ const displayPath = toDisplayPath(generatedDocsPath);
16
+
17
+ try {
18
+ const existed = await pathExists(generatedDocsPath);
19
+ await rm(generatedDocsPath, { recursive: true, force: true });
20
+
21
+ const message = existed
22
+ ? `Cleared generated documents (${displayPath})`
23
+ : `Generated documents already empty (${displayPath})`;
24
+
25
+ return {
26
+ message,
27
+ cleared: existed,
28
+ path: displayPath,
29
+ };
30
+ } catch (error) {
31
+ return {
32
+ message: `Failed to clear generated documents: ${error.message}`,
33
+ error: true,
34
+ path: displayPath,
35
+ };
36
+ }
37
+ }
38
+
39
+ clearGeneratedDocs.input_schema = {
40
+ type: "object",
41
+ properties: {
42
+ docsDir: {
43
+ type: "string",
44
+ description: "The generated documents directory to clear",
45
+ },
46
+ },
47
+ required: ["docsDir"],
48
+ };
49
+
50
+ clearGeneratedDocs.taskTitle = "Clear all generated documents";
51
+ clearGeneratedDocs.description = "Clear the generated documents directory";
@@ -0,0 +1,23 @@
1
+ type: team
2
+ name: clear
3
+ alias:
4
+ - clear
5
+ description: Clear various types of data including document structure, generated documents, configuration, and authorization tokens
6
+ skills:
7
+ - url: ../init/index.mjs
8
+ default_input:
9
+ skipIfExists: true
10
+ - ./choose-contents.mjs
11
+ input_schema:
12
+ type: object
13
+ properties:
14
+ targets:
15
+ type: array
16
+ description: Items to clear without confirmation
17
+ items:
18
+ type: string
19
+ enum:
20
+ - documentStructure
21
+ - generatedDocs
22
+ - documentConfig
23
+ - authTokens
@@ -0,0 +1,93 @@
1
+ import pMap from "p-map";
2
+ import pRetry from "p-retry";
3
+ import {
4
+ CODE_LANGUAGE_MAP_LINTER,
5
+ CODE_LANGUAGE_MAP_SUFFIX,
6
+ } from "../../utils/constants/linter.mjs";
7
+ import { debug } from "../../utils/debug.mjs";
8
+ import { lintCode } from "../../utils/linter/index.mjs";
9
+ import { getMarkdownAst, traverseMarkdownAst } from "../../utils/markdown/index.mjs";
10
+
11
+ const severityMapLevel = {
12
+ error: "critical",
13
+ warning: "minor",
14
+ };
15
+
16
+ export default async function evaluateDocumentCode({ content }) {
17
+ const ast = getMarkdownAst({ markdown: content });
18
+ const checkPromiseList = [];
19
+ const checkListResult = [];
20
+ let totalCount = 0;
21
+ let ignoreCount = 0;
22
+ let errorCount = 0;
23
+
24
+ traverseMarkdownAst({
25
+ ast,
26
+ test: "code",
27
+ visitor(node) {
28
+ const linter = CODE_LANGUAGE_MAP_LINTER[node.lang];
29
+ if (linter) {
30
+ const suffix = CODE_LANGUAGE_MAP_SUFFIX[node.lang];
31
+ checkPromiseList.push({ linter, code: node.value, suffix });
32
+ totalCount += 1;
33
+ } else {
34
+ ignoreCount += 1;
35
+ }
36
+ },
37
+ });
38
+ const checkList = await pMap(
39
+ checkPromiseList,
40
+ async (item) => {
41
+ const result = await pRetry(() => lintCode(item), {
42
+ onFailedAttempt: ({ error, attemptNumber, retriesLeft }) => {
43
+ debug(
44
+ `Attempt ${attemptNumber} failed: ${error.message}. There are ${retriesLeft} retries left.`,
45
+ );
46
+ },
47
+ retries: 3,
48
+ });
49
+ // lint occurs error, ignore
50
+ if (!result.success) {
51
+ debug("Lint failed", item, result);
52
+ return [];
53
+ }
54
+
55
+ if (!result.issues || result.issues.length === 0) {
56
+ debug("Lint result empty issues", item, result);
57
+ return [];
58
+ }
59
+
60
+ errorCount += 1;
61
+ return result.issues.map((x) => {
62
+ return {
63
+ ...x,
64
+ level: severityMapLevel[x.severity],
65
+ };
66
+ });
67
+ },
68
+ { concurrency: 5 },
69
+ );
70
+ checkListResult.push(...checkList.flat());
71
+
72
+ return {
73
+ codeEvaluation: {
74
+ baseline: 100,
75
+ details: checkListResult,
76
+ totalCount,
77
+ ignoreCount,
78
+ errorCount,
79
+ },
80
+ };
81
+ }
82
+
83
+ evaluateDocumentCode.description = "Traverse markdown code blocks and evaluate them.";
84
+
85
+ evaluateDocumentCode.input_schema = {
86
+ type: "object",
87
+ properties: {
88
+ content: {
89
+ type: "string",
90
+ description: "Source markdown content to be evaluated.",
91
+ },
92
+ },
93
+ };
@@ -0,0 +1,70 @@
1
+ name: evaluateDocumentStructure
2
+ description: Evaluates the results generated by the document-structure agent to ensure they meet expectations, especially in scenarios with previous generation results and user feedback.
3
+ instructions:
4
+ url: ../../prompts/evaluate/document-structure.md
5
+ model: openai/gpt-5
6
+ # model: anthropic/claude-opus-4-0
7
+ task_render_mode: collapse
8
+ task_title: Evaluate the structure of the documentation
9
+ input_schema:
10
+ type: object
11
+ properties:
12
+ documentStructureYaml:
13
+ type: string
14
+ description: Document structure planning
15
+ purposes:
16
+ type: string
17
+ description: User-selected document goals
18
+ audiences:
19
+ type: string
20
+ description: User-selected target audiences
21
+ coverageDepth:
22
+ type: string
23
+ description: User-selected content depth
24
+ required:
25
+ - documentStructureYaml
26
+ - purposes
27
+ - audiences
28
+ - coverageDepth
29
+ output_schema:
30
+ type: object
31
+ properties:
32
+ structureEvaluation:
33
+ type: object
34
+ properties:
35
+ baseline:
36
+ type: integer
37
+ description: Baseline score of selected purposes
38
+ details:
39
+ type: array
40
+ items:
41
+ type: object
42
+ properties:
43
+ dimension:
44
+ type: string
45
+ enum: [purposeCoverage, audienceCoverage, depthCoverage]
46
+ description: Dimension associated with this observation
47
+ level:
48
+ type: string
49
+ enum: [excellent, good, meets, minor, critical]
50
+ description: Evaluation level applied to the observation
51
+ topic:
52
+ type: string
53
+ description: Short identifier for the purpose/audience/depth aspect being judged
54
+ description:
55
+ type: string
56
+ description: Why the level was assigned
57
+ line:
58
+ type: integer
59
+ description: Integer line number within the source document/module (use 0 if unknown)
60
+ required:
61
+ - dimension
62
+ - level
63
+ - topic
64
+ - description
65
+ description: List of detailed evaluations for each purpose dimension
66
+ required:
67
+ - baseline
68
+ - details
69
+ required:
70
+ - structureEvaluation
@@ -0,0 +1,79 @@
1
+ name: evaluateDocument
2
+ description: Evaluates the quality of generated document content, ensuring compliance with user-configured goals, audiences, and knowledge level requirements.
3
+ instructions:
4
+ url: ../../prompts/evaluate/document.md
5
+ model: openai/gpt-5
6
+ # model: anthropic/claude-opus-4-0
7
+ task_render_mode: collapse
8
+ task_title: Evaluate document for '{{ title }}'
9
+ input_schema:
10
+ type: object
11
+ properties:
12
+ content:
13
+ type: string
14
+ description: Document content to be evaluated
15
+ translationsString:
16
+ type: string
17
+ description: Document translation content
18
+ description:
19
+ type: string
20
+ description: Document content planning description
21
+ purposes:
22
+ type: string
23
+ description: User-selected document goals
24
+ audiences:
25
+ type: string
26
+ description: User-selected target audiences
27
+ readerKnowledgeLevel:
28
+ type: string
29
+ description: User-selected reader knowledge level
30
+ required:
31
+ - content
32
+ - description
33
+ - purposes
34
+ - audiences
35
+ - readerKnowledgeLevel
36
+ output_schema:
37
+ type: object
38
+ properties:
39
+ documentEvaluation:
40
+ type: object
41
+ properties:
42
+ baseline:
43
+ type: integer
44
+ description: Fixed baseline score (80)
45
+ details:
46
+ type: array
47
+ description: Detailed observations contributing to the final score
48
+ items:
49
+ type: object
50
+ properties:
51
+ dimension:
52
+ type: string
53
+ enum: [readability, coherence, contentQuality, consistency, purposeAlignment, audienceAlignment, knowledgeLevelAlignment, navigability]
54
+ description: Dimension associated with this observation
55
+ level:
56
+ type: string
57
+ enum: [excellent, good, meets, minor, critical]
58
+ description: Evaluation level applied to the observation
59
+ topic:
60
+ type: string
61
+ description: Short identifier for the assessed passage or section
62
+ line:
63
+ type: integer
64
+ description: Source line number related to the observation (0 if unknown)
65
+ description:
66
+ type: string
67
+ description: Impact-focused explanation of the observation
68
+ required:
69
+ - dimension
70
+ - level
71
+ - topic
72
+ - line
73
+ - description
74
+ required:
75
+ - baseline
76
+ - details
77
+ required:
78
+ - documentEvaluation
79
+ includeInputInOutput: true
@@ -0,0 +1,78 @@
1
+ import { writeFile } from "node:fs/promises";
2
+ import { join } from "node:path";
3
+ import { pick } from "@aigne/core/utils/type-utils.js";
4
+ import { DOC_SMITH_DIR } from "../../utils/constants/index.mjs";
5
+ import {
6
+ copyHtmlReportTemplate,
7
+ createReportStructure,
8
+ ensureDirectoryExists,
9
+ generateReportSuccessMessage,
10
+ generateTimestampForFolder,
11
+ } from "../../utils/evaluate/report-utils.mjs";
12
+ import { toRelativePath } from "../../utils/utils.mjs";
13
+
14
+ /**
15
+ * Generate and save evaluation report by aggregating results from both structure and document evaluation agents
16
+ * @param {Object} params - Parameters object containing all evaluation data
17
+ * @param {Object} params.purposeCoverage - Purpose coverage evaluation from evaluate/document-structure agent
18
+ * @param {Object} params.audienceCoverage - Audience coverage evaluation from evaluate/document-structure agent
19
+ * @param {Object} params.coverageDepthAlignment - Coverage depth alignment evaluation from evaluate/document-structure agent
20
+ * @param {Array} params.originalDocumentStructure - Array of document evaluation results from evaluate/document agent
21
+ * @param {Object} [params.metadata] - Additional metadata for the report
22
+ * @param {string} [params.basePath] - Base path for saving reports, defaults to current working directory
23
+ * @returns {Promise<string>} Path to the saved report file
24
+ */
25
+ export default async function generateEvaluationReport({
26
+ structureEvaluation,
27
+ originalDocumentStructure,
28
+ metadata = {},
29
+ basePath = process.cwd(),
30
+ projectName,
31
+ projectDesc,
32
+ projectLogo,
33
+ documentPurpose,
34
+ targetAudienceTypes,
35
+ readerKnowledgeLevel,
36
+ documentationDepth,
37
+ targetAudience,
38
+ }) {
39
+ const timestamp = new Date().toISOString();
40
+ const timestampForFolder = generateTimestampForFolder();
41
+ const documentEvaluations = originalDocumentStructure.map((x) =>
42
+ pick(x, ["title", "description", "path", "parentId", "documentEvaluation", "codeEvaluation"]),
43
+ );
44
+
45
+ // Create report structure
46
+ const report = createReportStructure({
47
+ timestamp,
48
+ metadata,
49
+ structureEvaluation,
50
+ documentEvaluations,
51
+ projectName,
52
+ projectDesc,
53
+ projectLogo,
54
+ documentPurpose,
55
+ targetAudienceTypes,
56
+ readerKnowledgeLevel,
57
+ documentationDepth,
58
+ targetAudience,
59
+ });
60
+
61
+ const saveDir = join(basePath, DOC_SMITH_DIR, "evaluate", timestampForFolder);
62
+ const jsonReportPath = join(saveDir, "integrity-report.json");
63
+
64
+ await ensureDirectoryExists(saveDir);
65
+ await writeFile(jsonReportPath, JSON.stringify(report, null, 2), "utf8");
66
+
67
+ // Copy HTML report template
68
+ const htmlReportPath = await copyHtmlReportTemplate(saveDir, report);
69
+
70
+ // Generate success message
71
+ const message = generateReportSuccessMessage(toRelativePath(jsonReportPath), htmlReportPath);
72
+
73
+ return {
74
+ message,
75
+ };
76
+ }
77
+
78
+ generateEvaluationReport.taskTitle = "Generate evaluation report";
@@ -0,0 +1,39 @@
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
+ - ../utils/load-sources.mjs
9
+ - ../utils/format-document-structure.mjs
10
+ - type: transform
11
+ name: transformData
12
+ task_render_mode: hide
13
+ jsonata: |
14
+ $merge([
15
+ $,
16
+ {
17
+ "documentStructure": originalDocumentStructure,
18
+ "datasources": "",
19
+ "datasourcesList": ""
20
+ }
21
+ ])
22
+ - ./document-structure.yaml
23
+ - type: team
24
+ name: batchEvaluateDocument
25
+ skills:
26
+ - ../utils/load-document-all-content.mjs
27
+ - ./document.yaml
28
+ - ./code-snippet.mjs
29
+ - type: transform
30
+ task_render_mode: hide
31
+ jsonata: |
32
+ $merge([
33
+ $
34
+ ])
35
+ iterate_on: originalDocumentStructure
36
+ concurrency: 5
37
+ mode: sequential
38
+ - ./generate-report.mjs
39
+ mode: sequential
@@ -0,0 +1,56 @@
1
+ import {
2
+ getAddDocumentInputJsonSchema,
3
+ getAddDocumentOutputJsonSchema,
4
+ validateAddDocumentInput,
5
+ } from "../../../types/document-structure-schema.mjs";
6
+
7
+ export default async function addDocument(input) {
8
+ // Validate input using Zod schema
9
+ const validation = validateAddDocumentInput(input);
10
+ if (!validation.success) {
11
+ console.log(`⚠️ Cannot add document: ${validation.error}`);
12
+ return { documentStructure: input.documentStructure };
13
+ }
14
+
15
+ const { documentStructure, title, description, path, parentId, sourceIds } = validation.data;
16
+
17
+ // Validate parent exists if parentId is provided
18
+ if (parentId && parentId !== "null") {
19
+ const parentExists = documentStructure.some((item) => item.path === parentId);
20
+ if (!parentExists) {
21
+ console.log(`⚠️ Cannot add document: Parent document '${parentId}' not found.`);
22
+ return { documentStructure };
23
+ }
24
+ }
25
+
26
+ // Check if document with same path already exists
27
+ const existingDocument = documentStructure.find((item) => item.path === path);
28
+ if (existingDocument) {
29
+ console.log(
30
+ `⚠️ Cannot add document: A document with path '${path}' already exists. Choose a different path.`,
31
+ );
32
+ return { documentStructure };
33
+ }
34
+
35
+ // Create new document object
36
+ const newDocument = {
37
+ title,
38
+ description,
39
+ path,
40
+ parentId: parentId || null,
41
+ sourceIds: [...sourceIds], // Create a copy of the array
42
+ };
43
+
44
+ // Add the new document to the document structure
45
+ const updatedStructure = [...documentStructure, newDocument];
46
+
47
+ return {
48
+ documentStructure: updatedStructure,
49
+ addedDocument: newDocument,
50
+ };
51
+ }
52
+
53
+ addDocument.taskTitle = "Add new document";
54
+ addDocument.description = "Add a new document to the document structure";
55
+ addDocument.inputSchema = getAddDocumentInputJsonSchema();
56
+ addDocument.outputSchema = getAddDocumentOutputJsonSchema();
@@ -0,0 +1,49 @@
1
+ import {
2
+ getDeleteDocumentInputJsonSchema,
3
+ getDeleteDocumentOutputJsonSchema,
4
+ validateDeleteDocumentInput,
5
+ } from "../../../types/document-structure-schema.mjs";
6
+
7
+ export default async function deleteDocument(input) {
8
+ // Validate input using Zod schema
9
+ const validation = validateDeleteDocumentInput(input);
10
+ if (!validation.success) {
11
+ console.log(`⚠️ Cannot delete document: ${validation.error}`);
12
+ return { documentStructure: input.documentStructure };
13
+ }
14
+
15
+ const { documentStructure, path } = validation.data;
16
+
17
+ // Find the document to delete
18
+ const documentIndex = documentStructure.findIndex((item) => item.path === path);
19
+ if (documentIndex === -1) {
20
+ console.log(
21
+ `⚠️ Cannot delete document: Document '${path}' does not exist. Please choose an existing document to delete.`,
22
+ );
23
+ return { documentStructure };
24
+ }
25
+
26
+ const documentToDelete = documentStructure[documentIndex];
27
+
28
+ // Check if any other documents have this document as parent
29
+ const childDocuments = documentStructure.filter((item) => item.parentId === path);
30
+ if (childDocuments.length > 0) {
31
+ console.log(
32
+ `⚠️ Cannot delete document: Document '${path}' has ${childDocuments.length} child document(s): ${childDocuments.map((p) => p.path).join(", ")}. Please first move or delete these child documents.`,
33
+ );
34
+ return { documentStructure };
35
+ }
36
+
37
+ // Remove the document from the document structure
38
+ const updatedStructure = documentStructure.filter((_, index) => index !== documentIndex);
39
+
40
+ return {
41
+ documentStructure: updatedStructure,
42
+ deletedDocument: documentToDelete,
43
+ };
44
+ }
45
+
46
+ deleteDocument.taskTitle = "Delete document";
47
+ deleteDocument.description = "Delete a document from the document structure";
48
+ deleteDocument.inputSchema = getDeleteDocumentInputJsonSchema();
49
+ deleteDocument.outputSchema = getDeleteDocumentOutputJsonSchema();