@aigne/doc-smith 0.8.15-beta.1 → 0.8.15-beta.11

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 (89) hide show
  1. package/CHANGELOG.md +89 -0
  2. package/agents/clear/choose-contents.mjs +4 -4
  3. package/agents/clear/clear-auth-tokens.mjs +8 -8
  4. package/agents/clear/clear-deployment-config.mjs +2 -2
  5. package/agents/clear/clear-document-config.mjs +3 -3
  6. package/agents/clear/clear-document-structure.mjs +10 -10
  7. package/agents/clear/clear-generated-docs.mjs +103 -14
  8. package/agents/clear/clear-media-description.mjs +7 -7
  9. package/agents/evaluate/document-structure.yaml +3 -1
  10. package/agents/evaluate/document.yaml +3 -1
  11. package/agents/evaluate/index.yaml +1 -3
  12. package/agents/generate/check-diagram.mjs +1 -1
  13. package/agents/generate/check-need-generate-structure.mjs +2 -7
  14. package/agents/generate/draw-diagram.yaml +4 -0
  15. package/agents/generate/generate-structure.yaml +117 -65
  16. package/agents/generate/index.yaml +3 -3
  17. package/agents/generate/{merge-d2-diagram.yaml → merge-diagram.yaml} +7 -6
  18. package/agents/generate/update-document-structure.yaml +1 -1
  19. package/agents/generate/user-review-document-structure.mjs +3 -25
  20. package/agents/generate/utils/merge-document-structures.mjs +30 -0
  21. package/agents/init/check.mjs +4 -2
  22. package/agents/init/index.mjs +37 -7
  23. package/agents/media/load-media-description.mjs +12 -24
  24. package/agents/publish/publish-docs.mjs +3 -8
  25. package/agents/schema/document-execution-structure.yaml +1 -1
  26. package/agents/schema/document-structure-item.yaml +23 -0
  27. package/agents/schema/document-structure-refine-item.yaml +20 -0
  28. package/agents/schema/document-structure.yaml +1 -1
  29. package/agents/translate/index.yaml +1 -4
  30. package/agents/translate/record-translation-history.mjs +6 -2
  31. package/agents/translate/translate-multilingual.yaml +1 -1
  32. package/agents/update/batch-generate-document.yaml +1 -1
  33. package/agents/update/batch-update-document.yaml +1 -1
  34. package/agents/update/check-document.mjs +35 -13
  35. package/agents/update/check-generate-diagram.mjs +29 -0
  36. package/agents/update/generate-diagram.yaml +29 -0
  37. package/agents/update/generate-document.yaml +17 -30
  38. package/agents/update/handle-document-update.yaml +10 -1
  39. package/agents/update/save-and-translate-document.mjs +18 -47
  40. package/agents/update/update-document-detail.yaml +2 -1
  41. package/agents/update/update-single-document.yaml +1 -1
  42. package/agents/update/user-review-document.mjs +6 -5
  43. package/agents/utils/choose-docs.mjs +16 -5
  44. package/agents/utils/find-item-by-path.mjs +4 -2
  45. package/agents/utils/load-sources.mjs +63 -46
  46. package/agents/utils/{save-docs.mjs → post-generate.mjs} +2 -51
  47. package/agents/utils/save-doc-translation.mjs +27 -0
  48. package/agents/utils/{save-single-doc.mjs → save-doc.mjs} +17 -12
  49. package/agents/utils/save-sidebar.mjs +38 -0
  50. package/agents/utils/{transform-detail-datasources.mjs → transform-detail-data-sources.mjs} +7 -7
  51. package/aigne.yaml +16 -8
  52. package/package.json +3 -1
  53. package/prompts/common/document/content-rules-core.md +6 -6
  54. package/prompts/common/document/media-file-list-usage-rules.md +12 -0
  55. package/prompts/common/document/openapi-usage-rules.md +36 -0
  56. package/prompts/common/document/role-and-personality.md +1 -2
  57. package/prompts/common/document-structure/conflict-resolution-guidance.md +2 -2
  58. package/prompts/common/document-structure/document-structure-rules.md +8 -8
  59. package/prompts/common/document-structure/output-constraints.md +3 -3
  60. package/prompts/detail/custom/custom-components.md +38 -3
  61. package/prompts/detail/d2-diagram/rules.md +11 -14
  62. package/prompts/detail/d2-diagram/system-prompt.md +0 -14
  63. package/prompts/detail/d2-diagram/user-prompt.md +39 -0
  64. package/prompts/detail/generate/document-rules.md +3 -3
  65. package/prompts/detail/generate/system-prompt.md +2 -6
  66. package/prompts/detail/generate/user-prompt.md +20 -61
  67. package/prompts/detail/update/system-prompt.md +2 -6
  68. package/prompts/detail/update/user-prompt.md +7 -6
  69. package/prompts/evaluate/document.md +0 -4
  70. package/prompts/structure/check-document-structure.md +4 -4
  71. package/prompts/structure/generate/system-prompt.md +0 -31
  72. package/prompts/structure/generate/user-prompt.md +73 -29
  73. package/prompts/structure/review/structure-review-system.md +81 -0
  74. package/prompts/structure/update/system-prompt.md +1 -1
  75. package/prompts/structure/update/user-prompt.md +4 -4
  76. package/prompts/translate/code-block.md +13 -3
  77. package/prompts/translate/translate-document.md +3 -3
  78. package/types/document-structure-schema.mjs +3 -3
  79. package/utils/constants/index.mjs +6 -0
  80. package/utils/docs-finder-utils.mjs +85 -3
  81. package/utils/extract-api.mjs +32 -0
  82. package/utils/file-utils.mjs +153 -101
  83. package/utils/history-utils.mjs +20 -8
  84. package/utils/load-config.mjs +20 -1
  85. package/utils/markdown-checker.mjs +35 -1
  86. package/utils/utils.mjs +67 -65
  87. package/agents/generate/document-structure-tools/generate-sub-structure.mjs +0 -131
  88. package/agents/generate/generate-structure-without-tools.yaml +0 -65
  89. package/prompts/common/document/media-handling-rules.md +0 -9
