@aigne/doc-smith 0.8.15-beta.7 → 0.8.15-beta.9

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 (44) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/agents/evaluate/index.yaml +1 -3
  3. package/agents/generate/check-diagram.mjs +1 -1
  4. package/agents/generate/check-need-generate-structure.mjs +2 -7
  5. package/agents/generate/generate-structure.yaml +117 -65
  6. package/agents/generate/index.yaml +1 -2
  7. package/agents/generate/{merge-d2-diagram.yaml → merge-diagram.yaml} +7 -6
  8. package/agents/generate/update-document-structure.yaml +1 -1
  9. package/agents/generate/user-review-document-structure.mjs +1 -0
  10. package/agents/generate/utils/merge-document-structures.mjs +30 -0
  11. package/agents/schema/document-structure-item.yaml +23 -0
  12. package/agents/schema/document-structure-refine-item.yaml +20 -0
  13. package/agents/schema/document-structure.yaml +1 -3
  14. package/agents/update/batch-generate-document.yaml +1 -1
  15. package/agents/update/check-generate-diagram.mjs +26 -0
  16. package/agents/update/generate-diagram.yaml +0 -1
  17. package/agents/update/generate-document.yaml +17 -5
  18. package/agents/update/handle-document-update.yaml +8 -0
  19. package/agents/update/update-document-detail.yaml +2 -2
  20. package/agents/update/update-single-document.yaml +0 -1
  21. package/agents/update/user-review-document.mjs +6 -5
  22. package/agents/utils/load-sources.mjs +53 -13
  23. package/agents/utils/transform-detail-datasources.mjs +3 -3
  24. package/aigne.yaml +9 -4
  25. package/package.json +2 -1
  26. package/prompts/common/document/content-rules-core.md +4 -4
  27. package/prompts/common/document/openapi-usage-rules.md +36 -0
  28. package/prompts/common/document/role-and-personality.md +1 -2
  29. package/prompts/detail/d2-diagram/rules.md +11 -14
  30. package/prompts/detail/d2-diagram/system-prompt.md +0 -14
  31. package/prompts/detail/d2-diagram/user-prompt.md +30 -1
  32. package/prompts/detail/generate/document-rules.md +1 -1
  33. package/prompts/detail/generate/system-prompt.md +0 -6
  34. package/prompts/detail/generate/user-prompt.md +13 -60
  35. package/prompts/detail/update/system-prompt.md +0 -6
  36. package/prompts/detail/update/user-prompt.md +3 -3
  37. package/prompts/structure/generate/system-prompt.md +0 -30
  38. package/prompts/structure/generate/user-prompt.md +66 -27
  39. package/prompts/structure/review/structure-review-system.md +78 -0
  40. package/types/document-structure-schema.mjs +3 -3
  41. package/utils/extract-api.mjs +32 -0
  42. package/utils/file-utils.mjs +14 -87
  43. package/agents/generate/document-structure-tools/generate-sub-structure.mjs +0 -131
  44. package/agents/generate/generate-structure-without-tools.yaml +0 -65
@@ -4,11 +4,11 @@ import path from "node:path";
4
4
  import imageSize from "image-size";
5
5
  import {
6
6
  buildSourcesContent,
7
- calculateFileStats,
8
7
  loadFilesFromPaths,
9
8
  readFileContents,
10
9
  getMimeType,
11
10
  isRemoteFile,
11
+ calculateTokens,
12
12
  } from "../../utils/file-utils.mjs";
