@aigne/doc-smith 0.8.11-beta.4 → 0.8.11-beta.6

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 (118) hide show
  1. package/.aigne/doc-smith/config.yaml +2 -4
  2. package/.release-please-manifest.json +1 -1
  3. package/CHANGELOG.md +17 -2
  4. package/README.md +1 -1
  5. package/agents/clear/choose-contents.mjs +2 -2
  6. package/agents/clear/clear-document-structure.mjs +8 -8
  7. package/agents/clear/index.yaml +1 -1
  8. package/agents/evaluate/document-structure.yaml +1 -1
  9. package/agents/generate/check-d2-diagram-valid.mjs +26 -0
  10. package/agents/generate/check-document-structure.yaml +3 -3
  11. package/agents/generate/check-need-generate-structure.mjs +8 -8
  12. package/agents/generate/document-structure-tools/add-document.mjs +3 -3
  13. package/agents/generate/document-structure-tools/delete-document.mjs +2 -2
  14. package/agents/generate/document-structure-tools/move-document.mjs +3 -2
  15. package/agents/generate/document-structure-tools/update-document.mjs +2 -2
  16. package/agents/generate/generate-d2-diagram.yaml +23 -0
  17. package/agents/generate/generate-structure.yaml +1 -1
  18. package/agents/generate/merge-d2-diagram.yaml +39 -0
  19. package/agents/generate/update-document-structure.yaml +3 -3
  20. package/agents/generate/user-review-document-structure.mjs +10 -10
  21. package/agents/init/index.mjs +18 -10
  22. package/agents/publish/publish-docs.mjs +17 -20
  23. package/agents/update/batch-generate-document.yaml +1 -1
  24. package/agents/update/check-document.mjs +2 -2
  25. package/agents/update/generate-document.yaml +25 -0
  26. package/agents/utils/check-feedback-refiner.mjs +1 -1
  27. package/agents/utils/choose-docs.mjs +1 -1
  28. package/agents/utils/load-document-all-content.mjs +3 -3
  29. package/agents/utils/load-sources.mjs +1 -1
  30. package/agents/utils/save-docs.mjs +7 -28
  31. package/aigne.yaml +2 -2
  32. package/docs/_sidebar.md +1 -1
  33. package/docs/advanced-how-it-works.md +3 -3
  34. package/docs/advanced-quality-assurance.md +1 -1
  35. package/docs/cli-reference.ja.md +151 -80
  36. package/docs/cli-reference.md +126 -55
  37. package/docs/cli-reference.zh-TW.md +133 -62
  38. package/docs/cli-reference.zh.md +143 -72
  39. package/docs/configuration-interactive-setup.md +1 -1
  40. package/docs/configuration-language-support.md +1 -1
  41. package/docs/configuration-preferences.md +1 -1
  42. package/docs/configuration.ja.md +104 -48
  43. package/docs/configuration.md +58 -2
  44. package/docs/configuration.zh-TW.md +99 -42
  45. package/docs/configuration.zh.md +78 -21
  46. package/docs/features-generate-documentation.ja.md +63 -44
  47. package/docs/features-generate-documentation.md +54 -35
  48. package/docs/features-generate-documentation.zh-TW.md +67 -48
  49. package/docs/features-generate-documentation.zh.md +61 -41
  50. package/docs/features-publish-your-docs.ja.md +69 -46
  51. package/docs/features-publish-your-docs.md +65 -42
  52. package/docs/features-publish-your-docs.zh-TW.md +73 -50
  53. package/docs/features-publish-your-docs.zh.md +67 -44
  54. package/docs/features-translate-documentation.ja.md +35 -33
  55. package/docs/features-translate-documentation.md +24 -22
  56. package/docs/features-translate-documentation.zh-TW.md +32 -30
  57. package/docs/features-translate-documentation.zh.md +29 -27
  58. package/docs/features-update-and-refine.ja.md +120 -66
  59. package/docs/features-update-and-refine.md +110 -56
  60. package/docs/features-update-and-refine.zh-TW.md +116 -62
  61. package/docs/features-update-and-refine.zh.md +118 -64
  62. package/docs/getting-started.ja.md +22 -22
  63. package/docs/getting-started.md +1 -1
  64. package/docs/getting-started.zh-TW.md +16 -16
  65. package/docs/getting-started.zh.md +28 -28
  66. package/docs/overview.md +3 -3
  67. package/docs-mcp/analyze-docs-relevance.yaml +6 -6
  68. package/docs-mcp/docs-search.yaml +1 -1
  69. package/package.json +3 -3
  70. package/prompts/common/document-structure/conflict-resolution-guidance.md +3 -3
  71. package/prompts/common/document-structure/document-structure-rules.md +2 -2
  72. package/prompts/detail/{d2-chart/rules.md → d2-diagram/rules-system.md} +41 -5
  73. package/prompts/detail/d2-diagram/rules-user.md +4 -0
  74. package/prompts/detail/document-rules.md +3 -4
  75. package/prompts/detail/generate-document.md +8 -2
  76. package/prompts/detail/update-document.md +0 -2
  77. package/prompts/evaluate/document-structure.md +6 -6
  78. package/prompts/structure/check-document-structure.md +10 -10
  79. package/prompts/structure/document-rules.md +2 -2
  80. package/prompts/structure/generate-structure-system.md +3 -3
  81. package/prompts/structure/structure-example.md +1 -1
  82. package/prompts/structure/structure-getting-started.md +1 -1
  83. package/prompts/structure/update-document-structure.md +9 -9
  84. package/prompts/utils/feedback-refiner.md +1 -1
  85. package/tests/agents/clear/choose-contents.test.mjs +1 -1
  86. package/tests/agents/clear/clear-document-structure.test.mjs +36 -30
  87. package/tests/agents/evaluate/generate-report.test.mjs +1 -1
  88. package/tests/agents/generate/check-need-generate-structure.test.mjs +1 -1
  89. package/tests/agents/generate/document-structure-tools/add-document.test.mjs +2 -2
  90. package/tests/agents/generate/document-structure-tools/delete-document.test.mjs +4 -4
  91. package/tests/agents/generate/document-structure-tools/move-document.test.mjs +3 -3
  92. package/tests/agents/generate/document-structure-tools/update-document.test.mjs +3 -3
  93. package/tests/agents/generate/user-review-document-structure.test.mjs +7 -5
  94. package/tests/agents/init/init.test.mjs +25 -19
  95. package/tests/agents/publish/publish-docs.test.mjs +99 -0
  96. package/tests/agents/update/check-document.test.mjs +1 -1
  97. package/tests/agents/utils/check-detail-result.test.mjs +2 -15
  98. package/tests/agents/utils/format-document-structure.test.mjs +5 -5
  99. package/tests/agents/utils/load-sources.test.mjs +4 -4
  100. package/tests/agents/utils/save-docs.test.mjs +1 -1
  101. package/tests/utils/auth-utils.test.mjs +1 -1
  102. package/tests/utils/conflict-detector.test.mjs +1 -1
  103. package/tests/utils/d2-utils.test.mjs +4 -4
  104. package/tests/utils/deploy.test.mjs +3 -10
  105. package/tests/utils/docs-finder-utils.test.mjs +8 -8
  106. package/tests/utils/kroki-utils.test.mjs +5 -5
  107. package/tests/utils/preferences-utils.test.mjs +5 -3
  108. package/tests/utils/save-value-to-config.test.mjs +3 -1
  109. package/types/document-structure-schema.mjs +9 -9
  110. package/utils/auth-utils.mjs +4 -0
  111. package/utils/conflict-detector.mjs +1 -1
  112. package/utils/constants/index.mjs +7 -4
  113. package/utils/d2-utils.mjs +11 -6
  114. package/utils/deploy.mjs +4 -20
  115. package/utils/docs-finder-utils.mjs +11 -11
  116. package/utils/kroki-utils.mjs +5 -4
  117. package/utils/markdown-checker.mjs +1 -21
  118. /package/prompts/detail/{d2-chart → d2-diagram}/official-examples.md +0 -0