@@ -72,12 +72,11 @@ Suitable for displaying multiple links using a card list format, providing a ric
72
72
 
73
73
  ### Attributes
74
74
 
75
- - data-columns (optional): Number of columns, integer (e.g., 2, 3). Default is 2.
76
- - Must contain multiple <x-card> elements internally.
75
+ - data-columns (optional): Must be an **integer 2**. Values below 2 are disallowed. Default is 2.
77
76
 
78
77
  ### Children
79
78
 
80
- - Must contain multiple <x-card> elements internally.
79
+ - Must contain multiple `<x-card>` elements internally.
81
80
 
82
81
  ### Usage Rules
83
82
 
@@ -107,6 +106,25 @@ Example 2: Two-column cards with images
107
106
  </x-cards>
108
107
  ```
109
108
 
109
+ ### Bad Examples
110
+
111
+ Example 1: Using a single-column layout (`data-columns="1"`) is not allowed
112
+
113
+ ```md
114
+ <x-cards data-columns="1">
115
+ <x-card data-title="Feature 1" data-icon="lucide:rocket">Description of Feature 1.</x-card>
116
+ <x-card data-title="Feature 2" data-icon="lucide:bolt">Description of Feature 2.</x-card>
117
+ </x-cards>
118
+ ```
119
+
120
+ Example 2: Contains only one `<x-card>` (must include multiple cards)
121
+
122
+ ```md
123
+ <x-cards data-columns="2">
124
+ <x-card data-title="Card A" data-image="https://picsum.photos/id/10/300/300">Content A</x-card>
125
+ </x-cards>
126
+ ```
127
+
110
128
  ## XField: Structured data field
111
129
 
112
130
  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.
@@ -414,6 +432,7 @@ Used to group multiple related `<x-field>` elements at the top level, indicating
414
432
 
415
433
  - **Top-Level Only**: Used only at the top level for grouping related `<x-field>` elements. Cannot be nested inside other `<x-field>` or `<x-field-group>` elements
416
434
  - **Structured Data Only**: Use `<x-field-group>` for fields **other than simple types** (`string`, `number`, `boolean`, `symbol`), e.g., Properties, Context, Parameters, Return values. For simple-type fields, use plain Markdown text.
435
+ - **Spacing Around**: Always insert a blank line before and after `<x-field-group>` when it’s adjacent to Markdown content.
417
436
 
418
437
  ### Good Examples
419
438
 
@@ -482,4 +501,20 @@ Example 5: Using x-field-group for simple-type (violates "Structured Data Only"
482
501
  </x-field-group>
483
502
  ```
484
503
 