13
13
  import {
14
14
  getCurrentGitHead,
@@ -196,13 +196,10 @@ export default async function loadSources(
196
196
  }
197
197
 
198
198
  // Read all source files using the utility function
199
- let sourceFiles = await readFileContents(sourceFilesPaths, process.cwd());
200
-
201
- // Count tokens and lines using utility function
202
- const { totalTokens, totalLines } = calculateFileStats(sourceFiles);
203
-
204
- // check if totalTokens is too large
205
- const isLargeContext = totalTokens > INTELLIGENT_SUGGESTION_TOKEN_THRESHOLD;
199
+ let sourceFiles = (await readFileContents(sourceFilesPaths, process.cwd())).map((i) => ({
200
+ ...i,
201
+ tokens: calculateTokens(`\n${i.sourceId}\n${i.content}`),
202
+ }));
206
203
 
207
204
  // filter OpenAPI doc should after check isLargeContext
208
205
  sourceFiles = sourceFiles.filter((file) => {
@@ -215,6 +212,16 @@ export default async function loadSources(
215
212
  return !isOpenAPI;
216
213
  });
217
214
 
215
+ const totalTokens = sourceFiles.reduce((sum, file) => sum + file.tokens, 0);
216
+ const totalLines = sourceFiles.reduce(
217
+ (sum, file) => sum + file.content.split("\n").filter(Boolean).length,
218
+ 0,
219
+ );
220
+
221
+ const datasources = splitSourcesToChunks(sourceFiles, INTELLIGENT_SUGGESTION_TOKEN_THRESHOLD).map(
222
+ (i) => ({ dataSourceChunk: buildSourcesContent(i) }),
223
+ );
224
+
218
225
  const remoteFileList = [];
219
226
 
220
227
  sourceFiles.forEach((file) => {
@@ -226,8 +233,6 @@ export default async function loadSources(
226
233
  options.context.userContext.remoteFileList = remoteFileList;
227
234
  }
228
235
 
229
- // Build allSources string using utility function
230
- const allSources = buildSourcesContent(sourceFiles, isLargeContext);
231
236
  // all files path
232
237
  const allFilesPaths = sourceFiles.map((x) => `- ${toRelativePath(x.sourceId)}`).join("\n");
233
238
 
@@ -285,7 +290,7 @@ export default async function loadSources(
285
290
  }
286
291
 
287
292
  return {
288
- datasources: allSources,
293
+ datasources,
289
294
  content,
290
295
  originalDocumentStructure,
291
296
  files,
@@ -293,7 +298,6 @@ export default async function loadSources(
293
298
  totalTokens,
294
299
  totalLines,
295
300
  mediaFiles,
296
- isLargeContext,
297
301
  allFilesPaths,
298
302
  };
299
303
  }
@@ -342,7 +346,13 @@ loadSources.output_schema = {
342
346
  type: "object",
343
347
  properties: {
344
348
  datasources: {
345
- type: "string",
349
+ type: "array",
350
+ items: {
351
+ type: "object",
352
+ properties: {
353
+ dataSourceChunk: { type: "string" },
354
+ },
355
+ },
346
356
  },
347
357
  files: {
348
358
  type: "array",
@@ -373,3 +383,33 @@ loadSources.output_schema = {
373
383
  };
374
384
 
375
385
  loadSources.task_render_mode = "hide";
386
+
387
+ function splitSourcesToChunks(sources, maxTokens) {
388
+ const chunks = [];
389
+
390
+ let currentChunk = [];
391
+ let currentTokens = 0;
392
+
393
+ for (const source of sources) {
394
+ const sourceTokens = source.tokens;
395
+
396
+ if (currentTokens + sourceTokens > maxTokens) {
397
+ // Start a new chunk
398
+ if (currentChunk.length > 0) {
399
+ chunks.push(currentChunk);
400
+ }
401
+ currentChunk = [source];
402
+ currentTokens = sourceTokens;
403
+ } else {
404
+ // Add to current chunk
405
+ currentChunk.push(source);
406
+ currentTokens += sourceTokens;
407
+ }
408
+ }
409
+
410
+ if (currentChunk.length > 0) {
411
+ chunks.push(currentChunk);
412
+ }
413
+
414
+ return chunks;
415
+ }
@@ -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,9 @@
1
1
  #!/usr/bin/env aigne
2
2
 
3
- chat_model:
4
- provider: google
5
- name: gemini-2.5-pro
3
+ model:
4
+ model: aignehub/gemini-2.5-pro # reasoning_effort 128-32768
5
+ # https://github.com/AIGNE-io/aigne-framework/blob/main/models/gemini/src/gemini-chat-model.ts#L115
6
+ reasoning_effort: 502
6
7
  # name: gemini-2.5-flash
7
8
  temperature: 0.8
8
9
  agents:
@@ -11,7 +12,6 @@ agents:
11
12
 
12
13
  # Documentation Structure Generation
13
14
  - ./agents/generate/generate-structure.yaml
14
- - ./agents/generate/generate-structure-without-tools.yaml
15
15
  - ./agents/generate/update-document-structure.yaml
16
16
  - ./agents/generate/check-need-generate-structure.mjs
17
17
  - ./agents/generate/refine-document-structure.yaml
@@ -95,6 +95,11 @@ agents:
95
95
  - ./agents/evaluate/document-structure.yaml
96
96
  - ./agents/evaluate/document.yaml
97
97
  - ./agents/evaluate/code-snippet.mjs
98
+
99
+ # Diagram
100
+ - ./agents/generate/merge-diagram.yaml
101
+ - ./agents/update/generate-diagram.yaml
102
+ - ./agents/update/check-generate-diagram.mjs
98
103
  cli:
99
104
  chat: ./agents/chat/index.yaml
100
105
  agents:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aigne/doc-smith",
3
- "version": "0.8.15-beta.7",
3
+ "version": "0.8.15-beta.9",
4
4
  "description": "AI-driven documentation generation tool built on the AIGNE Framework",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -56,6 +56,7 @@
56
56
  "remark-lint": "^10.0.1",
57
57
  "remark-parse": "^11.0.0",
58
58
  "terminal-link": "^4.0.0",
59
+ "typescript": "^5.9.3",
59
60
  "ufo": "^1.6.1",
60
61
  "unified": "^11.0.5",
61
62
  "unist-util-visit": "^5.0.0",
@@ -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 detailDataSource, 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
8
  - Clearly differentiate content from other {{nodeName}} items in the documentStructure 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 detailDataSource 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
18
+ - Do not mention 'detailDataSource' in output, your content is for user consumption, and users are unaware of detailDataSource
19
19
  - Do not include file paths from Data Sources in output as they are meaningless to users
20
- - Avoid phrases like 'current {{nodeName}}'
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,13 +1,14 @@
1
- <diagram_generation_guide>
1
+ <diagram_generation_rules>
2
+ **Generation Workflow**
3
+ 1. Use the current `<detail_dataSource>`, `<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 `diagramSourceCode`. 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 `diagramSourceCode` 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
 
@@ -12,6 +12,35 @@ Generate a d2 diagram that represents the following document content:
12
12
 
13
13
  </user_rules>
14
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
+
15
35
  <document_content>
16
36
  {{documentContent}}
17
- </document_content>
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
@@ -43,14 +43,8 @@ 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
46
  {% include "../../common/document/media-file-list-usage-rules.md" %}
49
47
 
50
- Tool result usage rules:
51
- - Only use the `"role": "tool"` result as the datasource for document enhancement.
52
- - Do not include `"role": "agent"` content in the final output.
53
-
54
48
  </content_generation_rules>
55
49
 
56
50
 
@@ -2,20 +2,21 @@
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
11
 
12
+ - **Necessary**: Generate diagrams only when necessary.
13
+ </user_rules>
12
14
 
13
15
  {% set operation_type = "generating" %}
14
16
  {% include "../../common/document/user-preferences.md" %}
15
17
 
16
-
17
- <datasources>
18
- {{ detailDataSources }}
18
+ <detail_dataSource>
19
+ {{ detailDataSource }}
19
20
 
20
21
  {{ additionalInformation }}
21
22
 
@@ -23,66 +24,25 @@
23
24
  {{ assetsContent }}
24
25
  </media_file_list>
25
26
 
27
+ </detail_dataSource>
26
28
 
27
29
 
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
- ---
61
-
62
- **Expected output format:** A concise, clear, and easy-to-scan Markdown document.
63
-
64
- </openapi>
65
- {% endif %}
66
-
30
+ {% include "../../common/document/openapi-usage-rules.md" %}
67
31
 
68
32
  {% include "./detail-example.md" %}
69
33
 
70
-
71
34
  {% if content %}
72
- Content from previous generation:
73
- <last_content>
35
+ <previous_generation_content>
74
36
  {{content}}
75
- </last_content>
37
+ </previous_generation_content>
76
38
  {% endif %}
77
39
 
78
-
79
40
  {% if detailFeedback %}
80
41
  <content_review_feedback>
81
42
  {{ detailFeedback }}
82
43
  </content_review_feedback>
83
44
  {% endif %}
84
45
 
85
-
86
46
  {% if feedback %}
87
47
  User feedback on previous generation:
88
48
  <feedback>
@@ -90,19 +50,12 @@ User feedback on previous generation:
90
50
  </feedback>
91
51
  {% endif %}
92
52
 
93
-
94
53
  <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.
100
- - If the `generateDiagram` tool is not called, do not attempt to add any diagrams.
54
+ Generate detailed and well-structured document for the current {{nodeName}} based on user-provided information: current {{nodeName}} details (including title, description, path), detailDataSource, documentStructure (overall structural planning), and other relevant information.
101
55
 
102
56
  <steps>
103
57
  1. Analyze the provided document structure and user requirements to plan the content.
104
58
  2. Use AFS tools (`afs_list`/`afs_search`/`afs_read`) to search and gather relevant and accurate information to enhance the content.
105
- 3. Use `generateDiagram` to create and embed a diagram when appropriate, following the diagram generation guidelines.
106
- 4. Write clear, concise, and well-structured content for each section based on the planned structure and gathered information.
59
+ 3. Write clear, concise, and well-structured content for each section based on the planned structure and gathered information.
107
60
  </steps>
108
61
  </instructions>
@@ -40,12 +40,6 @@ Custom code block optimization rules:
40
40
 
41
41
  {% include "../../common/document/media-file-list-usage-rules.md" %}
42
42
 
43
- Diagram generation rules:
44
- {% include "../d2-diagram/guide.md" %}
45
- <diagram_generation_rules>
46
- {% include "../d2-diagram/system-prompt.md" %}
47
- </diagram_generation_rules>
48
-
49
43
  </content_optimization_rules>
50
44
 
51
45
 
@@ -15,9 +15,9 @@
15
15
  {{originalContent}}
16
16
  </original_page_content>
17
17
 
18
- <datasources>
18
+ <detail_dataSource>
19
19
 
20
- {{ detailDataSources }}
20
+ {{ detailDataSource }}
21
21
 
22
22
  {{ additionalInformation }}
23
23
 
@@ -25,7 +25,7 @@
25
25
  {{ assetsContent }}
26
26
  </media_file_list>
27
27
 
28
- </datasources>
28
+ </detail_dataSource>
29
29
 
30
30
  <user_feedback>
31
31
  {{feedback}}
@@ -14,34 +14,4 @@ You are an AI document strategist with the personality of an **INTJ (The Archite
14
14
  {% include "../../common/document-structure/conflict-resolution-guidance.md" %}
15
15
 
16
16
 
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
17
  {% include "../../common/document-structure/output-constraints.md" %}