@aigne/doc-smith 0.8.15-beta.8 → 0.8.15

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 (68) hide show
  1. package/CHANGELOG.md +73 -0
  2. package/agents/evaluate/document-structure.yaml +3 -1
  3. package/agents/evaluate/document.yaml +3 -1
  4. package/agents/evaluate/index.yaml +1 -3
  5. package/agents/generate/check-diagram.mjs +1 -1
  6. package/agents/generate/generate-structure.yaml +25 -71
  7. package/agents/generate/index.yaml +1 -2
  8. package/agents/generate/{merge-d2-diagram.yaml → merge-diagram.yaml} +7 -6
  9. package/agents/generate/update-document-structure.yaml +51 -45
  10. package/agents/generate/user-review-document-structure.mjs +3 -26
  11. package/agents/generate/utils/merge-document-structures.mjs +8 -32
  12. package/agents/init/check.mjs +1 -1
  13. package/agents/init/index.mjs +52 -2
  14. package/agents/init/validate.mjs +16 -0
  15. package/agents/publish/publish-docs.mjs +16 -10
  16. package/agents/schema/document-execution-structure.yaml +1 -1
  17. package/agents/schema/document-structure-item.yaml +1 -1
  18. package/agents/schema/document-structure-refine-item.yaml +20 -0
  19. package/agents/schema/document-structure.yaml +4 -2
  20. package/agents/update/batch-generate-document.yaml +1 -1
  21. package/agents/update/check-generate-diagram.mjs +84 -0
  22. package/agents/update/generate-diagram.yaml +0 -1
  23. package/agents/update/generate-document.yaml +4 -4
  24. package/agents/update/handle-document-update.yaml +9 -1
  25. package/agents/update/pre-check-generate-diagram.yaml +44 -0
  26. package/agents/update/update-document-detail.yaml +64 -58
  27. package/agents/update/update-single-document.yaml +1 -2
  28. package/agents/update/user-review-document.mjs +8 -6
  29. package/agents/utils/analyze-feedback-intent.yaml +29 -0
  30. package/agents/utils/choose-docs.mjs +16 -6
  31. package/agents/utils/find-item-by-path.mjs +4 -2
  32. package/agents/utils/load-sources.mjs +6 -6
  33. package/agents/utils/map-reasoning-effort-level.mjs +15 -0
  34. package/agents/utils/save-sidebar.mjs +12 -33
  35. package/agents/utils/{transform-detail-datasources.mjs → transform-detail-data-sources.mjs} +3 -3
  36. package/aigne.yaml +14 -3
  37. package/package.json +10 -9
  38. package/prompts/common/document/content-rules-core.md +6 -6
  39. package/prompts/common/document/openapi-usage-rules.md +36 -0
  40. package/prompts/common/document/role-and-personality.md +1 -2
  41. package/prompts/common/document-structure/conflict-resolution-guidance.md +2 -2
  42. package/prompts/common/document-structure/document-structure-rules.md +8 -8
  43. package/prompts/common/document-structure/output-constraints.md +3 -3
  44. package/prompts/detail/custom/custom-code-block.md +36 -1
  45. package/prompts/detail/custom/{custom-components.md → custom-components-usage-rules.md} +29 -7
  46. package/prompts/detail/d2-diagram/pre-check.md +23 -0
  47. package/prompts/detail/d2-diagram/rules.md +44 -29
  48. package/prompts/detail/d2-diagram/system-prompt.md +0 -14
  49. package/prompts/detail/d2-diagram/user-prompt.md +10 -1
  50. package/prompts/detail/generate/document-rules.md +3 -3
  51. package/prompts/detail/generate/system-prompt.md +2 -8
  52. package/prompts/detail/generate/user-prompt.md +13 -60
  53. package/prompts/detail/update/system-prompt.md +3 -8
  54. package/prompts/detail/update/user-prompt.md +9 -5
  55. package/prompts/evaluate/document.md +0 -4
  56. package/prompts/structure/check-document-structure.md +4 -4
  57. package/prompts/structure/generate/system-prompt.md +0 -1
  58. package/prompts/structure/generate/user-prompt.md +21 -18
  59. package/prompts/structure/review/structure-review-system.md +24 -16
  60. package/prompts/structure/update/system-prompt.md +0 -13
  61. package/prompts/structure/update/user-prompt.md +6 -5
  62. package/prompts/translate/translate-document.md +3 -3
  63. package/prompts/utils/analyze-feedback-intent.md +55 -0
  64. package/utils/constants/index.mjs +38 -0
  65. package/utils/deploy.mjs +3 -1
  66. package/utils/docs-finder-utils.mjs +37 -3
  67. package/utils/file-utils.mjs +97 -0
  68. package/utils/load-config.mjs +19 -0
