@aigne/doc-smith 0.8.15-beta.1 → 0.8.15-beta.10
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.
- package/CHANGELOG.md +76 -0
- package/agents/clear/choose-contents.mjs +4 -4
- package/agents/clear/clear-auth-tokens.mjs +8 -8
- package/agents/clear/clear-deployment-config.mjs +2 -2
- package/agents/clear/clear-document-config.mjs +3 -3
- package/agents/clear/clear-document-structure.mjs +10 -10
- package/agents/clear/clear-generated-docs.mjs +103 -14
- package/agents/clear/clear-media-description.mjs +7 -7
- package/agents/evaluate/document-structure.yaml +3 -1
- package/agents/evaluate/document.yaml +3 -1
- package/agents/evaluate/index.yaml +1 -3
- package/agents/generate/check-diagram.mjs +1 -1
- package/agents/generate/check-need-generate-structure.mjs +2 -7
- package/agents/generate/draw-diagram.yaml +4 -0
- package/agents/generate/generate-structure.yaml +117 -65
- package/agents/generate/index.yaml +3 -3
- package/agents/generate/{merge-d2-diagram.yaml → merge-diagram.yaml} +7 -6
- package/agents/generate/update-document-structure.yaml +1 -1
- package/agents/generate/user-review-document-structure.mjs +1 -0
- package/agents/generate/utils/merge-document-structures.mjs +30 -0
- package/agents/init/check.mjs +3 -1
- package/agents/init/index.mjs +37 -7
- package/agents/media/load-media-description.mjs +12 -24
- package/agents/publish/publish-docs.mjs +3 -8
- package/agents/schema/document-execution-structure.yaml +1 -1
- package/agents/schema/document-structure-item.yaml +23 -0
- package/agents/schema/document-structure-refine-item.yaml +20 -0
- package/agents/schema/document-structure.yaml +1 -1
- package/agents/translate/index.yaml +1 -4
- package/agents/translate/record-translation-history.mjs +6 -2
- package/agents/translate/translate-multilingual.yaml +1 -1
- package/agents/update/batch-generate-document.yaml +1 -1
- package/agents/update/batch-update-document.yaml +1 -1
- package/agents/update/check-document.mjs +35 -13
- package/agents/update/check-generate-diagram.mjs +26 -0
- package/agents/update/generate-diagram.yaml +29 -0
- package/agents/update/generate-document.yaml +17 -30
- package/agents/update/handle-document-update.yaml +10 -1
- package/agents/update/save-and-translate-document.mjs +18 -47
- package/agents/update/update-document-detail.yaml +2 -1
- package/agents/update/update-single-document.yaml +1 -1
- package/agents/update/user-review-document.mjs +6 -5
- package/agents/utils/choose-docs.mjs +2 -1
- package/agents/utils/load-sources.mjs +62 -45
- package/agents/utils/{save-docs.mjs → post-generate.mjs} +2 -51
- package/agents/utils/save-doc-translation.mjs +27 -0
- package/agents/utils/{save-single-doc.mjs → save-doc.mjs} +17 -12
- package/agents/utils/save-sidebar.mjs +59 -0
- package/agents/utils/{transform-detail-datasources.mjs → transform-detail-data-sources.mjs} +7 -7
- package/aigne.yaml +16 -8
- package/package.json +2 -1
- package/prompts/common/document/content-rules-core.md +6 -6
- package/prompts/common/document/media-file-list-usage-rules.md +12 -0
- package/prompts/common/document/openapi-usage-rules.md +36 -0
- package/prompts/common/document/role-and-personality.md +1 -2
- package/prompts/common/document-structure/conflict-resolution-guidance.md +2 -2
- package/prompts/common/document-structure/document-structure-rules.md +8 -8
- package/prompts/common/document-structure/output-constraints.md +3 -3
- package/prompts/detail/custom/custom-components.md +38 -3
- package/prompts/detail/d2-diagram/rules.md +11 -14
- package/prompts/detail/d2-diagram/system-prompt.md +0 -14
- package/prompts/detail/d2-diagram/user-prompt.md +39 -0
- package/prompts/detail/generate/document-rules.md +3 -3
- package/prompts/detail/generate/system-prompt.md +2 -6
- package/prompts/detail/generate/user-prompt.md +20 -61
- package/prompts/detail/update/system-prompt.md +2 -6
- package/prompts/detail/update/user-prompt.md +7 -6
- package/prompts/evaluate/document.md +0 -4
- package/prompts/structure/check-document-structure.md +4 -4
- package/prompts/structure/generate/system-prompt.md +0 -31
- package/prompts/structure/generate/user-prompt.md +68 -29
- package/prompts/structure/review/structure-review-system.md +79 -0
- package/prompts/structure/update/system-prompt.md +1 -1
- package/prompts/structure/update/user-prompt.md +4 -4
- package/prompts/translate/code-block.md +13 -3
- package/prompts/translate/translate-document.md +1 -1
- package/types/document-structure-schema.mjs +3 -3
- package/utils/docs-finder-utils.mjs +48 -0
- package/utils/extract-api.mjs +32 -0
- package/utils/file-utils.mjs +56 -101
- package/utils/history-utils.mjs +20 -8
- package/utils/load-config.mjs +1 -1
- package/utils/markdown-checker.mjs +35 -1
- package/utils/utils.mjs +67 -65
- package/agents/generate/document-structure-tools/generate-sub-structure.mjs +0 -131
- package/agents/generate/generate-structure-without-tools.yaml +0 -65
- package/prompts/common/document/media-handling-rules.md +0 -9
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { saveDocTranslation as _saveDocTranslation } from "../../utils/utils.mjs";
|
|
2
|
+
|
|
3
|
+
export default async function saveDocTranslation({
|
|
4
|
+
path,
|
|
5
|
+
docsDir,
|
|
6
|
+
translation,
|
|
7
|
+
language,
|
|
8
|
+
labels,
|
|
9
|
+
isShowMessage = false,
|
|
10
|
+
}) {
|
|
11
|
+
await _saveDocTranslation({
|
|
12
|
+
path,
|
|
13
|
+
docsDir,
|
|
14
|
+
language,
|
|
15
|
+
translation,
|
|
16
|
+
labels,
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
if (isShowMessage) {
|
|
20
|
+
const message = `✅ Translation completed successfully.`;
|
|
21
|
+
return { message };
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return {};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
saveDocTranslation.task_render_mode = "hide";
|
|
@@ -1,24 +1,22 @@
|
|
|
1
1
|
import { shutdownMermaidWorkerPool } from "../../utils/mermaid-worker-pool.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { saveDoc as _saveDoc } from "../../utils/utils.mjs";
|
|
3
3
|
|
|
4
|
-
export default async function
|
|
4
|
+
export default async function saveDoc({
|
|
5
5
|
path,
|
|
6
6
|
content,
|
|
7
7
|
docsDir,
|
|
8
|
-
translates,
|
|
9
8
|
labels,
|
|
10
9
|
locale,
|
|
11
|
-
|
|
10
|
+
feedback,
|
|
12
11
|
isShowMessage = false,
|
|
12
|
+
...rest
|
|
13
13
|
}) {
|
|
14
|
-
|
|
14
|
+
await _saveDoc({
|
|
15
15
|
path,
|
|
16
16
|
content,
|
|
17
17
|
docsDir,
|
|
18
|
-
translates,
|
|
19
18
|
labels,
|
|
20
19
|
locale,
|
|
21
|
-
isTranslate,
|
|
22
20
|
});
|
|
23
21
|
|
|
24
22
|
if (isShowMessage) {
|
|
@@ -29,13 +27,20 @@ export default async function saveSingleDoc({
|
|
|
29
27
|
console.warn("Failed to shutdown mermaid worker pool:", error.message);
|
|
30
28
|
}
|
|
31
29
|
|
|
32
|
-
const message =
|
|
33
|
-
? `✅ Translation completed successfully`
|
|
34
|
-
: `✅ Document updated successfully`;
|
|
30
|
+
const message = `✅ Document updated successfully.`;
|
|
35
31
|
return { message };
|
|
36
32
|
}
|
|
37
33
|
|
|
38
|
-
return {
|
|
34
|
+
return {
|
|
35
|
+
path,
|
|
36
|
+
content,
|
|
37
|
+
docsDir,
|
|
38
|
+
labels,
|
|
39
|
+
locale,
|
|
40
|
+
feedback,
|
|
41
|
+
isShowMessage,
|
|
42
|
+
...rest,
|
|
43
|
+
};
|
|
39
44
|
}
|
|
40
45
|
|
|
41
|
-
|
|
46
|
+
saveDoc.task_render_mode = "hide";
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { join } from "node:path";
|
|
2
|
+
import fs from "fs-extra";
|
|
3
|
+
|
|
4
|
+
export default async function saveSidebar({ documentStructure, docsDir }) {
|
|
5
|
+
// Generate _sidebar.md
|
|
6
|
+
try {
|
|
7
|
+
const sidebar = generateSidebar(documentStructure);
|
|
8
|
+
const sidebarPath = join(docsDir, "_sidebar.md");
|
|
9
|
+
|
|
10
|
+
await fs.ensureDir(docsDir);
|
|
11
|
+
await fs.writeFile(sidebarPath, sidebar, "utf8");
|
|
12
|
+
} catch (err) {
|
|
13
|
+
console.error("Failed to save _sidebar.md:", err.message);
|
|
14
|
+
}
|
|
15
|
+
return {};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Recursively generate sidebar text, the link path is the flattened file name
|
|
19
|
+
function walk(node, parentSegments = [], indent = "") {
|
|
20
|
+
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} `);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return out;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
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+$/, "");
|
|
59
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
|
+
import { isRemoteFile } from "../../utils/file-utils.mjs";
|
|
2
3
|
import { normalizePath, toRelativePath } from "../../utils/utils.mjs";
|
|
3
|
-
import { checkIsRemoteFile } from "../../utils/file-utils.mjs";
|
|
4
4
|
|
|
5
|
-
export default function
|
|
5
|
+
export default function transformDetailDataSource({ sourceIds }, options = {}) {
|
|
6
6
|
// Read file content for each sourceId, ignoring failures
|
|
7
7
|
let openAPISpec;
|
|
8
|
-
const
|
|
8
|
+
const remoteFileList = options?.context?.userContext?.remoteFileList || [];
|
|
9
9
|
const contents = (sourceIds || [])
|
|
10
10
|
.filter((id) => {
|
|
11
11
|
const openApiSourceId = options?.context?.userContext?.openAPISpec?.sourceId;
|
|
@@ -17,8 +17,8 @@ export default function transformDetailDatasources({ sourceIds }, options = {})
|
|
|
17
17
|
})
|
|
18
18
|
.map((id) => {
|
|
19
19
|
try {
|
|
20
|
-
if (
|
|
21
|
-
const findFile =
|
|
20
|
+
if (isRemoteFile(id)) {
|
|
21
|
+
const findFile = remoteFileList.find((f) => f.sourceId === id);
|
|
22
22
|
if (findFile) {
|
|
23
23
|
return `// sourceId: ${id}\n${findFile.content}\n`;
|
|
24
24
|
}
|
|
@@ -37,9 +37,9 @@ export default function transformDetailDatasources({ sourceIds }, options = {})
|
|
|
37
37
|
.filter(Boolean);
|
|
38
38
|
|
|
39
39
|
return {
|
|
40
|
-
|
|
40
|
+
detailDataSource: contents.join(""),
|
|
41
41
|
openAPISpec,
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
transformDetailDataSource.task_render_mode = "hide";
|
package/aigne.yaml
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env aigne
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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,14 +12,13 @@ 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
|
|
18
18
|
- ./agents/generate/check-document-structure.yaml
|
|
19
19
|
- ./agents/generate/user-review-document-structure.mjs
|
|
20
20
|
- ./agents/generate/index.yaml
|
|
21
|
-
|
|
21
|
+
|
|
22
22
|
# Documentation Structure Tools
|
|
23
23
|
- ./agents/generate/document-structure-tools/add-document.mjs
|
|
24
24
|
- ./agents/generate/document-structure-tools/delete-document.mjs
|
|
@@ -47,6 +47,7 @@ agents:
|
|
|
47
47
|
|
|
48
48
|
# Publishing
|
|
49
49
|
- ./agents/publish/publish-docs.mjs
|
|
50
|
+
- ./agents/publish/translate-meta.mjs
|
|
50
51
|
- ./agents/publish/index.yaml
|
|
51
52
|
|
|
52
53
|
# Media
|
|
@@ -65,9 +66,11 @@ agents:
|
|
|
65
66
|
|
|
66
67
|
# Utilities
|
|
67
68
|
- ./agents/utils/load-sources.mjs
|
|
68
|
-
- ./agents/utils/
|
|
69
|
-
- ./agents/utils/
|
|
70
|
-
- ./agents/utils/
|
|
69
|
+
- ./agents/utils/post-generate.mjs
|
|
70
|
+
- ./agents/utils/save-sidebar.mjs
|
|
71
|
+
- ./agents/utils/transform-detail-data-sources.mjs
|
|
72
|
+
- ./agents/utils/save-doc.mjs
|
|
73
|
+
- ./agents/utils/save-doc-translation.mjs
|
|
71
74
|
- ./agents/utils/save-output.mjs
|
|
72
75
|
- ./agents/utils/format-document-structure.mjs
|
|
73
76
|
- ./agents/utils/find-item-by-path.mjs
|
|
@@ -92,6 +95,11 @@ agents:
|
|
|
92
95
|
- ./agents/evaluate/document-structure.yaml
|
|
93
96
|
- ./agents/evaluate/document.yaml
|
|
94
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
|
|
95
103
|
cli:
|
|
96
104
|
chat: ./agents/chat/index.yaml
|
|
97
105
|
agents:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aigne/doc-smith",
|
|
3
|
-
"version": "0.8.15-beta.
|
|
3
|
+
"version": "0.8.15-beta.10",
|
|
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
|
|
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
|
|
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
|
|
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
|
|
19
|
-
- Do not include file paths from
|
|
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,12 @@
|
|
|
1
|
+
<media_file_list_usage_rules>
|
|
2
|
+
|
|
3
|
+
**Usage Workflow**
|
|
4
|
+
1. Read the `<media_file_list>` data and take note of each file's `path` and `description` as references.
|
|
5
|
+
2. Combine those descriptions with the current document's content to decide which images should be used and where they should be inserted.
|
|
6
|
+
3. Confirm that every inserted image path comes from `<media_file_list>`. If a path is missing from that list, replace it with one that is included.
|
|
7
|
+
|
|
8
|
+
**Usage Requirements**
|
|
9
|
+
- Insert images with Markdown syntax: ``.
|
|
10
|
+
- Never invent, reinterpret, fabricate, normalize, or rewrite any media file path under any circumstances.
|
|
11
|
+
|
|
12
|
+
</media_file_list_usage_rules>
|
|
@@ -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
|
-
|
|
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
|
|
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
|
-
|
|
5
|
-
1. When planning the structure, reasonably organize and display all information from
|
|
6
|
-
2. Users may provide limited
|
|
7
|
-
3. For information provided in user
|
|
8
|
-
4. If
|
|
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
|
|
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
|
|
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
|
|
4
|
-
- If
|
|
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>
|
|
@@ -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):
|
|
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
|
|
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
|
-
<
|
|
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
|
-
|
|
4
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
<
|
|
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
|
-
</
|
|
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 "
|
|
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
|
|
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
|
|