@@ -5,13 +5,17 @@ import chalk from "chalk";
5
5
  import fs from "fs-extra";
6
6
 
7
7
  import { getAccessToken } from "../../utils/auth-utils.mjs";
8
- import { DISCUSS_KIT_STORE_URL, TMP_DIR, TMP_DOCS_DIR } from "../../utils/constants/index.mjs";
8
+ import {
9
+ DEFAULT_APP_URL,
10
+ DISCUSS_KIT_STORE_URL,
11
+ DOC_SMITH_DIR,
12
+ TMP_DIR,
13
+ TMP_DOCS_DIR,
14
+ } from "../../utils/constants/index.mjs";
9
15
  import { beforePublishHook, ensureTmpDir } from "../../utils/d2-utils.mjs";
10
16
  import { deploy } from "../../utils/deploy.mjs";
11
17
  import { getGithubRepoUrl, loadConfigFromFile, saveValueToConfig } from "../../utils/utils.mjs";
12
18
 
13
- const DEFAULT_APP_URL = "https://docsmith.aigne.io";
14
-
15
19
  export default async function publishDocs(
16
20
  { docsDir: rawDocsDir, appUrl, boardId, projectName, projectDesc, projectLogo },
17
21
  options,
@@ -19,9 +23,7 @@ export default async function publishDocs(
19
23
  // move work dir to tmp-dir
20
24
  await ensureTmpDir();
21
25
 
22
- const hasDocSmithBaseUrl = !!process.env.DOC_SMITH_BASE_URL;
23
-
24
- const docsDir = join(".aigne", "doc-smith", TMP_DIR, TMP_DOCS_DIR);
26
+ const docsDir = join(DOC_SMITH_DIR, TMP_DIR, TMP_DOCS_DIR);
25
27
  await fs.rm(docsDir, { recursive: true, force: true });
26
28
  await fs.mkdir(docsDir, {
27
29
  recursive: true,
@@ -61,22 +63,18 @@ export default async function publishDocs(
61
63
  name: `${chalk.blue("Your existing website")} - Integrate and publish directly on your current site (setup required)`,
62
64
  value: "custom",
63
65
  },
64
- ...(hasCachedCheckoutId && hasDocSmithBaseUrl
66
+ ...(hasCachedCheckoutId
65
67
  ? [
66
68
  {
67
- name: `${chalk.yellow("Resume previous website setup")} - ${chalk.green("Already paid.")} Continue where you left off. Your payment is already processed.`,
69
+ name: `${chalk.yellow("Resume previous website setup")} - ${chalk.green("Already paid.")} Continue where you left off. Your payment has already been processed.`,
68
70
  value: "new-instance-continue",
69
71
  },
70
72
  ]
71
73
  : []),
72
- ...(hasDocSmithBaseUrl
73
- ? [
74
- {
75
- 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.`,
76
- value: "new-instance",
77
- },
78
- ]
79
- : []),
74
+ {
75
+ 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.`,
76
+ value: "new-instance",
77
+ },
80
78
  ],
81
79
  });
82
80
 
@@ -100,7 +98,7 @@ export default async function publishDocs(
100
98
  });
101
99
  // Ensure appUrl has protocol
102
100
  appUrl = userInput.includes("://") ? userInput : `https://${userInput}`;
103
- } else if (hasDocSmithBaseUrl && ["new-instance", "new-instance-continue"].includes(choice)) {
101
+ } else if (["new-instance", "new-instance-continue"].includes(choice)) {
104
102
  // Deploy a new Discuss Kit service
105
103
  try {
106
104
  let id = "";
@@ -118,8 +116,7 @@ export default async function publishDocs(
118
116
  token = ltToken;
119
117
  } catch (error) {
120
118
  const errorMsg = error?.message || "Unknown error occurred";
121
- console.error(`${chalk.red("❌ Failed to publish to website:")} ${errorMsg}`);
122
- return { message: `❌ Publish failed: ${errorMsg}` };
119
+ return { message: `${chalk.red("❌ Failed to publish to website:")} ${errorMsg}` };
123
120
  }
124
121
  }
125
122
  }
@@ -168,7 +165,7 @@ export default async function publishDocs(
168
165
  boardDesc: projectInfo.description,
169
166
  boardCover: projectInfo.icon,
170
167
  mediaFolder: rawDocsDir,
171
- cacheFilePath: join(".aigne", "doc-smith", "upload-cache.yaml"),
168
+ cacheFilePath: join(DOC_SMITH_DIR, "upload-cache.yaml"),
172
169
  boardMeta,
173
170
  });
174
171
 
@@ -8,7 +8,7 @@ input_schema:
8
8
  properties:
9
9
  datasources:
10
10
  type: string
11
- description: Context for document structure generation, used to assist generate document structure
11
+ description: Context for documentation structure generation, used to assist generate documentation structure
12
12
  documentExecutionStructure: ../schema/document-execution-structure.yaml
13
13
  modifiedFiles:
14
14
  type: array
@@ -36,10 +36,10 @@ export default async function checkDocument(
36
36
  detailGenerated = false;
37
37
  }
38
38
 
39
- // Check if sourceIds have changed by comparing with original document structure
39
+ // Check if sourceIds have changed by comparing with original documentation structure
40
40
  let sourceIdsChanged = false;
41
41
  if (originalDocumentStructure && sourceIds) {
42
- // Find the original node in the document structure
42
+ // Find the original node in the documentation structure
43
43
  const originalNode = originalDocumentStructure.find((node) => node.path === path);
44
44
 
45
45
  if (originalNode?.sourceIds) {
@@ -48,3 +48,28 @@ output_schema:
48
48
  type: string
49
49
  required:
50
50
  - content
51
+ skills:
52
+ - type: team
53
+ task_render_mode: collapse
54
+ name: generateD2DiagramContent
55
+ skills:
56
+ - ../generate/generate-d2-diagram.yaml
57
+ reflection:
58
+ reviewer: ../generate/check-d2-diagram-valid.mjs
59
+ is_approved: isValid
60
+ max_iterations: 5
61
+ return_last_on_max_iterations: true
62
+ input_schema:
63
+ type: object
64
+ properties:
65
+ documentContent:
66
+ type: string
67
+ description: Source code of current document (without the D2 diagram)
68
+ required:
69
+ - documentContent
70
+ output_schema:
71
+ type: object
72
+ properties:
73
+ d2DiagramSourceCode:
74
+ type: string
75
+ description: Source code for the D2 diagram
@@ -62,7 +62,7 @@ checkFeedbackRefiner.input_schema = {
62
62
  },
63
63
  documentStructureFeedback: {
64
64
  type: "string",
65
- description: "Feedback from document structure stage",
65
+ description: "Feedback from documentation structure stage",
66
66
  },
67
67
  stage: {
68
68
  type: "string",
@@ -41,7 +41,7 @@ export default async function chooseDocs(
41
41
 
42
42
  // Convert files to choices with titles
43
43
  const choices = mainLanguageFiles.map((file) => {
44
- // Convert filename to flat path to find corresponding document structure item
44
+ // Convert filename to flat path to find corresponding documentation structure item
45
45
  const flatName = file.replace(/\.md$/, "").replace(/\.\w+(-\w+)?$/, "");
46
46
  const docItem = documentExecutionStructure.find((item) => {
47
47
  const itemFlattenedPath = item.path.replace(/^\//, "").replace(/\//g, "-");
@@ -4,19 +4,19 @@ import { findItemByPath, readFileContent } from "../../utils/docs-finder-utils.m
4
4
  /**
5
5
  * Loads a document's content along with all its translations from the docs directory.
6
6
  *
7
- * This function finds a document by its path in the document structure, then searches
7
+ * This function finds a document by its path in the documentation structure, then searches
8
8
  * for all translation files in the docs directory that match the document's naming pattern.
9
9
  * Translation files are identified by the pattern: {flatName}.{language-code}.md
10
10
  *
11
11
  * @param {Object} params - The parameters object
12
12
  * @param {string} params.path - The document path to find in the structure
13
13
  * @param {string} params.docsDir - The directory containing document files and translations
14
- * @param {Object} params.documentStructure - The document structure object to search in
14
+ * @param {Object} params.documentStructure - The documentation structure object to search in
15
15
  * @returns {Promise<Object>} An object containing the document data with translations
16
16
  * @throws {Error} Throws an error if the document path is not found in the structure
17
17
  */
18
18
  export default async function loadDocumentAllContent({ path, docsDir, documentStructure }) {
19
- // Find the document item by path in the document structure
19
+ // Find the document item by path in the documentation structure
20
20
  const result = await findItemByPath(documentStructure, path, null, docsDir);
21
21
 
22
22
  if (!result) {
@@ -175,7 +175,7 @@ export default async function loadSources({
175
175
  }),
176
176
  );
177
177
 
178
- // Get the last document structure
178
+ // Get the last documentation structure
179
179
  let originalDocumentStructure;
180
180
  if (outputDir) {
181
181
  const documentStructurePath = path.join(outputDir, "structure-plan.json");
@@ -35,39 +35,18 @@ export default async function saveDocs({
35
35
  console.error("Failed to save _sidebar.md:", err.message);
36
36
  }
37
37
 
38
- // Clean up invalid .md files that are no longer in the document structure
38
+ // Clean up invalid .md files that are no longer in the documentation structure
39
39
  try {
40
40
  await cleanupInvalidFiles(documentStructure, docsDir, translateLanguages, locale);
41
41
  } catch (err) {
42
42
  console.error("Failed to cleanup invalid .md files:", err.message);
43
43
  }
44
44
 
45
- const message = `# ✅ Documentation Generated Successfully!
46
-
47
- Generated **${documentStructure.length}** documents and saved to: \`${docsDir}\`
45
+ const message = `
46
+ ✅ Documentation generated successfully! (\`${documentStructure.length}\` documents → \`${docsDir}\`)
48
47
  ${projectInfoMessage || ""}
49
- ## 🚀 Next Steps
50
-
51
- **Publish Your Documentation**
52
-
53
- Generate a shareable preview link for your team:
54
-
55
- \`aigne doc publish\`
56
-
57
- ## 🔧 Optional Actions
58
-
59
- **Update Specific Documents**
60
-
61
- Regenerate content for individual documents:
62
-
63
- \`aigne doc update\`
64
-
65
- **Refine Document Structure**
66
-
67
- Review and improve your documentation organization:
68
-
69
- \`aigne doc generate\`
70
-
48
+ 🚀 Next: Make your documentation live and generate a shareable link, run: \`aigne doc publish\`
49
+ 💡 Optional: Update specific document (\`aigne doc update\`) or refine documentation structure (\`aigne doc generate\`)
71
50
  `;
72
51
 
73
52
  // Shutdown mermaid worker pool to ensure clean exit
@@ -94,7 +73,7 @@ function generateFileName(flatName, language) {
94
73
  }
95
74
 
96
75
  /**
97
- * Clean up .md files that are no longer in the document structure
76
+ * Clean up .md files that are no longer in the documentation structure
98
77
  * @param {Array<{path: string, title: string}>} documentStructure
99
78
  * @param {string} docsDir
100
79
  * @param {Array<string>} translateLanguages
@@ -109,7 +88,7 @@ async function cleanupInvalidFiles(documentStructure, docsDir, translateLanguage
109
88
  const files = await readdir(docsDir);
110
89
  const mdFiles = files.filter((file) => file.endsWith(".md"));
111
90
 
112
- // Generate expected file names from document structure
91
+ // Generate expected file names from documentation structure
113
92
  const expectedFiles = new Set();
114
93
 
115
94
  // Add main document files
package/aigne.yaml CHANGED
@@ -9,7 +9,7 @@ agents:
9
9
  # Initialization
10
10
  - ./agents/init/index.mjs
11
11
 
12
- # Document Structure Generation
12
+ # Documentation Structure Generation
13
13
  - ./agents/generate/generate-structure.yaml
14
14
  - ./agents/generate/update-document-structure.yaml
15
15
  - ./agents/generate/check-need-generate-structure.mjs
@@ -18,7 +18,7 @@ agents:
18
18
  - ./agents/generate/user-review-document-structure.mjs
19
19
  - ./agents/generate/index.yaml
20
20
 
21
- # Document Structure Tools
21
+ # Documentation Structure Tools
22
22
  - ./agents/generate/document-structure-tools/add-document.mjs
23
23
  - ./agents/generate/document-structure-tools/delete-document.mjs
24
24
  - ./agents/generate/document-structure-tools/update-document.mjs
package/docs/_sidebar.md CHANGED
@@ -14,4 +14,4 @@
14
14
  * [Advanced Topics](/advanced.md)
15
15
  * [How It Works](/advanced-how-it-works.md)
16
16
  * [Quality Assurance](/advanced-quality-assurance.md)
17
- * [Changelog](/changelog.md)
17
+ * [Changelog](/changelog.md)
@@ -73,7 +73,7 @@ User-Feedback -> Pipeline.Content-Generation: "Regenerate Content"
73
73
 
74
74
  1. **Input Analysis**: The process begins when agents load your source code and project configuration (`aigne.yaml`).
75
75
 
76
- 2. **Structure Planning**: An agent analyzes the codebase to propose a logical document structure. It creates an outline based on the project's composition and any specified rules.
76
+ 2. **Structure Planning**: An agent analyzes the codebase to propose a logical documentation structure. It creates an outline based on the project's composition and any specified rules.
77
77
 
78
78
  3. **Content Generation**: With the structure in place, content generation agents populate each section of the document plan with detailed text, code examples, and explanations.
79
79
 
@@ -88,8 +88,8 @@ DocSmith's functionality is provided by a collection of agents defined in the pr
88
88
  | Functional Role | Key Agent Files | Description |
89
89
  | ------------------------ | ---------------------------------------------------- | ------------------------------------------------------------------------------------ |
90
90
  | **Structure Planning** | `generate/generate-structure.yaml` | Analyzes source code to propose the initial document outline. |
91
- | **Structure Refinement** | `generate/refine-document-structure.yaml` | Modifies the document structure based on user feedback. |
92
- | **Content Generation** | `update/batch-generate-document.yaml`, `generate-document.yaml` | Populates the document structure with detailed content for each section. |
91
+ | **Structure Refinement** | `generate/refine-document-structure.yaml` | Modifies the documentation structure based on user feedback. |
92
+ | **Content Generation** | `update/batch-generate-document.yaml`, `generate-document.yaml` | Populates the documentation structure with detailed content for each section. |
93
93
  | **Translation** | `translate/translate-document.yaml`, `translate-multilingual.yaml` | Translates generated documentation into multiple target languages. |
94
94
  | **Publishing** | `publish/publish-docs.mjs` | Manages the process of publishing documents to Discuss Kit instances. |
95
95
  | **Data I/O** | `utils/load-sources.mjs`, `utils/save-docs.mjs` | Responsible for reading source files and writing the final markdown documents to disk. |
@@ -68,7 +68,7 @@ DocSmith performs several checks to ensure the structural integrity of the conte
68
68
 
69
69
  #### Link and Media Integrity
70
70
 
71
- - **Link Integrity**: All relative links within the documentation are validated against the document structure plan to prevent dead links. This ensures that all internal navigation works as expected. The checker ignores external links (starting with `http://` or `https://`) and `mailto:` links.
71
+ - **Link Integrity**: All relative links within the documentation are validated against the documentation structure to prevent dead links. This ensures that all internal navigation works as expected. The checker ignores external links (starting with `http://` or `https://`) and `mailto:` links.
72
72
 
73
73
  - **Image Validation**: To avoid broken images, the checker verifies that any local image file referenced in the documentation exists on the file system. It resolves both relative and absolute paths to confirm the file is present. External image URLs and data URLs are not checked.
74
74