@@ -0,0 +1,15 @@
1
+ import {
2
+ DEFAULT_REASONING_EFFORT_LEVEL,
3
+ DEFAULT_REASONING_EFFORT_VALUE,
4
+ REASONING_EFFORT_LEVELS,
5
+ } from "../../utils/constants/index.mjs";
6
+
7
+ export default function mapReasoningEffortLevel({ level }, options) {
8
+ const g =
9
+ REASONING_EFFORT_LEVELS[level] || REASONING_EFFORT_LEVELS[DEFAULT_REASONING_EFFORT_LEVEL];
10
+
11
+ return {
12
+ reasoningEffort:
13
+ g[options.context.userContext.thinkingEffort] ?? DEFAULT_REASONING_EFFORT_VALUE,
14
+ };
15
+ }
@@ -1,5 +1,6 @@
1
1
  import { join } from "node:path";
2
2
  import fs from "fs-extra";
3
+ import { buildDocumentTree } from "../../utils/docs-finder-utils.mjs";
3
4
 
4
5
  export default async function saveSidebar({ documentStructure, docsDir }) {
5
6
  // Generate _sidebar.md
@@ -16,44 +17,22 @@ export default async function saveSidebar({ documentStructure, docsDir }) {
16
17
  }
17
18
 
18
19
  // Recursively generate sidebar text, the link path is the flattened file name
19
- function walk(node, parentSegments = [], indent = "") {
20
+ function walk(nodes, indent = "") {
20
21
  let out = "";
21
- for (const key of Object.keys(node)) {
22
- const item = node[key];
23
- const fullSegments = [...parentSegments, key];
24
- const flatFile = `${fullSegments.join("-")}.md`;
25
- if (item.__title) {
26
- const realIndent = item.__parentId === null ? "" : indent;
27
- out += `${realIndent}* [${item.__title}](/${flatFile})\n`;
28
- }
29
- const children = item.__children;
30
- if (Object.keys(children).length > 0) {
31
- out += walk(children, fullSegments, `${indent} `);
22
+ for (const node of nodes) {
23
+ const relPath = node.path.replace(/^\//, "");
24
+ const flatFile = `${relPath.split("/").join("-")}.md`;
25
+ const realIndent = node.parentId === null ? "" : indent;
26
+ out += `${realIndent}* [${node.title}](/${flatFile})\n`;
27
+
28
+ if (node.children && node.children.length > 0) {
29
+ out += walk(node.children, `${indent} `);
32
30
  }
33
31
  }
34
32
  return out;
35
33
  }
36
34
 
37
35
  function generateSidebar(documentStructure) {
38
- // Build tree structure
39
- const root = {};
40
- for (const { path, title, parentId } of documentStructure) {
41
- const relPath = path.replace(/^\//, "");
42
- const segments = relPath.split("/");
43
- let node = root;
44
- for (let i = 0; i < segments.length; i++) {
45
- const seg = segments[i];
46
- if (!node[seg])
47
- node[seg] = {
48
- __children: {},
49
- __title: null,
50
- __fullPath: segments.slice(0, i + 1).join("/"),
51
- __parentId: parentId,
52
- };
53
- if (i === segments.length - 1) node[seg].__title = title;
54
- node = node[seg].__children;
55
- }
56
- }
57
-
58
- return walk(root).replace(/\n+$/, "");
36
+ const { rootNodes } = buildDocumentTree(documentStructure);
37
+ return walk(rootNodes).replace(/\n+$/, "");
59
38
  }
@@ -2,7 +2,7 @@ import fs from "node:fs";
2
2
  import { isRemoteFile } from "../../utils/file-utils.mjs";
3
3
  import { normalizePath, toRelativePath } from "../../utils/utils.mjs";
4
4
 
5
- export default function transformDetailDatasources({ sourceIds }, options = {}) {
5
+ export default function transformDetailDataSource({ sourceIds }, options = {}) {
6
6
  // Read file content for each sourceId, ignoring failures
7
7
  let openAPISpec;
8
8
  const remoteFileList = options?.context?.userContext?.remoteFileList || [];
@@ -37,9 +37,9 @@ export default function transformDetailDatasources({ sourceIds }, options = {})
37
37
  .filter(Boolean);
38
38
 
39
39
  return {
40
- detailDataSources: contents.join(""),
40
+ detailDataSource: contents.join(""),
41
41
  openAPISpec,
42
42
  };
43
43
  }
44
44
 
45
- transformDetailDatasources.task_render_mode = "hide";
45
+ transformDetailDataSource.task_render_mode = "hide";
package/aigne.yaml CHANGED
@@ -1,8 +1,12 @@
1
1
  #!/usr/bin/env aigne
2
2
 
3
3
  model:
4
- model: google/gemini-2.5-pro
5
- # name: gemini-2.5-flash
4
+ # model: aignehub/gpt-5
5
+ # model: aignehub/claude-sonnet-4-0
6
+ model: aignehub/gemini-2.5-pro # reasoning_effort 128-32768
7
+ # https://github.com/AIGNE-io/aigne-framework/blob/main/models/gemini/src/gemini-chat-model.ts#L115
8
+ reasoning_effort:
9
+ $get: reasoningEffort
6
10
  temperature: 0.8
7
11
  agents:
8
12
  # Initialization
@@ -66,7 +70,7 @@ agents:
66
70
  - ./agents/utils/load-sources.mjs
67
71
  - ./agents/utils/post-generate.mjs
68
72
  - ./agents/utils/save-sidebar.mjs
69
- - ./agents/utils/transform-detail-datasources.mjs
73
+ - ./agents/utils/transform-detail-data-sources.mjs
70
74
  - ./agents/utils/save-doc.mjs
71
75
  - ./agents/utils/save-doc-translation.mjs
72
76
  - ./agents/utils/save-output.mjs
@@ -74,6 +78,7 @@ agents:
74
78
  - ./agents/utils/find-item-by-path.mjs
75
79
  - ./agents/utils/check-feedback-refiner.mjs
76
80
  - ./agents/utils/feedback-refiner.yaml
81
+ - ./agents/utils/analyze-feedback-intent.yaml
77
82
 
78
83
  # User Preferences & Chat
79
84
  - ./agents/prefs/index.mjs
@@ -93,6 +98,12 @@ agents:
93
98
  - ./agents/evaluate/document-structure.yaml
94
99
  - ./agents/evaluate/document.yaml
95
100
  - ./agents/evaluate/code-snippet.mjs
101
+
102
+ # Diagram
103
+ - ./agents/generate/merge-diagram.yaml
104
+ - ./agents/update/generate-diagram.yaml
105
+ - ./agents/update/check-generate-diagram.mjs
106
+ - ./agents/update/pre-check-generate-diagram.yaml
96
107
  cli:
97
108
  chat: ./agents/chat/index.yaml
98
109
  agents:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aigne/doc-smith",
3
- "version": "0.8.15-beta.8",
3
+ "version": "0.8.15",
4
4
  "description": "AI-driven documentation generation tool built on the AIGNE Framework",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -24,14 +24,14 @@
24
24
  "author": "Arcblock <blocklet@arcblock.io> https://github.com/blocklet",
25
25
  "license": "Elastic-2.0",
26
26
  "dependencies": {
27
- "@aigne/aigne-hub": "^0.10.0",
28
- "@aigne/anthropic": "^0.14.0",
29
- "@aigne/cli": "^1.49.1",
30
- "@aigne/core": "^1.61.0",
31
- "@aigne/gemini": "^0.14.0",
32
- "@aigne/openai": "^0.16.0",
33
- "@aigne/publish-docs": "^0.12.0",
34
- "@blocklet/payment-broker-client": "^1.21.10",
27
+ "@aigne/aigne-hub": "^0.10.5-beta.3",
28
+ "@aigne/anthropic": "^0.14.5-beta.3",
29
+ "@aigne/cli": "^1.53.1-beta.4",
30
+ "@aigne/core": "^1.65.1-beta.3",
31
+ "@aigne/gemini": "^0.14.5-beta.3",
32
+ "@aigne/openai": "^0.16.5-beta.3",
33
+ "@aigne/publish-docs": "^0.12.1",
34
+ "@blocklet/payment-broker-client": "^1.22.8",
35
35
  "@terrastruct/d2": "^0.1.33",
36
36
  "chalk": "^5.5.0",
37
37
  "cli-highlight": "^2.1.11",
@@ -48,6 +48,7 @@
48
48
  "marked": "^15.0.12",
49
49
  "marked-terminal": "^7.3.0",
50
50
  "mermaid": "^11.9.0",
51
+ "minimatch": "^10.1.1",
51
52
  "open": "^10.2.0",
52
53
  "p-limit": "^7.1.1",
53
54
  "p-map": "^7.0.3",
@@ -2,12 +2,12 @@ Target Audience: {{targetAudience}}
2
2
 
3
3
  Content Generation Rules:
4
4
 
5
- - Use only information from DataSources, never fabricate or supplement content not present in the sources
5
+ - Use only information from `<detail_data_source>`, never fabricate or supplement content not present in the sources
6
6
  - Combine the current {{nodeName}} title and description to create a well-structured content plan that is rich, organized, and engaging
7
7
  - Content style must match the target audience
8
- - Clearly differentiate content from other {{nodeName}} items in the documentStructure to avoid duplication and highlight this {{nodeName}}'s unique value
8
+ - Clearly differentiate content from other {{nodeName}} items in the `<document_structure>` to avoid duplication and highlight this {{nodeName}}'s unique value
9
9
  {% if enforceInfoCompleteness %}
10
- - If DataSources lack sufficient information, return an error message requesting users to provide additional content. Ensure page content is sufficiently rich, don't hesitate to ask users for supplementary information
10
+ - If `<detail_data_source>` lack sufficient information, return an error message requesting users to provide additional content. Ensure page content is sufficiently rich, don't hesitate to ask users for supplementary information
11
11
  - Display only valuable, engaging information. If information is insufficient, prompt users to provide more details
12
12
  {% endif %}
13
13
  - Output complete information including all content planned for the {{nodeName}}
@@ -15,6 +15,6 @@ Content Generation Rules:
15
15
  - Maintain a strict, sequential heading hierarchy; no skipping (e.g., no jump from level-1 to level-3).
16
16
  - Format markdown output with proper line breaks and spacing for easy reading
17
17
  - For list data with many items, prioritize using markdown table for cleaner, more readable presentation
18
- - Do not mention 'DataSources' in output, your content is for user consumption, and users are unaware of DataSources
19
- - Do not include file paths from Data Sources in output as they are meaningless to users
20
- - Avoid phrases like 'current {{nodeName}}'
18
+ - Do not mention `<detail_data_source>` in output, your content is for user consumption, and users are unaware of detailDataSource
19
+ - Do not include file paths from `<data_sources>` in output as they are meaningless to users
20
+ - Avoid phrases like 'current {{nodeName}}'
@@ -0,0 +1,36 @@
1
+ {% if openAPISpec %}
2
+ <openapi_usage_rules>
3
+
4
+ **Goal:** Use the provided OpenAPI (Swagger) specification, align it with the current page objective, and leverage it to refine this document.
5
+
6
+ **OpenAPI File Content:**
7
+ <openapi_doc>
8
+
9
+ {{ openAPISpec }}
10
+
11
+ </openapi_doc>
12
+
13
+ ---
14
+
15
+ ### **Documentation Requirements and Constraints**
16
+
17
+ 1. **Extract the core content:**
18
+ * Organize the document by functional modules.
19
+ * For each path item, include the following elements:
20
+ * HTTP method and path.
21
+ * Concise summary.
22
+ * Detailed description.
23
+ * Request parameters: name, location (`in`), type, required flag, description.
24
+ * Request body: describe its structure when present.
25
+ * Responses: at least the key status codes (e.g., 200, 201, 400, 500) and their schemas.
26
+
27
+ 2. **Mandatory API description constraints (deduplication rule):**
28
+ * **Ensure that throughout the document (including preface, overview, etc.), any introduction to the project APIs appears only within this OpenAPI-generated "API reference" section.**
29
+ * **Never** repeat or expand the interface list elsewhere in the document (for example, "Quick Start" or "Architecture Overview" sections).
30
+
31
+ ---
32
+
33
+ **Expected output format:** A concise, clear, and easy-to-scan Markdown document.
34
+
35
+ </openapi_usage_rules>
36
+ {% endif %}
@@ -13,5 +13,4 @@ Your key strengths include:
13
13
  1. **Fact-Driven:** Adhere strictly to the provided technical specifications. Do not infer or embellish information.
14
14
  2. **Structured and Orderly:** Organize the content logically with clear headings, subheadings, lists, and tables. Present information sequentially where appropriate (e.g., installation steps).
15
15
  3. **Clarity and Precision:** Use precise, unambiguous language. Define technical terms clearly. Avoid marketing jargon or emotionally charged words.
16
- 4. **Practical and Helpful:** Focus on providing practical examples, code snippets, and clear instructions that a user can directly apply.
17
- 5. **Tool Utilization:** Actively call tools as needed, potentially multiple times, to obtain complete information from AFS (AIGNE File System) or generate Diagrams. Do not embed Mermaid or other diagram markup directly; include diagrams only via generateDiagram tool responses.
16
+ 5. **Tool Utilization:** Actively call tools as needed, potentially multiple times, to obtain complete information from AFS (AIGNE File System).
@@ -1,5 +1,5 @@
1
1
  <conflict_resolution_guidance>
2
- When users select potentially conflicting options, conflict resolution guidance will be provided in user_rules. Please carefully read these guidelines and implement the corresponding resolution strategies in the documentation structure.
2
+ When users select potentially conflicting options, conflict resolution guidance will be provided in `<user_rules>`. Please carefully read these guidelines and implement the corresponding resolution strategies in the documentation structure.
3
3
 
4
4
  Core principles for conflict resolution:
5
5
  1. **Layered need satisfaction**: Simultaneously satisfy multiple purposes and audiences through reasonable documentation structure hierarchy
@@ -13,4 +13,4 @@ Common conflict resolution patterns:
13
13
  - **Depth conflicts**: Adopt progressive structures that allow users to choose appropriate depth levels
14
14
 
15
15
  When generating documentation structure, prioritize conflict resolution strategies to ensure the final structure can harmoniously satisfy all user needs.
16
- </conflict_resolution_guidance>
16
+ </conflict_resolution_guidance>
@@ -1,18 +1,18 @@
1
1
  <document_structure_rules>
2
2
  The target audience for this document is: {{targetAudience}}
3
3
 
4
- DataSources usage rules:
5
- 1. When planning the structure, reasonably organize and display all information from DataSources without omission
6
- 2. Users may provide limited DataSources. In such cases, you can supplement with your existing knowledge to complete the structural planning
7
- 3. For information provided in user DataSources, if it's public information, you can supplement planning with your existing knowledge. If it's the user's private products or information, **do not arbitrarily create or supplement false information**
8
- 4. If DataSources don't match the target audience, you need to reframe the DataSources to match the target audience
4
+ `<data_sources>` usage rules:
5
+ 1. When planning the structure, reasonably organize and display all information from `<data_sources>` without omission
6
+ 2. Users may provide limited `<data_sources>`. In such cases, you can supplement with your existing knowledge to complete the structural planning
7
+ 3. For information provided in user `<data_sources>`, if it's public information, you can supplement planning with your existing knowledge. If it's the user's private products or information, **do not arbitrarily create or supplement false information**
8
+ 4. If `<data_sources>` don't match the target audience, you need to reframe the `<data_sources>` to match the target audience
9
9
 
10
10
  Structural planning rules:
11
11
 
12
12
  1. {{nodeName}} planning should prioritize user-specified rules, especially requirements like "number of {{nodeName}}", "must include xxx {{nodeName}}", "cannot include xxx {{nodeName}}"
13
13
  2. {{nodeName}} planning should display as much information as possible from the user-provided context
14
14
  3. Structure planning should have reasonable hierarchical relationships, with content planned at appropriate levels, avoiding flat layouts with numerous {{nodeName}} items
15
- 4. The order of {{nodeName}} in output should follow the target audience's browsing path. It doesn't need to follow the exact order in DataSources—progress from simple to advanced, from understanding to exploration, with reasonable pathways
15
+ 4. The order of {{nodeName}} in output should follow the target audience's browsing path. It doesn't need to follow the exact order in `<data_sources>` progress from simple to advanced, from understanding to exploration, with reasonable pathways
16
16
  5. Each {{nodeName}} should have a clear content plan and must not duplicate content from other {{nodeName}} items
17
17
  6. Information planned for each {{nodeName}} should be clearly describable within a single page. If there's too much information to display or the concepts are too broad, consider splitting into sub-{{nodeName}} items
18
18
  7. If previous documentation structure and user feedback are provided, make only necessary modifications based on user feedback without major changes
@@ -26,7 +26,7 @@ Structural planning rules:
26
26
  - Title
27
27
  - Description of the important information this {{nodeName}} plans to display, with descriptions tailored to the target audience
28
28
 
29
- 2. Content planning should prioritize displaying information from user-provided DataSources or supplement with your existing knowledge. Do not arbitrarily fabricate information.
29
+ 2. Content planning should prioritize displaying information from user-provided `<data_sources>` or supplement with your existing knowledge. Do not arbitrarily fabricate information.
30
30
 
31
31
  {% ifAsync docsType == 'general' %}
32
32
  {% include "../../structure/document-rules.md" %}
@@ -41,4 +41,4 @@ Other requirements:
41
41
 
42
42
  1. Must satisfy user specified rules
43
43
  2. Return information using the user's language {{locale}}
44
- </document_structure_rules>
44
+ </document_structure_rules>
@@ -1,9 +1,9 @@
1
1
  <output_constraints>
2
2
 
3
- 1. Associated sourceIds should be as comprehensive as possible. You can include as many related datasources as possible.
4
- - If datasources contain source code, **include as much related and adjacent source code as possible** to ensure quality of subsequent detail generation.
3
+ 1. Associated sourceIds should be as comprehensive as possible. You can include as many related `<data_sources>` as possible.
4
+ - If `<data_sources>` contain source code, **include as much related and adjacent source code as possible** to ensure quality of subsequent detail generation.
5
5
  - First identify the most relevant source code files, then analyze the source code referenced within them. Referenced file paths, referenced files, and files in referenced paths all need to be included in sourceIds
6
6
  - For referenced files, analyze another layer of source code files referenced within them and add to sourceIds to ensure complete context for detail generation
7
7
  2. **Ensure sourceIds are never empty**. Do not plan {{nodeName}} items without related data sources
8
8
 
9
- </output_constraints>
9
+ </output_constraints>
@@ -18,6 +18,11 @@ The following are the available enhanced attributes and their descriptions:
18
18
  * `language` and `title` are written directly after \`\`\`, separated by spaces.
19
19
  * Other attributes (`icon`) must be provided in **key=value** format, separated by spaces.
20
20
 
21
+ ### Special Rules
22
+ - If the language is a shell (includes `sh`, `bash`, `zsh`, etc.):
23
+ - Executable shell code blocks must be a single-line command to make copying and running easier.
24
+ - Do not include comments inside executable shell code blocks; place explanatory comments outside the code block.
25
+
21
26
  ### Examples
22
27
 
23
28
  <code_block_good_examples>
@@ -70,9 +75,26 @@ class ShoppingCart {
70
75
  }
71
76
  }
72
77
  ```
78
+
79
+ **Example 5: Shell code block should in one line**
80
+
81
+ ```sh Install aigne deps icon=lucide:terminal
82
+ npm i -g @aigne/cli @aigne/doc-smith @aigne/websmith-smith
83
+ ```
84
+
85
+ **Example 6: Shell code block use `\` to split multiple lines**
86
+ ```bash Deploying with Access Keys icon=lucide:terminal
87
+ blocklet deploy . \
88
+ --endpoint https://my-server.arcblock.io \
89
+ --access-key 'your_access_key_id' \
90
+ --access-secret 'your_access_key_secret' \
91
+ --app-id z2qa9sD2tFAP8gM7C1i8iETg3a1T3A3aT3bQ
92
+ ```
93
+
73
94
  </code_block_good_examples>
74
95
 
75
96
  <code_block_bad_examples>
97
+
76
98
  **Example 1**
77
99
 
78
100
  There are two errors in this example:
@@ -97,5 +119,18 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
97
119
  }
98
120
  ```
99
121
 
122
+ **Example 2: shell code block have multiple lines**
123
+ ```sh
124
+ npm i -g @aigne/cli
125
+ npm i -g @aigne/doc-smith
126
+ npm i -g @aigne/websmith-smith
127
+ ```
128
+
129
+ **Example 3: shell code block comments**
130
+ ```sh
131
+ # add aigne deps
132
+ npm i -g @aigne/cli
133
+ ```
134
+
100
135
  </code_block_bad_examples>
101
- </enhanced_code_block_rules>
136
+ </enhanced_code_block_rules>
@@ -1,4 +1,4 @@
1
- <custom_components_usage>
1
+ <custom_components_usage_rules>
2
2
  When generating document details, you can use the following custom components at appropriate locations based on their descriptions and functionality to enhance document presentation:
3
3
 
4
4
  ## XCard: Individual link display card
@@ -48,11 +48,11 @@ Example 1: Inline Markdown formatting in card content
48
48
 
49
49
  Example 2: Code block inside card content
50
50
 
51
- ```md
51
+ ````md
52
52
  <x-card data-title="ctrl_break()" data-icon="lucide:keyboard">
53
53
  Creates a listener for "ctrl-break" events.
54
54
 
55
- \`\`\`rust
55
+ ```rust
56
56
  use tokio::signal::windows::ctrl_break;
57
57
 
58
58
  #[tokio::main]
@@ -62,10 +62,11 @@ stream.recv().await;
62
62
  println!("got ctrl-break");
63
63
  Ok(())
64
64
  }
65
- \`\`\`
66
- </x-card>
67
65
  ```
68
66
 
67
+ ````
68
+
69
+
69
70
  ## XCards: Multiple cards container
70
71
 
71
72
  Suitable for displaying multiple links using a card list format, providing a richer and more visually appealing presentation.
@@ -80,7 +81,7 @@ Suitable for displaying multiple links using a card list format, providing a ric
80
81
 
81
82
  ### Usage Rules
82
83
 
83
- - **Visual Consistency**: All <x-card> elements within the same <x-cards> must maintain visual consistency:
84
+ - **Visual Consistency**: All `<x-card>` elements within the same `<x-cards>` must maintain visual consistency:
84
85
  - It's recommended to always provide data-icon for each card.
85
86
  - Or all cards should have data-image.
86
87
  - Avoid mixing (some with icons, some with only images).
@@ -106,6 +107,18 @@ Example 2: Two-column cards with images
106
107
  </x-cards>
107
108
  ```
108
109
 
110
+ Example 3: Replace markdown format multiple links
111
+
112
+ ```md
113
+ For more detailed information on specific features, please refer to the following sections:
114
+
115
+ <x-cards data-columns="3">
116
+ <x-card data-title="Using Discussions" data-href="/discussions">Introduce how to use discussions</x-card>
117
+ <x-card data-title="Using the Blog" data-href="/blog">Introduce how to use the Blog</x-card>
118
+ <x-card data-title="Using Chat" data-href="/chat">Introduce how to use Chat</x-card>
119
+ </x-cards>
120
+ ```
121
+
109
122
  ### Bad Examples
110
123
 
111
124
  Example 1: Using a single-column layout (`data-columns="1"`) is not allowed
@@ -125,6 +138,15 @@ Example 2: Contains only one `<x-card>` (must include multiple cards)
125
138
  </x-cards>
126
139
  ```
127
140
 
141
+ Example 3: Markdown format multiple links
142
+
143
+ ```md
144
+ For more detailed information on specific features, please refer to the following sections:
145
+ - [Using Discussions](./discussions.md)
146
+ - [Using the Blog](./blog.md)
147
+ - [Using Chat](./chat.md)
148
+ ```
149
+
128
150
  ## XField: Structured data field
129
151
 
130
152
  Suitable for displaying API parameters, return values, context data, and any structured data with metadata in a clean, organized format. Supports nested structures for complex data types.
@@ -517,4 +539,4 @@ Example 6: Missing blank line before x-field-group (violates "Spacing Around" ru
517
539
  </x-field-group>
518
540
  ```
519
541
 
520
- </custom_components_usage>
542
+ </custom_components_usage_rules>
@@ -0,0 +1,23 @@
1
+ <document_content>
2
+ {{documentContent}}
3
+ </document_content>
4
+
5
+ {% if feedback %}
6
+ <feedback>
7
+ {{feedback}}
8
+ </feedback>
9
+ {% endif %}
10
+
11
+ {% if detailFeedback %}
12
+ <content_review_feedback>
13
+ {{ detailFeedback }}
14
+ </content_review_feedback>
15
+ {% endif %}
16
+
17
+ {% if previousGenerationContent %}
18
+ <previous_generation_content>
19
+ {{ previousGenerationContent }}
20
+ </previous_generation_content>
21
+ {% endif %}
22
+
23
+ {% include "./rules.md" %}
@@ -1,29 +1,44 @@
1
- <diagram_generation_guide>
2
-
3
- 1. Core Principles and Mandatory Constraints
4
- - **Absolute Constraint (Mandatory)**: You **must only** call the `generateDiagram` tool to generate a diagram.
5
- - **Do not** generate mermaid diagram.
6
- - **Do not** generate base64 image.
7
- - **Do not** generate fake image url.
8
- - **Diagram Failure Handling**: If the `generateDiagram` tool call fails, **omit the diagram entirely** and proceed with generating the text. **Do not** attempt to describe the diagram in words as a replacement.
9
-
10
- 2. Diagram Triggers and Types: Call `generateDiagram` and select the most appropriate type when describing the following specific content
11
- - Architecture Diagram (High-Level)
12
- - **Trigger**: When the document provides a high-level overview of a system, project, or the overall documentation set.
13
- - **Content**: Must illustrate the main components, their relationships, and the overall structure.
14
- - Structural Diagram (Module-Level)
15
- - **Trigger**: When generating the introductory document for a major section or module.
16
- - **Content**: Must show the key sub-components, files, or core concepts within that specific module.
17
- - Process and Interaction Diagrams (Detailed)
18
- - **Trigger**: When the document describes a workflow, a sequence of events, user interactions, or data flow.
19
- - **Diagram Type Selection**:
20
- - **Flowchart**: Use for step-by-step processes, algorithms, or decision-making logic.
21
- - **Sequence Diagram**: Use for time-ordered interactions between different components or actors (e.g., API calls).
22
- 3. Constraints and Best Practices
23
- - **Quantity Limit**: Generate a maximum of **three** diagrams per document.
24
- - **Relevance**: Ensure every diagram **directly** illustrates a concept explained in the surrounding text. Avoid generating diagrams for simple concepts that are easily understood through text alone.
25
- 4. Tool result using rules
26
- - If the `generateDiagram` tool's result (`diagramSourceCode`) is present, insert the value of `diagramSourceCode` directly into the document as a string.
27
- - If the `generateDiagram` tool's result is not present, do not attempt to add any diagrams.
28
-
29
- </diagram_generation_guide>
1
+ <diagram_generation_rules>
2
+
3
+ You must analyze the provided inputs to determine if a diagram is needed and where to insert a placeholder. You must not generate the diagram itself (e.g., no Mermaid, PlantUML, or other code). You are only deciding and placing the placeholder.
4
+
5
+ ## Inputs
6
+
7
+ - `<document_content>`: The main body of text to be evaluated.
8
+ - `<previous_generation_content>`: The content from the previous run, which may contain DIAGRAM_PLACEHOLDER.
9
+ - `<feedback>`: Specific user instructions for this run (e.g., "add a diagram," "remove the diagram").
10
+ - `<content_review_feedback>`: General automated or human feedback on the content.
11
+
12
+ ## Scoring conditions
13
+
14
+ - `add`: If `<feedback>` explicitly requests to add a diagram, ignore other conditions, +30000
15
+ - `remove`: If `<feedback>` explicitly requests to remove a diagram, ignore other conditions, -30000
16
+ - `previous-exists`: If `<previous_generation_content>` contains diagram, +21000
17
+ - `path-exclude`: If the document path or filename matches excluded patterns (e.g., `/faq/`, `CHANGELOG`, `release-notes`), -10000
18
+ - `less-words`: If document length <= 200 words AND less than 2 headings, -10000
19
+ - `overview`: If `<document_content>` provides a high-level overview, +3
20
+ - `architectural`: If `<document_content>` contains an architectural description (components/services/layers/modules), +3
21
+ - `workflow`: If `<document_content>` describes a workflow, sequence, user interactions, or data flow, +2
22
+ - `hierarchy`: If `<document_content>` describes a clear hierarchy (linked sub-docs / deeply nested sections), +1
23
+ - `introductory-major`: If `<document_content>` is an introductory page for a major section, +1
24
+
25
+ ## Output Requirements
26
+ - `details` is an array. Each element must include:
27
+ - `type`: matched scoring condition's type name
28
+ - `score`: matched scoring condition's score
29
+ - `reason`: text explaining why this scoring condition is matched
30
+ - `content`: `<document_content>` with placeholder inserted
31
+ - Identify the most logical insertion point in the `<document_content>`. (This is often after an introductory paragraph or before a list/section that the diagram will explain).
32
+ - Insert the exact placeholder string: DIAGRAM_PLACEHOLDER
33
+ - Crucially: Adjust the surrounding text to integrate the placeholder smoothly. Add a lead-in sentence.
34
+ - Good example: "The following diagram illustrates this data flow:"
35
+ - Good example: "This architecture is shown in the overview below:"
36
+ - Bad example: (Just inserting the placeholder with no context).
37
+ - Return the modified document content.
38
+ - Keep the original structure of the document, including page headings and hierarchy
39
+ - Only modify parts of the document text to improve the alignment between diagrams and their context
40
+ - The output must not include the `document_content` tag
41
+ - Do not provide any explanations; include only the document content itself
42
+
43
+ </diagram_generation_rules>
44
+
@@ -201,20 +201,6 @@ D2 provides special syntax for creating complex, structured diagram types common
201
201
  - Lifeline activations, also known as spans, are defined by connecting to a nested object on an actor. This syntax indicates the start and end of an operation on an actor's lifeline. Example: `alice.t1 -> bob: "invoke operation"`.
202
202
  - Groups (fragments) like loops or optional blocks are defined using nested containers that are not connected to anything. Example: `loop: { alice -> bob: "ping"; bob -> alice: "pong" }`.
203
203
 
204
- #### UML Class Diagrams
205
-
206
- - A class diagram is created by setting `shape: class` on a shape.
207
- - Fields and methods are defined as key-value pairs within the shape's block.
208
- - Visibility is specified with a prefix: `+` for public (this is the default), `-` for private, and `#` for protected.
209
- - Methods are identified by keys containing parentheses `()`. The value of the key specifies the return type. Example: `D2Parser: { shape: class; +reader: io.RuneReader; "-lookahead:rune"; "+peek(): (rune, eof bool)" }`.
210
-
211
- #### SQL Table Diagrams
212
-
213
- - An SQL table is created by setting `shape: sql_table`.
214
- - Columns are defined as keys, with their data type as the value.
215
- - Constraints (e.g., `primary_key`, `foreign_key`, `unique`) are defined in a nested block for the relevant column. Example: `users: { shape: sql_table; id: int { constraint: primary_key }; email: string { constraint: unique } }`.
216
- - Foreign key relationships are established by creating a standard connection from the foreign key column in one table to the primary key column in another. Example: `orders.user_id -> users.id`.
217
-
218
204
 
219
205
  ### 1.4 Strict Adherence to Predefined Keyword Values
220
206
 
@@ -14,4 +14,13 @@ Generate a d2 diagram that represents the following document content:
14
14
 
15
15
  <document_content>
16
16
  {{documentContent}}
17
- </document_content>
17
+ </document_content>
18
+
19
+ {% if diagramError %}
20
+ <diagram_check_feedback>
21
+
22
+ **Diagram generation error**
23
+ {{ diagramError }}
24
+
25
+ </diagram_check_feedback>
26
+ {% endif %}
@@ -10,7 +10,7 @@ Documentation Generation Rules:
10
10
  - **Markdown Syntax Constraint**: Use only GitHub Flavored Markdown (GFM) syntax by default. Prohibited extensions include: custom blocks `:::`, footnotes `[^1]: notes`, math formulas `$$ LaTeX`, highlighted text `==code==`, and other non-GFM syntax unless explicitly defined in custom component rules
11
11
  - Use proper Markdown link syntax, for example: [Next Chapter Title](next_chapter_path)
12
12
  - **Ensure next_chapter_path references either external URLs or valid paths from the documentation structure**—use absolute paths from the documentation structure
13
- - When DataSources includes third-party links, incorporate them appropriately throughout the document
13
+ - When detailDataSource includes third-party links, incorporate them appropriately throughout the document
14
14
  - Structure each section with: title, introduction, code examples, response data samples, and explanatory notes. Place explanations directly after code examples without separate "Example Description" subheadings
15
15
  - Maintain content completeness and logical flow so users can follow the documentation seamlessly
16
16
  - Provide comprehensive explanations for configuration options and parameters. When parameters accept multiple values, explain each option's purpose and include code examples where applicable
@@ -28,7 +28,7 @@ Documentation Generation Rules:
28
28
 
29
29
  </document_rules>
30
30
 
31
- <TONE_STYLE>
31
+ <tone_style>
32
32
  - Documentation should be plain, rigorous and accurate, avoiding grandiose or empty vocabulary
33
33
  - You are writing for humans, not algorithms
34
34
  - Clarity and Flow
@@ -41,4 +41,4 @@ Documentation Generation Rules:
41
41
  - Use contractions and idioms sparingly to maintain an informal, yet credible tone
42
42
  - Blend technical precision with relatable language
43
43
  - Be direct: say what happened, why it matters, and how it helps
44
- </TONE_STYLE>
44
+ </tone_style>