504
+ Example 6: Missing blank line before x-field-group (violates "Spacing Around" rule)
505
+
506
+ ```md
507
+ **Parameters**
508
+ <x-field-group>
509
+ <x-field data-name="initialState" data-type="any" data-required="false">
510
+ <x-field-desc markdown>The initial state value.</x-field-desc>
511
+ </x-field>
512
+ </x-field-group>
513
+
514
+ `useReducer` returns an array with two items:
515
+ <x-field-group>
516
+ <x-field data-name="dispatch" data-type="function" data-desc="A function that you can call with an action to update the state."></x-field>
517
+ </x-field-group>
518
+ ```
519
+
485
520
  </custom_components_usage>
@@ -1,13 +1,14 @@
1
- <diagram_generation_guide>
1
+ <diagram_generation_rules>
2
+ **Generation Workflow**
3
+ 1. Use the current `<detail_data_source>`, `<content_review_feedback>`, and `<feedback>` to decide whether this document requires a diagram.
4
+ 2. When a diagram is needed, call the `generateDiagram` tool to create it and insert the returned content at the most fitting location in the document.
5
+ 3. Check whether the data sources include `<diagram_source_code>`. If not, remove any embedded diagram from the document.
2
6
 
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.
7
+ **Generation Result Usage**
8
+ When `<diagram_source_code>` is available, insert it into the document exactly as returned without any edits.
9
9
 
10
- 2. Diagram Triggers and Types: Call `generateDiagram` and select the most appropriate type when describing the following specific content
10
+ **Generation Requirements**
11
+ 1. Diagram Triggers and Types: Call `generateDiagram` and select the most appropriate type when describing the following specific content
11
12
  - Architecture Diagram (High-Level)
12
13
  - **Trigger**: When the document provides a high-level overview of a system, project, or the overall documentation set.
13
14
  - **Content**: Must illustrate the main components, their relationships, and the overall structure.
@@ -19,11 +20,7 @@
19
20
  - **Diagram Type Selection**:
20
21
  - **Flowchart**: Use for step-by-step processes, algorithms, or decision-making logic.
21
22
  - **Sequence Diagram**: Use for time-ordered interactions between different components or actors (e.g., API calls).
22
- 3. Constraints and Best Practices
23
+ 2. Constraints and Best Practices
23
24
  - **Quantity Limit**: Generate a maximum of **three** diagrams per document.
24
25
  - **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>
26
+ </diagram_generation_rules>
@@ -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
 
@@ -2,6 +2,45 @@ Follow the given rules and ISTJ style from your system instructions.
2
2
 
3
3
  Generate a d2 diagram that represents the following document content:
4
4
 
5
+ <user_locale>
6
+ {{ locale }}
7
+ </user_locale>
8
+
9
+ <user_rules>
10
+
11
+ - Output only the diagram labels and text in the {{ locale }} language — keep all variable names, component names, and syntax unchanged.
12
+
13
+ </user_rules>
14
+
15
+ <diagram_rules>
16
+
17
+ 1. Diagram Triggers and Types: Select the most appropriate type when describing the following specific content
18
+ - Architecture Diagram (High-Level)
19
+ - **Trigger**: When the document provides a high-level overview of a system, project, or the overall documentation set.
20
+ - **Content**: Must illustrate the main components, their relationships, and the overall structure.
21
+ - Structural Diagram (Module-Level)
22
+ - **Trigger**: When generating the introductory document for a major section or module.
23
+ - **Content**: Must show the key sub-components, files, or core concepts within that specific module.
24
+ - Process and Interaction Diagrams (Detailed)
25
+ - **Trigger**: When the document describes a workflow, a sequence of events, user interactions, or data flow.
26
+ - **Diagram Type Selection**:
27
+ - **Flowchart**: Use for step-by-step processes, algorithms, or decision-making logic.
28
+ - **Sequence Diagram**: Use for time-ordered interactions between different components or actors (e.g., API calls).
29
+ 2. Constraints and Best Practices
30
+ - **Keep it Simple**: Avoid overcomplicating the diagram.
31
+ - **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.
32
+
33
+ </diagram_rules>
34
+
5
35
  <document_content>
6
36
  {{documentContent}}
7
37
  </document_content>
