@aigne/doc-smith 0.6.0 → 0.7.1
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/.aigne/doc-smith/config.yaml +70 -0
- package/.aigne/doc-smith/output/structure-plan.json +152 -0
- package/.aigne/doc-smith/preferences.yml +31 -0
- package/.aigne/doc-smith/upload-cache.yaml +288 -0
- package/.github/workflows/ci.yml +46 -0
- package/.github/workflows/reviewer.yml +2 -1
- package/CHANGELOG.md +17 -0
- package/README.md +33 -15
- package/agents/chat.yaml +30 -0
- package/agents/check-structure-plan.mjs +1 -1
- package/agents/docs-fs.yaml +25 -0
- package/agents/exit.mjs +6 -0
- package/agents/feedback-refiner.yaml +5 -1
- package/agents/find-items-by-paths.mjs +10 -4
- package/agents/fs.mjs +60 -0
- package/agents/input-generator.mjs +150 -91
- package/agents/load-config.mjs +0 -5
- package/agents/load-sources.mjs +61 -8
- package/agents/publish-docs.mjs +27 -12
- package/agents/retranslate.yaml +1 -1
- package/agents/team-publish-docs.yaml +2 -2
- package/aigne.yaml +1 -0
- package/docs/_sidebar.md +17 -0
- package/docs/advanced-how-it-works.md +104 -0
- package/docs/advanced-how-it-works.zh.md +104 -0
- package/docs/advanced-quality-assurance.md +64 -0
- package/docs/advanced-quality-assurance.zh.md +64 -0
- package/docs/advanced.md +28 -0
- package/docs/advanced.zh.md +28 -0
- package/docs/changelog.md +272 -0
- package/docs/changelog.zh.md +272 -0
- package/docs/cli-reference.md +185 -0
- package/docs/cli-reference.zh.md +185 -0
- package/docs/configuration-interactive-setup.md +82 -0
- package/docs/configuration-interactive-setup.zh.md +82 -0
- package/docs/configuration-language-support.md +64 -0
- package/docs/configuration-language-support.zh.md +64 -0
- package/docs/configuration-llm-setup.md +90 -0
- package/docs/configuration-llm-setup.zh.md +90 -0
- package/docs/configuration-preferences.md +122 -0
- package/docs/configuration-preferences.zh.md +123 -0
- package/docs/configuration.md +173 -0
- package/docs/configuration.zh.md +173 -0
- package/docs/features-generate-documentation.md +82 -0
- package/docs/features-generate-documentation.zh.md +82 -0
- package/docs/features-publish-your-docs.md +98 -0
- package/docs/features-publish-your-docs.zh.md +98 -0
- package/docs/features-translate-documentation.md +83 -0
- package/docs/features-translate-documentation.zh.md +83 -0
- package/docs/features-update-and-refine.md +86 -0
- package/docs/features-update-and-refine.zh.md +86 -0
- package/docs/features.md +56 -0
- package/docs/features.zh.md +56 -0
- package/docs/getting-started.md +74 -0
- package/docs/getting-started.zh.md +74 -0
- package/docs/overview.md +48 -0
- package/docs/overview.zh.md +48 -0
- package/media.md +19 -0
- package/package.json +13 -10
- package/prompts/content-detail-generator.md +7 -3
- package/prompts/document/custom-components.md +80 -0
- package/prompts/document/d2-chart/diy-examples.md +44 -0
- package/prompts/document/d2-chart/official-examples.md +708 -0
- package/prompts/document/d2-chart/rules.md +48 -0
- package/prompts/document/detail-generator.md +12 -15
- package/prompts/document/structure-planning.md +1 -3
- package/prompts/feedback-refiner.md +81 -60
- package/prompts/structure-planning.md +20 -3
- package/tests/check-detail-result.test.mjs +3 -4
- package/tests/conflict-resolution.test.mjs +237 -0
- package/tests/input-generator.test.mjs +940 -0
- package/tests/load-sources.test.mjs +627 -3
- package/tests/preferences-utils.test.mjs +94 -0
- package/tests/save-value-to-config.test.mjs +182 -5
- package/tests/utils.test.mjs +49 -0
- package/utils/conflict-detector.mjs +72 -1
- package/utils/constants.mjs +125 -124
- package/utils/kroki-utils.mjs +162 -0
- package/utils/markdown-checker.mjs +98 -70
- package/utils/utils.mjs +96 -28
package/agents/load-sources.mjs
CHANGED
|
@@ -2,7 +2,11 @@ import { access, readFile, stat } from "node:fs/promises";
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { DEFAULT_EXCLUDE_PATTERNS, DEFAULT_INCLUDE_PATTERNS } from "../utils/constants.mjs";
|
|
4
4
|
import { getFilesWithGlob, loadGitignore } from "../utils/file-utils.mjs";
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
getCurrentGitHead,
|
|
7
|
+
getModifiedFilesBetweenCommits,
|
|
8
|
+
isGlobPattern,
|
|
9
|
+
} from "../utils/utils.mjs";
|
|
6
10
|
|
|
7
11
|
export default async function loadSources({
|
|
8
12
|
sources = [],
|
|
@@ -24,7 +28,12 @@ export default async function loadSources({
|
|
|
24
28
|
|
|
25
29
|
for (const dir of paths) {
|
|
26
30
|
try {
|
|
27
|
-
|
|
31
|
+
if (typeof dir !== "string") {
|
|
32
|
+
console.warn(`Invalid source path: ${dir}`);
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// First try to access as a file or directory
|
|
28
37
|
const stats = await stat(dir);
|
|
29
38
|
|
|
30
39
|
if (stats.isFile()) {
|
|
@@ -78,7 +87,31 @@ export default async function loadSources({
|
|
|
78
87
|
allFiles = allFiles.concat(filesInDir);
|
|
79
88
|
}
|
|
80
89
|
} catch (err) {
|
|
81
|
-
if (err.code
|
|
90
|
+
if (err.code === "ENOENT") {
|
|
91
|
+
// Path doesn't exist as file or directory, try as glob pattern
|
|
92
|
+
try {
|
|
93
|
+
// Check if it looks like a glob pattern
|
|
94
|
+
const isGlobPatternResult = isGlobPattern(dir);
|
|
95
|
+
|
|
96
|
+
if (isGlobPatternResult) {
|
|
97
|
+
// Use glob to find matching files from current working directory
|
|
98
|
+
const { glob } = await import("glob");
|
|
99
|
+
const matchedFiles = await glob(dir, {
|
|
100
|
+
absolute: true,
|
|
101
|
+
nodir: true, // Only files, not directories
|
|
102
|
+
dot: false, // Don't include hidden files
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
if (matchedFiles.length > 0) {
|
|
106
|
+
allFiles = allFiles.concat(matchedFiles);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
} catch (globErr) {
|
|
110
|
+
console.warn(`Failed to process glob pattern "${dir}": ${globErr.message}`);
|
|
111
|
+
}
|
|
112
|
+
} else {
|
|
113
|
+
throw err;
|
|
114
|
+
}
|
|
82
115
|
}
|
|
83
116
|
}
|
|
84
117
|
|
|
@@ -206,11 +239,31 @@ export default async function loadSources({
|
|
|
206
239
|
let assetsContent = "# Available Media Assets for Documentation\n\n";
|
|
207
240
|
|
|
208
241
|
if (mediaFiles.length > 0) {
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
.
|
|
212
|
-
|
|
213
|
-
|
|
242
|
+
// Helper function to determine file type from extension
|
|
243
|
+
const getFileType = (filePath) => {
|
|
244
|
+
const ext = path.extname(filePath).toLowerCase();
|
|
245
|
+
const imageExts = [".jpg", ".jpeg", ".png", ".gif", ".bmp", ".webp", ".svg"];
|
|
246
|
+
const videoExts = [".mp4", ".mov", ".avi", ".mkv", ".webm", ".m4v"];
|
|
247
|
+
|
|
248
|
+
if (imageExts.includes(ext)) return "image";
|
|
249
|
+
if (videoExts.includes(ext)) return "video";
|
|
250
|
+
return "media";
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
const mediaYaml = mediaFiles.map((file) => ({
|
|
254
|
+
name: file.name,
|
|
255
|
+
path: file.path,
|
|
256
|
+
type: getFileType(file.path),
|
|
257
|
+
}));
|
|
258
|
+
|
|
259
|
+
assetsContent += "```yaml\n";
|
|
260
|
+
assetsContent += "assets:\n";
|
|
261
|
+
mediaYaml.forEach((asset) => {
|
|
262
|
+
assetsContent += ` - name: "${asset.name}"\n`;
|
|
263
|
+
assetsContent += ` path: "${asset.path}"\n`;
|
|
264
|
+
assetsContent += ` type: "${asset.type}"\n`;
|
|
265
|
+
});
|
|
266
|
+
assetsContent += "```\n";
|
|
214
267
|
}
|
|
215
268
|
|
|
216
269
|
// Count words and lines in allSources
|
package/agents/publish-docs.mjs
CHANGED
|
@@ -1,16 +1,33 @@
|
|
|
1
1
|
import { basename, join } from "node:path";
|
|
2
2
|
import { publishDocs as publishDocsFn } from "@aigne/publish-docs";
|
|
3
3
|
import chalk from "chalk";
|
|
4
|
+
import fs from "fs-extra";
|
|
5
|
+
|
|
4
6
|
import { getAccessToken } from "../utils/auth-utils.mjs";
|
|
5
|
-
import { DISCUSS_KIT_STORE_URL } from "../utils/constants.mjs";
|
|
7
|
+
import { DISCUSS_KIT_STORE_URL, TMP_DIR, TMP_DOCS_DIR } from "../utils/constants.mjs";
|
|
8
|
+
import { beforePublishHook, ensureTmpDir } from "../utils/kroki-utils.mjs";
|
|
6
9
|
import { getGithubRepoUrl, loadConfigFromFile, saveValueToConfig } from "../utils/utils.mjs";
|
|
7
10
|
|
|
8
11
|
const DEFAULT_APP_URL = "https://docsmith.aigne.io";
|
|
9
12
|
|
|
10
13
|
export default async function publishDocs(
|
|
11
|
-
{ docsDir, appUrl, boardId, projectName, projectDesc, projectLogo },
|
|
14
|
+
{ docsDir: rawDocsDir, appUrl, boardId, projectName, projectDesc, projectLogo },
|
|
12
15
|
options,
|
|
13
16
|
) {
|
|
17
|
+
// move work dir to tmp-dir
|
|
18
|
+
await ensureTmpDir();
|
|
19
|
+
|
|
20
|
+
const docsDir = join(".aigne", "doc-smith", TMP_DIR, TMP_DOCS_DIR);
|
|
21
|
+
await fs.rm(docsDir, { recursive: true, force: true });
|
|
22
|
+
await fs.mkdir(docsDir, {
|
|
23
|
+
recursive: true,
|
|
24
|
+
});
|
|
25
|
+
await fs.cp(rawDocsDir, docsDir, { recursive: true });
|
|
26
|
+
|
|
27
|
+
// ----------------- trigger beforePublishHook -----------------------------
|
|
28
|
+
await beforePublishHook({ docsDir });
|
|
29
|
+
|
|
30
|
+
// ----------------- main publish process flow -----------------------------
|
|
14
31
|
// Check if DOC_DISCUSS_KIT_URL is set in environment variables
|
|
15
32
|
const envAppUrl = process.env.DOC_DISCUSS_KIT_URL;
|
|
16
33
|
const useEnvAppUrl = !!envAppUrl;
|
|
@@ -87,6 +104,8 @@ export default async function publishDocs(
|
|
|
87
104
|
].filter((lang, index, arr) => arr.indexOf(lang) === index), // Remove duplicates
|
|
88
105
|
};
|
|
89
106
|
|
|
107
|
+
let message;
|
|
108
|
+
|
|
90
109
|
try {
|
|
91
110
|
const { success, boardId: newBoardId } = await publishDocsFn({
|
|
92
111
|
sidebarPath,
|
|
@@ -98,7 +117,7 @@ export default async function publishDocs(
|
|
|
98
117
|
boardName: projectInfo.name,
|
|
99
118
|
boardDesc: projectInfo.description,
|
|
100
119
|
boardCover: projectInfo.icon,
|
|
101
|
-
mediaFolder:
|
|
120
|
+
mediaFolder: rawDocsDir,
|
|
102
121
|
cacheFilePath: join(".aigne", "doc-smith", "upload-cache.yaml"),
|
|
103
122
|
boardMeta,
|
|
104
123
|
});
|
|
@@ -114,18 +133,14 @@ export default async function publishDocs(
|
|
|
114
133
|
if (boardId !== newBoardId) {
|
|
115
134
|
await saveValueToConfig("boardId", newBoardId);
|
|
116
135
|
}
|
|
117
|
-
|
|
118
|
-
return {
|
|
119
|
-
message,
|
|
120
|
-
};
|
|
136
|
+
message = `✅ Documentation Published Successfully!`;
|
|
121
137
|
}
|
|
122
|
-
|
|
123
|
-
return {};
|
|
124
138
|
} catch (error) {
|
|
125
|
-
|
|
126
|
-
message: `❌ Failed to publish docs: ${error.message}`,
|
|
127
|
-
};
|
|
139
|
+
message = `❌ Failed to publish docs: ${error.message}`;
|
|
128
140
|
}
|
|
141
|
+
// clean up tmp work dir
|
|
142
|
+
await fs.rm(docsDir, { recursive: true, force: true });
|
|
143
|
+
return message ? { message } : {};
|
|
129
144
|
}
|
|
130
145
|
|
|
131
146
|
publishDocs.input_schema = {
|
package/agents/retranslate.yaml
CHANGED
|
@@ -58,7 +58,7 @@ input_schema:
|
|
|
58
58
|
type: array
|
|
59
59
|
items:
|
|
60
60
|
type: string
|
|
61
|
-
description: Languages to translate to
|
|
61
|
+
description: "Languages to translate to, available languages are: en, zh, zh-TW, ja, fr, de, es, it, ru, ko, pt, ar"
|
|
62
62
|
feedback:
|
|
63
63
|
type: string
|
|
64
64
|
description: Feedback for translation improvement
|
|
@@ -13,6 +13,6 @@ skills:
|
|
|
13
13
|
input_schema:
|
|
14
14
|
type: object
|
|
15
15
|
properties:
|
|
16
|
-
appUrl:
|
|
16
|
+
appUrl:
|
|
17
17
|
type: string
|
|
18
|
-
description: target website URL where the documentation will be published
|
|
18
|
+
description: target website URL where the documentation will be published (optional - if not provided, will prompt for interactive input)
|
package/aigne.yaml
CHANGED
package/docs/_sidebar.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
* [Overview](/overview.md)
|
|
2
|
+
* [Getting Started](/getting-started.md)
|
|
3
|
+
* [Core Features](/features.md)
|
|
4
|
+
* [Generate Documentation](/features-generate-documentation.md)
|
|
5
|
+
* [Update and Refine](/features-update-and-refine.md)
|
|
6
|
+
* [Translate Documentation](/features-translate-documentation.md)
|
|
7
|
+
* [Publish Your Docs](/features-publish-your-docs.md)
|
|
8
|
+
* [CLI Command Reference](/cli-reference.md)
|
|
9
|
+
* [Configuration Guide](/configuration.md)
|
|
10
|
+
* [LLM Setup](/configuration-llm-setup.md)
|
|
11
|
+
* [Language Support](/configuration-language-support.md)
|
|
12
|
+
* [Managing Preferences](/configuration-preferences.md)
|
|
13
|
+
* [Interactive Setup](/configuration-interactive-setup.md)
|
|
14
|
+
* [Advanced Topics](/advanced.md)
|
|
15
|
+
* [How It Works](/advanced-how-it-works.md)
|
|
16
|
+
* [Quality Assurance](/advanced-quality-assurance.md)
|
|
17
|
+
* [Changelog](/changelog.md)
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
---
|
|
2
|
+
labels: ["Reference"]
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# How It Works
|
|
6
|
+
|
|
7
|
+
AIGNE DocSmith provides a sophisticated, automated documentation solution by leveraging a multi-agent system built on the AIGNE Framework. Instead of relying on a single, monolithic AI, DocSmith orchestrates a pipeline of specialized AI agents, each an expert in its specific task. This collaborative approach ensures the generation of structured, detailed, and high-quality documentation directly from your source code.
|
|
8
|
+
|
|
9
|
+
## Architectural Overview
|
|
10
|
+
|
|
11
|
+
DocSmith is an integral part of the AIGNE ecosystem, a comprehensive platform for AI application development. It seamlessly integrates with other AIGNE components, utilizing the platform's core AI capabilities and infrastructure.
|
|
12
|
+
|
|
13
|
+

|
|
14
|
+
|
|
15
|
+
At its core, DocSmith operates as a pipeline, processing your source code through several distinct stages, each managed by one or more dedicated AI agents.
|
|
16
|
+
|
|
17
|
+
## The Documentation Generation Pipeline
|
|
18
|
+
|
|
19
|
+
The entire process, from analyzing your code to publishing the final documents, follows a structured pipeline. This ensures consistency and allows for targeted refinements at any stage.
|
|
20
|
+
|
|
21
|
+
```d2
|
|
22
|
+
direction: down
|
|
23
|
+
|
|
24
|
+
"Source Code & Config": {
|
|
25
|
+
shape: step
|
|
26
|
+
label: "Input: Source Code & Configuration"
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
"Structure Planning": {
|
|
30
|
+
shape: step
|
|
31
|
+
label: "1. Structure Planning"
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
"Content Generation": {
|
|
35
|
+
shape: step
|
|
36
|
+
label: "2. Content Generation"
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
"Saving & Output": {
|
|
40
|
+
shape: step
|
|
41
|
+
label: "3. Saving & Output"
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
"Optional Processes": {
|
|
45
|
+
shape: diamond
|
|
46
|
+
label: "4. Optional Processes"
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
"Translation": {
|
|
50
|
+
shape: step
|
|
51
|
+
label: "Translation"
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
"Publishing": {
|
|
55
|
+
shape: step
|
|
56
|
+
label: "Publishing"
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
"Feedback Loop": {
|
|
60
|
+
shape: callout
|
|
61
|
+
label: "User Feedback Loop"
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
"Source Code & Config" -> "Structure Planning"
|
|
65
|
+
"Structure Planning" -> "Content Generation"
|
|
66
|
+
"Content Generation" -> "Saving & Output"
|
|
67
|
+
"Saving & Output" -> "Optional Processes"
|
|
68
|
+
|
|
69
|
+
"Optional Processes" -> "Translation": "Translate Docs"
|
|
70
|
+
"Optional Processes" -> "Publishing": "Publish Docs"
|
|
71
|
+
|
|
72
|
+
"Structure Planning" <- "Feedback Loop": "Refine Structure"
|
|
73
|
+
"Content Generation" <- "Feedback Loop": "Regenerate Content"
|
|
74
|
+
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
1. **Input Analysis**: The process begins with agents like `load-sources` and `load-config`, which gather your source code, configuration files (`aigne.yaml`), and any user-defined rules.
|
|
78
|
+
|
|
79
|
+
2. **Structure Planning**: The `reflective-structure-planner` agent analyzes the codebase to propose a comprehensive and logical document structure. It considers your specified target audience, rules, and feedback to create an optimal outline.
|
|
80
|
+
|
|
81
|
+
3. **Content Generation**: Once the structure is approved, the `content-detail-generator` and `batch-docs-detail-generator` agents take over. They populate each section of the document plan with detailed, high-quality content, ensuring technical accuracy and adherence to the defined style.
|
|
82
|
+
|
|
83
|
+
4. **Refinement and Updates**: If you provide feedback using `aigne doc update` or `aigne doc generate --feedback`, the `detail-regenerator` and `feedback-refiner` agents are activated. They intelligently update specific documents or adjust the overall structure based on your input.
|
|
84
|
+
|
|
85
|
+
5. **Translation and Publishing**: Finally, optional agents like `translate` and `publish-docs` handle multi-language translation and publishing to Discuss Kit platforms, completing the end-to-end workflow.
|
|
86
|
+
|
|
87
|
+
## Key AI Agents
|
|
88
|
+
|
|
89
|
+
DocSmith's power comes from its team of specialized agents. While many agents work behind the scenes, here are some of the key players in the documentation pipeline:
|
|
90
|
+
|
|
91
|
+
| Agent Role | Primary Function | Governing File(s) |
|
|
92
|
+
|---|---|---|
|
|
93
|
+
| **Structure Planner** | Analyzes source code and rules to generate the overall documentation outline. | `structure-planning.yaml`, `reflective-structure-planner.yaml` |
|
|
94
|
+
| **Content Generator** | Writes detailed content for each individual document section based on the plan. | `content-detail-generator.yaml`, `batch-docs-detail-generator.yaml` |
|
|
95
|
+
| **Translation Agent** | Translates generated documentation into multiple target languages. | `translate.yaml`, `batch-translate.yaml` |
|
|
96
|
+
| **Refinement Agent** | Regenerates or modifies content and structure based on user feedback. | `detail-regenerator.yaml`, `feedback-refiner.yaml` |
|
|
97
|
+
| **Publishing Agent** | Manages the process of publishing documents to Discuss Kit instances. | `publish-docs.mjs`, `team-publish-docs.yaml` |
|
|
98
|
+
| **Configuration Loader** | Reads and interprets the project's configuration from `aigne.yaml`. | `load-config.mjs` |
|
|
99
|
+
|
|
100
|
+
This modular, agent-based architecture makes DocSmith highly flexible and robust, allowing each step of the process to be optimized independently.
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
Now that you understand the mechanics behind DocSmith, learn about the measures in place to guarantee high-quality output in the [Quality Assurance](./advanced-quality-assurance.md) section.
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
---
|
|
2
|
+
labels: ["Reference"]
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# 工作原理
|
|
6
|
+
|
|
7
|
+
AIGNE DocSmith 基于 AIGNE 框架构建的多 Agent 系统,提供了一套精密的自动化文档解决方案。 DocSmith 并非依赖单一、庞大的 AI,而是通过协调一系列专业的 AI Agent 组成的流水线,每个 Agent 都是其特定任务的专家。 这种协作方式确保了能够直接从您的源代码生成结构化、详细且高质量的文档。
|
|
8
|
+
|
|
9
|
+
## 架构概述
|
|
10
|
+
|
|
11
|
+
DocSmith 是 AIGNE 生态系统不可或缺的一部分,AIGNE 是一个用于 AI 应用开发的综合平台。 它与其他 AIGNE 组件无缝集成,利用平台的核心 AI 能力和基础设施。
|
|
12
|
+
|
|
13
|
+

|
|
14
|
+
|
|
15
|
+
DocSmith 的核心是一个处理流水线,它将您的源代码经过几个不同阶段的处理,每个阶段都由一个或多个专用的 AI Agent 管理。
|
|
16
|
+
|
|
17
|
+
## 文档生成流水线
|
|
18
|
+
|
|
19
|
+
从分析代码到发布最终文档的整个过程,都遵循一个结构化的流水线。 这确保了过程的一致性,并允许在任何阶段进行有针对性的优化。
|
|
20
|
+
|
|
21
|
+
```d2
|
|
22
|
+
direction: down
|
|
23
|
+
|
|
24
|
+
"Source Code & Config": {
|
|
25
|
+
shape: step
|
|
26
|
+
label: "输入:源代码与配置"
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
"Structure Planning": {
|
|
30
|
+
shape: step
|
|
31
|
+
label: "1. 结构规划"
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
"Content Generation": {
|
|
35
|
+
shape: step
|
|
36
|
+
label: "2. 内容生成"
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
"Saving & Output": {
|
|
40
|
+
shape: step
|
|
41
|
+
label: "3. 保存与输出"
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
"Optional Processes": {
|
|
45
|
+
shape: diamond
|
|
46
|
+
label: "4. 可选流程"
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
"Translation": {
|
|
50
|
+
shape: step
|
|
51
|
+
label: "翻译"
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
"Publishing": {
|
|
55
|
+
shape: step
|
|
56
|
+
label: "发布"
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
"Feedback Loop": {
|
|
60
|
+
shape: callout
|
|
61
|
+
label: "用户反馈循环"
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
"Source Code & Config" -> "Structure Planning"
|
|
65
|
+
"Structure Planning" -> "Content Generation"
|
|
66
|
+
"Content Generation" -> "Saving & Output"
|
|
67
|
+
"Saving & Output" -> "Optional Processes"
|
|
68
|
+
|
|
69
|
+
"Optional Processes" -> "Translation": "翻译文档"
|
|
70
|
+
"Optional Processes" -> "Publishing": "发布文档"
|
|
71
|
+
|
|
72
|
+
"Structure Planning" <- "Feedback Loop": "优化结构"
|
|
73
|
+
"Content Generation" <- "Feedback Loop": "重新生成内容"
|
|
74
|
+
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
1. **输入分析**:该过程始于 `load-sources` 和 `load-config` 等 Agent,它们负责收集您的源代码、配置文件(`aigne.yaml`)以及任何用户定义的规则。
|
|
78
|
+
|
|
79
|
+
2. **结构规划**:`reflective-structure-planner` Agent 会分析代码库,以提出一个全面且逻辑清晰的文档结构。它会考虑您指定的目标受众、规则和反馈,以创建最佳大纲。
|
|
80
|
+
|
|
81
|
+
3. **内容生成**:一旦结构获得批准,`content-detail-generator` 和 `batch-docs-detail-generator` Agent 就会接手。它们会用详细、高质量的内容填充文档计划的每个部分,确保技术准确性并遵循定义的风格。
|
|
82
|
+
|
|
83
|
+
4. **优化与更新**:如果您使用 `aigne doc update` 或 `aigne doc generate --feedback` 提供反馈,`detail-regenerator` 和 `feedback-refiner` Agent 将被激活。它们会根据您的输入智能地更新特定文档或调整整体结构。
|
|
84
|
+
|
|
85
|
+
5. **翻译与发布**:最后,像 `translate` 和 `publish-docs` 这样的可选 Agent 会处理多语言翻译和发布到 Discuss Kit 平台的工作,从而完成端到端的工作流。
|
|
86
|
+
|
|
87
|
+
## 关键 AI Agent
|
|
88
|
+
|
|
89
|
+
DocSmith 的强大之处在于其专业的 Agent 团队。虽然许多 Agent 在幕后工作,但以下是文档生成流水线中的一些关键角色:
|
|
90
|
+
|
|
91
|
+
| Agent 角色 | 主要功能 | 相关文件 |
|
|
92
|
+
|---|---|---|
|
|
93
|
+
| **结构规划器** | 分析源代码和规则,以生成整体的文档大纲。 | `structure-planning.yaml`, `reflective-structure-planner.yaml` |
|
|
94
|
+
| **内容生成器** | 根据计划为每个文档部分撰写详细内容。 | `content-detail-generator.yaml`, `batch-docs-detail-generator.yaml` |
|
|
95
|
+
| **Translation Agent** | 将生成的文档翻译成多种目标语言。 | `translate.yaml`, `batch-translate.yaml` |
|
|
96
|
+
| **Refinement Agent** | 根据用户反馈重新生成或修改内容和结构。 | `detail-regenerator.yaml`, `feedback-refiner.yaml` |
|
|
97
|
+
| **Publishing Agent** | 管理将文档发布到 Discuss Kit 实例的过程。 | `publish-docs.mjs`, `team-publish-docs.yaml` |
|
|
98
|
+
| **配置加载器** | 从 `aigne.yaml` 读取并解释项目的配置。 | `load-config.mjs` |
|
|
99
|
+
|
|
100
|
+
这种模块化的、基于 Agent 的架构使 DocSmith 变得高度灵活和健壮,允许流程的每一步都可以独立优化。
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
现在您已经了解了 DocSmith 背后的工作机制,接下来请在 [质量保证](./advanced-quality-assurance.md) 部分了解为确保高质量输出而采取的措施。
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
---
|
|
2
|
+
labels: ["Reference"]
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Quality Assurance
|
|
6
|
+
|
|
7
|
+
To ensure your documentation is consistently high-quality, DocSmith includes a powerful automated quality assurance pipeline. These built-in checks run automatically during the generation and update processes to detect and report common issues—from broken links to formatting errors—before they reach your readers.
|
|
8
|
+
|
|
9
|
+
The process validates multiple aspects of your content to maintain structural integrity and accuracy.
|
|
10
|
+
|
|
11
|
+
```d2
|
|
12
|
+
direction: right
|
|
13
|
+
|
|
14
|
+
Input: "Markdown Content"
|
|
15
|
+
|
|
16
|
+
QA_Pipeline: "DocSmith QA Pipeline" {
|
|
17
|
+
shape: package
|
|
18
|
+
|
|
19
|
+
Checks: {
|
|
20
|
+
grid-columns: 2
|
|
21
|
+
"Structural Integrity": "Incomplete code blocks & inconsistent indentation"
|
|
22
|
+
"Link & Asset Health": "Dead links & missing local images"
|
|
23
|
+
"Diagram Validation": "D2 syntax checks"
|
|
24
|
+
"Markdown Linting": "Table formatting & standard rules"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
Output: "Validated Documentation"
|
|
29
|
+
|
|
30
|
+
Input -> QA_Pipeline: "Analyzed"
|
|
31
|
+
QA_Pipeline -> Output: "Generated"
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Content and Structural Integrity
|
|
35
|
+
|
|
36
|
+
DocSmith analyzes the fundamental structure of your markdown files to catch issues that often lead to rendering failures or confusing output.
|
|
37
|
+
|
|
38
|
+
- **Incomplete Code Blocks**: The validator ensures that every code block opened with ` ``` ` is properly closed. Unclosed blocks can cause large portions of a document to render incorrectly.
|
|
39
|
+
- **Inconsistent Indentation**: Code blocks with inconsistent indentation are flagged. This is particularly important for code samples where indentation is syntactically significant and for preventing unexpected rendering issues.
|
|
40
|
+
- **Content Completeness**: The system checks if the content appears to be truncated by verifying that it ends with appropriate punctuation (e.g., `.`, `)`, `|`). This helps catch incomplete generation results.
|
|
41
|
+
|
|
42
|
+
### Link and Asset Validation
|
|
43
|
+
|
|
44
|
+
Broken links and missing images can degrade the user experience. DocSmith validates these resources automatically to ensure they are always available to the reader.
|
|
45
|
+
|
|
46
|
+
- **Dead Link Checking**: All internal links are cross-referenced against the paths defined in your project's structure plan. Any link pointing to a non-existent page is reported as a dead link.
|
|
47
|
+
- **Local Image Verification**: For local images (i.e., those not hosted on an external server), the system checks that the referenced image file exists at the specified relative or absolute path.
|
|
48
|
+
|
|
49
|
+
### Diagram Validation
|
|
50
|
+
|
|
51
|
+
To ensure that all diagrams render correctly, DocSmith specifically validates the syntax of D2 code blocks. Before processing, the D2 content is checked for syntactical correctness. If an error is found, it is flagged to prevent a broken diagram from being published.
|
|
52
|
+
|
|
53
|
+
### Markdown Formatting and Linting
|
|
54
|
+
|
|
55
|
+
Beyond major structural issues, DocSmith lints the markdown for formatting consistency and correctness, leveraging established standards to enforce a clean and readable style. Key checks include:
|
|
56
|
+
|
|
57
|
+
| Check Category | Description |
|
|
58
|
+
|---|---|
|
|
59
|
+
| **Table Formatting** | Verifies that the number of columns in a table's header, separator line, and data rows are consistent. Mismatched column counts are a common cause of broken tables. |
|
|
60
|
+
| **Heading Issues** | Detects duplicate headings within the same document or headings that use improper indentation, which can break the document outline. |
|
|
61
|
+
| **Reference Validation** | Checks for undefined references, such as using a link reference `[text][ref]` without defining `[ref]: url` elsewhere. |
|
|
62
|
+
| **Code Block Style** | Ensures consistent usage of code block markers for better readability and parsing. |
|
|
63
|
+
|
|
64
|
+
This automated quality assurance layer is a core part of DocSmith's architecture, designed to minimize manual review and ensure that your documentation is always accurate, professional, and reliable. To learn more about the overall generation process, see [How It Works](./advanced-how-it-works.md).
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
---
|
|
2
|
+
labels: ["Reference"]
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# 质量保证
|
|
6
|
+
|
|
7
|
+
为确保您的文档始终保持高质量,DocSmith 内置了一个强大的自动化质量保证流程。这些内置检查在生成和更新过程中自动运行,以检测并报告常见问题(从链接失效到格式错误),从而在问题影响到读者之前予以解决。
|
|
8
|
+
|
|
9
|
+
该流程会验证您内容的多个方面,以保持结构的完整性和准确性。
|
|
10
|
+
|
|
11
|
+
```d2
|
|
12
|
+
direction: right
|
|
13
|
+
|
|
14
|
+
Input: "Markdown 内容"
|
|
15
|
+
|
|
16
|
+
QA_Pipeline: "DocSmith QA 流程" {
|
|
17
|
+
shape: package
|
|
18
|
+
|
|
19
|
+
Checks: {
|
|
20
|
+
grid-columns: 2
|
|
21
|
+
"结构完整性": "代码块不完整和缩进不一致"
|
|
22
|
+
"链接和资源健康状况": "失效链接和本地图片缺失"
|
|
23
|
+
"图表验证": "D2 语法检查"
|
|
24
|
+
"Markdown 语法检查": "表格格式和标准规则"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
Output: "经验证的文档"
|
|
29
|
+
|
|
30
|
+
Input -> QA_Pipeline: "分析"
|
|
31
|
+
QA_Pipeline -> Output: "生成"
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### 内容和结构完整性
|
|
35
|
+
|
|
36
|
+
DocSmith 会分析 Markdown 文件的基本结构,以捕获那些经常导致渲染失败或输出混乱的问题。
|
|
37
|
+
|
|
38
|
+
- **代码块不完整**:验证器会确保每个以 ` ``` ` 开始的代码块都已正确关闭。未关闭的代码块可能导致文档的大部分内容无法正确渲染。
|
|
39
|
+
- **缩进不一致**:系统会标记出缩进不一致的代码块。这对于缩进具有语法意义的代码示例以及防止意外的渲染问题尤为重要。
|
|
40
|
+
- **内容完整性**:系统通过验证内容是否以适当的标点符号(例如 `.`、`)`、`|`)结尾,来检查内容是否被截断。这有助于捕获不完整的生成结果。
|
|
41
|
+
|
|
42
|
+
### 链接和资源验证
|
|
43
|
+
|
|
44
|
+
失效链接和缺失图片会降低用户体验。DocSmith 会自动验证这些资源,以确保读者始终可以访问它们。
|
|
45
|
+
|
|
46
|
+
- **失效链接检查**:所有内部链接都会与您项目结构计划中定义的路径进行交叉引用。任何指向不存在页面的链接都将被报告为失效链接。
|
|
47
|
+
- **本地图片验证**:对于本地图片(即未托管在外部服务器上的图片),系统会检查引用的图片文件是否存在于指定的相对或绝对路径中。
|
|
48
|
+
|
|
49
|
+
### 图表验证
|
|
50
|
+
|
|
51
|
+
为确保所有图表都能正确渲染,DocSmith 会专门验证 D2 代码块的语法。在处理之前,系统会检查 D2 内容的语法正确性。如果发现错误,系统会进行标记,以防止发布损坏的图表。
|
|
52
|
+
|
|
53
|
+
### Markdown 格式化与语法检查
|
|
54
|
+
|
|
55
|
+
除了主要的结构性问题,DocSmith 还会对 Markdown 进行语法检查,以确保格式的一致性和正确性,并利用既定标准来强制执行清晰易读的风格。关键检查包括:
|
|
56
|
+
|
|
57
|
+
| 检查类别 | 描述 |
|
|
58
|
+
|---|---|
|
|
59
|
+
| **表格格式化** | 验证表格的表头、分隔线和数据行中的列数是否一致。列数不匹配是导致表格损坏的常见原因。 |
|
|
60
|
+
| **标题问题** | 检测同一文档中的重复标题或使用不当缩进的标题,这些问题可能会破坏文档大纲。 |
|
|
61
|
+
| **引用验证** | 检查未定义的引用,例如使用了链接引用 `[text][ref]`,但未在其他地方定义 `[ref]: url`。 |
|
|
62
|
+
| **代码块样式** | 确保一致地使用代码块标记,以提高可读性和解析效率。 |
|
|
63
|
+
|
|
64
|
+
这个自动化的质量保证层是 DocSmith 架构的核心部分,旨在最大限度地减少人工审查,并确保您的文档始终准确、专业且可靠。要了解有关整体生成流程的更多信息,请参阅[工作原理](./advanced-how-it-works.md)。
|
package/docs/advanced.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
---
|
|
2
|
+
labels: ["Reference"]
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Advanced Topics
|
|
6
|
+
|
|
7
|
+
For those who wish to look under the hood, this section provides a deeper dive into the architecture of AIGNE DocSmith. Here, you'll learn how the tool functions, its place within the AIGNE ecosystem, and the internal mechanisms it uses to generate high-quality documentation.
|
|
8
|
+
|
|
9
|
+
While a deep understanding of these topics isn't necessary for general use, it can be valuable for customizing behavior, troubleshooting issues, or contributing to the project.
|
|
10
|
+
|
|
11
|
+
## The AIGNE Ecosystem
|
|
12
|
+
|
|
13
|
+
AIGNE DocSmith is not a standalone tool; it is a key component of the [AIGNE Framework](https://www.aigne.io/en/framework), a comprehensive platform for AI application development. This integration allows DocSmith to leverage the platform's advanced AI capabilities and robust infrastructure. The following diagram illustrates how DocSmith fits into the broader ecosystem.
|
|
14
|
+
|
|
15
|
+

|
|
16
|
+
|
|
17
|
+
To better understand the internal processes and quality controls, explore the following sections.
|
|
18
|
+
|
|
19
|
+
<x-cards data-columns="2">
|
|
20
|
+
<x-card data-title="How It Works" data-href="/advanced/how-it-works" data-icon="lucide:cpu">
|
|
21
|
+
An architectural overview of DocSmith, explaining the role of AI agents in the documentation generation pipeline.
|
|
22
|
+
</x-card>
|
|
23
|
+
<x-card data-title="Quality Assurance" data-href="/advanced/quality-assurance" data-icon="lucide:shield-check">
|
|
24
|
+
Understand the built-in checks DocSmith performs to ensure high-quality, well-formatted, and error-free documentation.
|
|
25
|
+
</x-card>
|
|
26
|
+
</x-cards>
|
|
27
|
+
|
|
28
|
+
By exploring these topics, you can gain a more complete understanding of DocSmith's capabilities. For a detailed breakdown of all available commands and their options, proceed to the [CLI Command Reference](./cli-reference.md).
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
---
|
|
2
|
+
labels: ["Reference"]
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# 高级主题
|
|
6
|
+
|
|
7
|
+
对于希望深入了解其内部机制的用户,本节将深入解析 AIGNE DocSmith 的架构。在这里,你将了解到该工具的运作方式、其在 AIGNE 生态系统中的定位,以及它用于生成高质量文档的内部机制。
|
|
8
|
+
|
|
9
|
+
虽然深入理解这些主题对于一般使用并非必要,但它对于自定义行为、排查问题或为项目做出贡献非常有价值。
|
|
10
|
+
|
|
11
|
+
## AIGNE 生态系统
|
|
12
|
+
|
|
13
|
+
AIGNE DocSmith 并非一个独立的工具,而是 [AIGNE 框架](https://www.aigne.io/en/framework) 的关键组件,该框架是一个用于 AI 应用开发的综合平台。这种集成使 DocSmith 能够利用该平台的先进 AI 功能和强大的基础设施。下图展示了 DocSmith 如何融入更广泛的生态系统。
|
|
14
|
+
|
|
15
|
+

|
|
16
|
+
|
|
17
|
+
要更好地了解其内部流程和质量控制,请浏览以下章节。
|
|
18
|
+
|
|
19
|
+
<x-cards data-columns="2">
|
|
20
|
+
<x-card data-title="工作原理" data-href="/advanced/how-it-works" data-icon="lucide:cpu">
|
|
21
|
+
DocSmith 的架构概览,解释了 AI Agent 在文档生成流程中的作用。
|
|
22
|
+
</x-card>
|
|
23
|
+
<x-card data-title="质量保证" data-href="/advanced/quality-assurance" data-icon="lucide:shield-check">
|
|
24
|
+
了解 DocSmith 为确保文档高质量、格式良好且无错误而执行的内置检查。
|
|
25
|
+
</x-card>
|
|
26
|
+
</x-cards>
|
|
27
|
+
|
|
28
|
+
通过探索这些主题,你可以更全面地了解 DocSmith 的功能。要获取所有可用命令及其选项的详细说明,请参阅 [CLI 命令参考](./cli-reference.md)。
|