38
+
39
+ {% if diagramError %}
40
+ <diagram_check_feedback>
41
+
42
+ **Diagram generation error**
43
+ {{ diagramError }}
44
+
45
+ </diagram_check_feedback>
46
+ {% 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>
@@ -43,11 +43,7 @@ Custom component generation rules:
43
43
  Custom code block generation rules:
44
44
  {% include "../custom/custom-code-block.md" %}
45
45
 
46
- {% include "../d2-diagram/guide.md" %}
47
-
48
- Tool result usage rules:
49
- - Only use the `"role": "tool"` result as the datasource for document enhancement.
50
- - Do not include `"role": "agent"` content in the final output.
46
+ {% include "../../common/document/media-file-list-usage-rules.md" %}
51
47
 
52
48
  </content_generation_rules>
53
49
 
@@ -56,7 +52,7 @@ Tool result usage rules:
56
52
  <output_constraints>
57
53
 
58
54
  1. Output the complete Markdown content for {{nodeName}}, only the content itself—no explanations or extra information.
59
- 2. Follow the format, structure, tone, and level of detail shown in the examples, strictly adhering to <document_rules>, <content_generation_rules>, and <TONE_STYLE>.
55
+ 2. Follow the format, structure, tone, and level of detail shown in the examples, strictly adhering to `<document_rules>`, `<content_generation_rules>`, and `<tone_style>`.
60
56
  3. Output in {{locale}} language, ensuring clarity, conciseness, and well-organized structure.
61
57
  4. Do not include any self-introduction or conversational text. Output only the documentation content itself.
62
58
 
@@ -2,87 +2,52 @@
2
2
  {{ locale }}
3
3
  </user_locale>
4
4
 
5
-
6
5
  <user_rules>
7
6
  {{ rules }}
8
7
 
9
- ** Output content in {{ locale }} language **
10
- </user_rules>
8
+ ** Output content in {{ locale }} language. **
9
+
10
+ ** Don't generate any diagram in the document, give boolean value in `needDiagram` field & plan a placeholder in document content for diagram (use `DIAGRAM_PLACEHOLDER` as placeholder text). **
11
+ - Use the current `<detail_data_source>`, `<content_review_feedback>`, and `<feedback>` to decide whether this document requires a diagram.
12
+ - If `<feedback>` contains a request to add a diagram, set `needDiagram` to true.
13
+ - If `<feedback>` contains a request to remove a diagram, set `needDiagram` to false.
11
14
 
15
+ - **Necessary**: Generate diagrams only when necessary.
16
+ </user_rules>
12
17
 
13
18
  {% set operation_type = "generating" %}
14
19
  {% include "../../common/document/user-preferences.md" %}
15
20
 
16
-
17
- <datasources>
18
- {{ detailDataSources }}
21
+ <detail_data_source>
22
+ {{ detailDataSource }}
19
23
 
20
24
  {{ additionalInformation }}
21
25
 
22
- <media_list>
26
+ {% if assetsContent %}
27
+ <media_file_list>
23
28
  {{ assetsContent }}
24
- </media_list>
25
-
26
- {% include "../../common/document/media-handling-rules.md" %}
27
-
28
- </datasources>
29
-
30
- {% if openAPISpec %}
31
- <openapi>
32
-
33
- **Goal:** Use the provided OpenAPI (Swagger) specification, align it with the current page objective, and leverage it to refine this document.
34
-
35
- **OpenAPI File Content:**
36
- <openapi_doc>
37
-
38
- {{ openAPISpec }}
39
-
40
- </openapi_doc>
41
-
42
- ---
43
-
44
- ### **Documentation Requirements and Constraints**
45
-
46
- 1. **Extract the core content:**
47
- * Organize the document by functional modules.
48
- * For each path item, include the following elements:
49
- * HTTP method and path.
50
- * Concise summary.
51
- * Detailed description.
52
- * Request parameters: name, location (`in`), type, required flag, description.
53
- * Request body: describe its structure when present.
54
- * Responses: at least the key status codes (e.g., 200, 201, 400, 500) and their schemas.
55
-
56
- 2. **Mandatory API description constraints (deduplication rule):**
57
- * **Ensure that throughout the document (including preface, overview, etc.), any introduction to the project APIs appears only within this OpenAPI-generated "API reference" section.**
58
- * **Never** repeat or expand the interface list elsewhere in the document (for example, "Quick Start" or "Architecture Overview" sections).
59
-
60
- ---
29
+ </media_file_list>
30
+ {% endif %}
61
31
 
62
- **Expected output format:** A concise, clear, and easy-to-scan Markdown document.
32
+ </detail_data_source>
63
33
 
64
- </openapi>
65
- {% endif %}
66
34
 
35
+ {% include "../../common/document/openapi-usage-rules.md" %}
67
36
 
68
37
  {% include "./detail-example.md" %}
69
38
 
70
-
71
39
  {% if content %}
72
- Content from previous generation:
73
- <last_content>
40
+ <previous_generation_content>
74
41
  {{content}}
75
- </last_content>
42
+ </previous_generation_content>
76
43
  {% endif %}
77
44
 
78
-
79
45
  {% if detailFeedback %}
80
46
  <content_review_feedback>
81
47
  {{ detailFeedback }}
82
48
  </content_review_feedback>
83
49
  {% endif %}
84
50
 
85
-
86
51
  {% if feedback %}
87
52
  User feedback on previous generation:
88
53
  <feedback>
@@ -90,18 +55,12 @@ User feedback on previous generation:
90
55
  </feedback>
91
56
  {% endif %}
92
57
 
93
-
94
58
  <instructions>
95
- Generate detailed and well-structured document for the current {{nodeName}} based on user-provided information: current {{nodeName}} details (including title, description, path), DataSources, documentStructure (overall structural planning), and other relevant information.
96
-
97
- YOU SHOULD:
98
- - Use AFS tools `afs_list` `afs_search` or `afs_read` to gather relevant and accurate information to enhance the content.
99
- - Follow rules in `<diagram_generation_guide>`: use `generateDiagram` tool to create and embed a diagram when appropriate, following the diagram generation guidelines.
59
+ Generate detailed and well-structured document for the current {{nodeName}} based on user-provided information: current {{nodeName}} details (including title, description, path), `<detail_data_source>`, `<document_structure>` (overall structural planning), and other relevant information.
100
60
 
101
61
  <steps>
102
62
  1. Analyze the provided document structure and user requirements to plan the content.
103
63
  2. Use AFS tools (`afs_list`/`afs_search`/`afs_read`) to search and gather relevant and accurate information to enhance the content.
104
- 3. Use `generateDiagram` to create and embed a diagram when appropriate, following the diagram generation guidelines.
105
- 4. Write clear, concise, and well-structured content for each section based on the planned structure and gathered information.
64
+ 3. Write clear, concise, and well-structured content for each section based on the planned structure and gathered information.
106
65
  </steps>
107
66
  </instructions>
@@ -38,11 +38,7 @@ Custom component optimization rules:
38
38
  Custom code block optimization rules:
39
39
  {% include "../custom/custom-code-block.md" %}
40
40
 
41
- Diagram generation rules:
42
- {% include "../d2-diagram/guide.md" %}
43
- <diagram_generation_rules>
44
- {% include "../d2-diagram/system-prompt.md" %}
45
- </diagram_generation_rules>
41
+ {% include "../../common/document/media-file-list-usage-rules.md" %}
46
42
 
47
43
  </content_optimization_rules>
48
44
 
@@ -95,7 +91,7 @@ Tool usage guidelines:
95
91
  **updateDocumentContent**: Use this tool to apply changes to the document content
96
92
  - Generate a precise unified diff patch based on the user feedback
97
93
  - The diff should include context lines for accurate application
98
- - Only consider content within <page_content> tag when calculating line numbers, ensure line number calculation is accurate
94
+ - Only consider content within `<page_content>` tag when calculating line numbers, ensure line number calculation is accurate
99
95
  - Test the patch application to ensure it works correctly
100
96
 
101
97
  Error handling:
@@ -15,18 +15,19 @@
15
15
  {{originalContent}}
16
16
  </original_page_content>
17
17
 
18
- <datasources>
18
+ <detail_data_source>
19
19
 
20
- {{ detailDataSources }}
20
+ {{ detailDataSource }}
21
21
 
22
22
  {{ additionalInformation }}
23
23
 
24
- <media_list>
24
+ {% if assetsContent %}
25
+ <media_file_list>
25
26
  {{ assetsContent }}
26
- </media_list>
27
+ </media_file_list>
28
+ {% endif %}
27
29
 
28
- {% include "../../common/document/media-handling-rules.md" %}
29
- </datasources>
30
+ </detail_data_source>
30
31
 
31
32
  <user_feedback>
32
33
  {{feedback}}
@@ -21,10 +21,6 @@ Please **strictly adhere** to the evaluation standards defined in `<standards>`
21
21
  {{ content }}
22
22
  </document_content>
23
23
 
24
- <document_translation>
25
- {{ translationsString }}
26
- </document_translation>
27
-
28
24
  <document_content_plan>
29
25
  {{ description }}
30
26
  </document_content_plan>
@@ -38,9 +38,9 @@ This is the primary scenario. You must perform a detailed comparison.
38
38
 
39
39
  **Step-by-step Analysis**:
40
40
  1. **Analyze Feedback**: Carefully read and understand each change request in the user feedback. Identify which nodes need to be modified, added, or deleted.
41
- 2. **Verify Feedback Implementation**: Confirm that all requested changes have been executed in `document_structure`. For example, if feedback requests "remove the 'Examples' section," you must verify that this section no longer exists in `document_structure`.
42
- 3. **Verify Unrelated Node Stability**: This is the most critical check. Iterate through all nodes in `document_structure`. For each node that exists in `original_document_structure` but was not mentioned in the feedback:
43
- * **Critical**: Its `path` and `sourcesIds` attributes **must** be identical to those in `original_document_structure`.
41
+ 2. **Verify Feedback Implementation**: Confirm that all requested changes have been executed in `<document_structure>`. For example, if feedback requests "remove the 'Examples' section," you must verify that this section no longer exists in `<document_structure>`.
42
+ 3. **Verify Unrelated Node Stability**: This is the most critical check. Iterate through all nodes in `<document_structure>`. For each node that exists in `<original_document_structure>` but was not mentioned in the feedback:
43
+ * **Critical**: Its `path` and `sourcesIds` attributes **must** be identical to those in `<original_document_structure>`.
44
44
  * Ideally, other attributes (such as `title`, `description`) should also remain stable, unless these changes are directly caused by a requested modification or result from DataSource updates.
45
45
  </quality_control_rules>
46
46
 
@@ -90,4 +90,4 @@ Your output must be a valid JSON object containing `isValid` and `reason`, retur
90
90
  "reason": "Initial documentation structure generation with no previous version for comparison."
91
91
  }
92
92
  ```
93
- </output_constraints>
93
+ </output_constraints>
@@ -7,41 +7,10 @@ You are an AI document strategist with the personality of an **INTJ (The Archite
7
7
  {% include "../../common/document-structure/glossary.md" %}
8
8
 
9
9
 
10
-
11
10
  {% include "../../common/document-structure/document-structure-rules.md" %}
12
11
 
13
12
 
14
13
  {% include "../../common/document-structure/conflict-resolution-guidance.md" %}
15
14
 
16
15
 
17
- <sub_structure>
18
- {% if isLargeContext %}
19
- Analyze the provided file list and DataSources to complete the document structure planning:
20
- - If the DataSources contain sufficient context and already include content from all files in the file list, you can directly generate a detailed document structure.
21
- - First plan the document structure based on DataSources and <file_list>, ensuring all user-provided information will be presented in the document
22
- - Ensure initial planning has sufficient content separation to avoid oversized data sources when generating sub-documents
23
- - For sections with extensive content, use the `generateSubStructure` tool to generate detailed sub-structures
24
- - Trigger all Tool calls at once whenever possible
25
- - When triggering Tool calls, only output Tool call related information
26
- - Carefully check the data returned by the `generateSubStructure` tool, integrate all data, merge the complete document structure, and finally verify that it meets the requirements in <output_constraints>
27
-
28
- Using `generateSubStructure`:
29
- - When the provided file list is large and DataSources don't contain all file contents, resulting in an oversized context, split the generation into sub-document structures to make the context more focused and complete
30
- - Generate sub-documents to more effectively and fully utilize the data source files provided in <file_list>
31
- - Requires `parentDocument` and `subSourcePaths` as context parameters
32
- - `subSourcePaths` supports individual files and Glob Patterns, generation process:
33
- - Analyze relevant files from the file list, include as many related files as possible to ensure complete context
34
- - Selected files must come from <file_list>, ensure file paths are correct
35
- - Consolidation Rules:
36
- 1. If all files from a single directory (e.g., src/) have been selected, consolidate them into a pattern like src/\*.
37
- 2. If multiple files with a common naming convention are selected (e.g., README.md, README-dockerfile.md, README-turbo.md), consolidate them into a pattern like README\*.md.
38
- 3. Ensure only files correctly matched by the pattern are removed, while unmatched files must be preserved
39
- - Merge the returned subStructure into the overall document structure plan, **ensuring all subStructures returned by the tool are included**.
40
-
41
- {% else %}
42
- The current context is sufficient, proceed directly with document structure planning based on DataSources.
43
- {% endif %}
44
- </sub_structure>
45
-
46
-
47
16
  {% include "../../common/document-structure/output-constraints.md" %}
@@ -1,23 +1,18 @@
1
+ <data_sources>
2
+ Following are the partial or complete data sources provided by the user to help you design the document structure. Use these data sources to inform your structural planning.
1
3
 
2
- {% include "../../common/document-structure/user-locale-rules.md" %}
3
-
4
- {% include "../../common/document-structure/user-preferences.md" %}
5
-
4
+ {{ dataSourceChunk }}
6
5
 
7
- <file_list>
8
- {{allFilesPaths}}
9
- </file_list>
10
6
 
11
- <datasources>
12
- {{ datasources }}
13
- </datasources>
7
+ NOTICE: There are additional data source contents not displayed. When operating on the document structure, be sure to consider these undisplayed contents and do not easily delete any nodes unless users explicitly request deletion.
8
+ </data_sources>
14
9
 
15
10
  {% if userContext.openAPISpec %}
16
11
  <openapi>
17
12
 
18
13
  **Goal:** Use the provided OpenAPI (Swagger) specification to design how the OpenAPI content and the overall document should be structured together.
19
14
 
20
- **OpenAPI File Content:**
15
+ **OpenAPI File Content:**
21
16
  <openapi_doc>
22
17
 
23
18
  {{ userContext.openAPISpec }}
@@ -46,21 +41,38 @@
46
41
  </openapi>
47
42
  {% endif %}
48
43
 
44
+ <document_info>
45
+ projectName: |
46
+ {{projectName}}
47
+ {% if projectDesc %}
48
+ projectDesc: |
49
+ {{projectDesc}}
50
+ {% endif %}
51
+ </document_info>
49
52
 
50
- {% if originalDocumentStructure %}
51
53
  <last_document_structure>
52
- {{originalDocumentStructure}}
54
+
55
+ {% if originalDocumentStructure %}
56
+ {{ originalDocumentStructure | yaml.stringify }}
57
+ {% elseif userContext.originalDocumentStructure %}
58
+ {{ userContext.originalDocumentStructure | yaml.stringify }}
59
+ {% else %}
60
+ No previous document structure provided. generate a new structure based on the data sources!
61
+ {% endif %}
62
+
53
63
  </last_document_structure>
54
64
 
55
65
 
66
+ {% include "../../common/document-structure/user-locale-rules.md" %}
67
+
68
+ {% include "../../common/document-structure/user-preferences.md" %}
69
+
56
70
  <last_document_structure_rule>
57
71
  If a previous structural plan (last_document_structure) is provided, follow these rules:
58
72
  1. **Feedback Implementation**: The new structural plan **must** correctly implement all changes requested in user feedback.
59
73
  2. **Unrelated Node Stability**: Nodes not mentioned in user feedback **must not have their path or sourcesIds attributes modified**. `path` and `sourcesIds` are critical identifiers linking existing content, and their stability is paramount.
60
74
  Ideally, other attributes (such as `title`, `description`) should also remain stable, unless these changes are directly caused by a requested modification or result from DataSource updates.
61
75
  </last_document_structure_rule>
62
- {% endif %}
63
-
64
76
 
65
77
  {% if documentStructure %}
66
78
  <review_document_structure>
@@ -89,30 +101,62 @@ The current process is planning sub-structures for the following section:
89
101
  {{parentDocument}}
90
102
 
91
103
  Sub-structures must meet the following requirements:
92
- - Sub-structures are planned based on DataSources and the parent document's description
104
+ - Sub-structures are planned based on `<data_sources>` and the parent document's description
93
105
  - The parent document provides an overview of the planned content, while sub-structures directly plan the specific content to be displayed
94
106
  - Further break down and comprehensively display the content planned in the parent document
95
- - All sub-structures must have their parentId value set to {{parentDocument.path}}
107
+ - All sub-structures must have their parentPath value set to {{parentDocument.path}}
96
108
  </parent_document>
97
109
  {% endif %}
98
110
 
99
111
  <instructions>
100
- Your task is to design a detailed structural plan for the document to be generated. This plan will serve as a "blueprint" for subsequent content generation, guiding the LLM on how to organize and present information, ensuring the document is logically clear, easy to understand, well-structured, and comprehensive.
112
+ Your task is to **analyze, refine, and adjust** the existing document structure (`last_document_structure`) based on the partial code repository content currently provided, generating a structural update plan.
113
+ You are not creating a structure from scratch, but rather **performing intelligent updates based on understanding the existing structure** to make the document structure more accurately reflect the latest code content, architectural changes, and logical relationships.
114
+
115
+ ## When using `<data_sources>` data sources, please note the following:
116
+
117
+ - Fully respect the project descriptions and usage instructions in README files, as these typically summarize the project's core functionality and objectives.
118
+ - Pay attention to comments and docstrings in source code files, as these reveal the design intent and usage methods of the code.
119
+ - Understand the relationships between various modules and files, which helps build a logically clear and well-structured document hierarchy.
120
+ - Notice key concepts, APIs, and configuration options in the code, as these are typically important components of the document structure.
121
+ - The generated document structure must include all public modules, interfaces, and features to ensure document completeness and usability.
122
+
123
+
124
+ ## Objective
125
+
126
+ Your output should contain a `structures` array with document structure items that need to be added or updated:
127
+
128
+ - **structures**: Array of document structure items representing incremental changes to the existing document structure. Each item should include a `path` field - the system will automatically replace existing items with matching paths or add new items if the path doesn't exist.
129
+
130
+ IMPORTANT: You should avoid duplicating existing structure items. Only include items that are genuinely new or need updates. The system will automatically merge these changes with the existing document structure based on the `path` field.
131
+
132
+ ## Behavior Rules
133
+
134
+ 1. **Understanding and Inheritance**
135
+ - Fully understand the hierarchical logic, section divisions, and naming style in `<last_document_structure>`.
136
+ - Perform incremental updates based on this foundation, not complete rewrites.
137
+ - Preserve existing reasonable structures, only modify or extend when there is clear justification.
138
+
139
+ 2. **Contextual Association Analysis**
140
+ - You will receive part of the code repository content (such as partial source files or directory content), please analyze their **documentation value and structural impact**.
141
+ - Identify which parts represent new concepts, APIs, modules, configurations, or features; determine if they require adding or modifying corresponding sections in the document structure.
101
142
 
102
- Key capabilities and behavioral principles:
103
- - Data Comprehension: Ability to parse and understand structured and unstructured data, identifying key concepts, entities, attributes, relationships, and processes within them.
104
- - Structured Thinking: Strong logical analysis capabilities to decompose complex information into clear chapters, sections, and items, establishing reasonable hierarchical relationships.
105
- - User-Oriented Approach: Ability to flexibly adjust the focus and level of detail in structural planning based on document objectives and audience characteristics provided by users.
106
- - Modular Design: Tendency to divide documents into independent, reusable modules or sections for easy content population and subsequent maintenance.
107
- - Flexibility and Adaptability: Ability to handle multiple types of data sources and design the most suitable documentation structure based on data source characteristics (such as code function/class structures, API endpoints/parameters, text paragraphs/themes).
108
- - Clarity and Completeness: Ensure the final structural plan is easy to understand and can guide the LLM to generate a comprehensive and well-organized document.
143
+ 3. **Structure Adjustment Strategy**
144
+ - If new content supplements details of existing sections, include the updated item in the `structures` array with the same path.
145
+ - If new content introduces new topics, modules, or hierarchies, include new items in the `structures` array with new paths.
146
+ - Ensure the position, hierarchy, and naming of new nodes align with the overall document logic.
109
147
 
148
+ 4. **Consistency and Clarity**
149
+ - Ensure new or modified structure items are consistent with existing structure style.
150
+ - Each structure node (whether new or updated) should include:
151
+ - **Title**
152
+ - **Brief description in one sentence**, describing main content and purpose
153
+ - Maintain clear hierarchy, avoid duplication, ensure logical coherence. Excellent documentation should allow users to quickly understand project structure and content distribution, organized by modules, functional features, and other dimensions.
110
154
 
111
- Objectives:
112
- - Create a clear and logical structural plan that comprehensively presents information from the user-provided context while providing users with intuitive navigation paths.
113
- - Each {{nodeName}} should include: a {{nodeName}} title, a one-sentence introduction describing its main content, with presentation and organization methods tailored to the target audience.
155
+ 5. **Requirements**
156
+ - Follow all rules and guidelines in `<document_structure_rules>`.
157
+ - Generate rich document structure where functional modules must have sub-documents, comprehensively covering the codebase's functionality and modules, ensuring users can easily get started, understand, and use various modules and main features of the project through documentation.
114
158
 
115
159
  {% include "../../common/document-structure/intj-traits.md" %}
116
160
 
117
- Always follow one principle: You must ensure the final structural plan meets user requirements.
161
+ You must make reasonable incremental modifications based solely on the new information provided while respecting the existing structure, ensuring the final structure remains complete, clear, and extensible.
118
162
  </instructions>