@aigne/doc-smith 0.9.7 → 0.9.8-alpha.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/CHANGELOG.md +20 -0
- package/agentic-agents/common/base-info.md +50 -0
- package/agentic-agents/common/planner.md +115 -0
- package/agentic-agents/common/worker.md +51 -0
- package/agentic-agents/create/index.yaml +79 -0
- package/agentic-agents/create/objective.md +44 -0
- package/agentic-agents/create/set-custom-prompt.mjs +43 -0
- package/agentic-agents/detail/index.yaml +82 -0
- package/agentic-agents/detail/objective.md +9 -0
- package/agentic-agents/detail/set-custom-prompt.mjs +88 -0
- package/agentic-agents/structure/design-rules.md +39 -0
- package/agentic-agents/structure/index.yaml +63 -0
- package/agentic-agents/structure/objective.md +14 -0
- package/agentic-agents/structure/review-criteria.md +55 -0
- package/agentic-agents/structure/set-custom-prompt.mjs +78 -0
- package/agentic-agents/utils/load-base-sources.mjs +96 -0
- package/agents/create/analyze-diagram-type-llm.yaml +160 -0
- package/agents/create/analyze-diagram-type.mjs +297 -0
- package/agents/create/check-need-generate-structure.mjs +1 -34
- package/agents/create/generate-diagram-image.yaml +60 -0
- package/agents/create/index.yaml +9 -5
- package/agents/create/replace-d2-with-image.mjs +625 -0
- package/agents/create/user-review-document-structure.mjs +8 -7
- package/agents/create/utils/init-current-content.mjs +5 -9
- package/agents/evaluate/document.yaml +6 -0
- package/agents/evaluate/index.yaml +1 -0
- package/agents/init/index.mjs +36 -388
- package/agents/localize/index.yaml +4 -4
- package/agents/media/batch-generate-media-description.yaml +2 -0
- package/agents/media/generate-media-description.yaml +3 -0
- package/agents/media/load-media-description.mjs +44 -15
- package/agents/publish/index.yaml +1 -0
- package/agents/publish/publish-docs.mjs +1 -4
- package/agents/update/check-diagram-flag.mjs +116 -0
- package/agents/update/check-document.mjs +0 -1
- package/agents/update/check-generate-diagram.mjs +48 -30
- package/agents/update/check-sync-image-flag.mjs +55 -0
- package/agents/update/check-update-is-single.mjs +11 -0
- package/agents/update/generate-diagram.yaml +43 -9
- package/agents/update/generate-document.yaml +9 -0
- package/agents/update/handle-document-update.yaml +10 -8
- package/agents/update/index.yaml +25 -7
- package/agents/update/sync-images-and-exit.mjs +148 -0
- package/agents/update/update-single/update-single-document-detail.mjs +131 -17
- package/agents/utils/analyze-feedback-intent.mjs +136 -0
- package/agents/utils/choose-docs.mjs +185 -40
- package/agents/utils/generate-document-or-skip.mjs +41 -0
- package/agents/utils/handle-diagram-operations.mjs +263 -0
- package/agents/utils/load-all-document-content.mjs +30 -0
- package/agents/utils/load-sources.mjs +2 -2
- package/agents/utils/post-generate.mjs +14 -3
- package/agents/utils/read-current-document-content.mjs +46 -0
- package/agents/utils/save-doc-translation.mjs +34 -0
- package/agents/utils/save-doc.mjs +42 -0
- package/agents/utils/save-sidebar.mjs +19 -6
- package/agents/utils/skip-if-content-exists.mjs +27 -0
- package/aigne.yaml +15 -3
- package/assets/report-template/report.html +17 -17
- package/docs-mcp/read-doc-content.mjs +30 -1
- package/package.json +9 -7
- package/prompts/detail/diagram/generate-image-system.md +135 -0
- package/prompts/detail/diagram/generate-image-user.md +32 -0
- package/prompts/detail/generate/user-prompt.md +27 -13
- package/prompts/evaluate/document.md +23 -10
- package/prompts/media/media-description/system-prompt.md +10 -2
- package/prompts/media/media-description/user-prompt.md +9 -0
- package/utils/check-document-has-diagram.mjs +95 -0
- package/utils/constants/index.mjs +46 -0
- package/utils/d2-utils.mjs +119 -178
- package/utils/delete-diagram-images.mjs +99 -0
- package/utils/docs-finder-utils.mjs +133 -25
- package/utils/image-compress.mjs +75 -0
- package/utils/kroki-utils.mjs +2 -3
- package/utils/load-config.mjs +29 -0
- package/utils/sync-diagram-to-translations.mjs +262 -0
- package/utils/utils.mjs +24 -0
- package/agents/create/check-diagram.mjs +0 -40
- package/agents/create/draw-diagram.yaml +0 -27
- package/agents/create/merge-diagram.yaml +0 -39
- package/agents/create/wrap-diagram-code.mjs +0 -35
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
type: team
|
|
2
|
+
name: GenerateStructure
|
|
3
|
+
# model: anthropic/claude-opus-4-5-20251101
|
|
4
|
+
description: Generate the structure of your documentation
|
|
5
|
+
input_schema:
|
|
6
|
+
type: object
|
|
7
|
+
properties:
|
|
8
|
+
rules:
|
|
9
|
+
type: string
|
|
10
|
+
description: Your specific requirements for documentation structure
|
|
11
|
+
locale:
|
|
12
|
+
type: string
|
|
13
|
+
description: Primary language for documentation (e.g., zh, en, ja)
|
|
14
|
+
task:
|
|
15
|
+
type: string
|
|
16
|
+
description: Task related to this documentation structure
|
|
17
|
+
skills:
|
|
18
|
+
- ../utils/load-base-sources.mjs
|
|
19
|
+
- ./set-custom-prompt.mjs
|
|
20
|
+
- type: "@aigne/agent-library/orchestrator"
|
|
21
|
+
objective:
|
|
22
|
+
url: objective.md
|
|
23
|
+
planner:
|
|
24
|
+
type: ai
|
|
25
|
+
model: anthropic/claude-opus-4-5-20251101
|
|
26
|
+
instructions:
|
|
27
|
+
url: ../common/planner.md
|
|
28
|
+
input_schema:
|
|
29
|
+
type: object
|
|
30
|
+
properties:
|
|
31
|
+
plannerInitState:
|
|
32
|
+
type: string
|
|
33
|
+
description: The initial state of the planner
|
|
34
|
+
customPlannerPrompt:
|
|
35
|
+
type: string
|
|
36
|
+
description: The custom planner prompt
|
|
37
|
+
worker:
|
|
38
|
+
type: ai
|
|
39
|
+
instructions:
|
|
40
|
+
url: ../common/worker.md
|
|
41
|
+
input_schema:
|
|
42
|
+
type: object
|
|
43
|
+
properties:
|
|
44
|
+
domainKnowledge:
|
|
45
|
+
type: string
|
|
46
|
+
description: The domain knowledge
|
|
47
|
+
completer:
|
|
48
|
+
type: function
|
|
49
|
+
process: |
|
|
50
|
+
let message = 'All tasks have been completed.';
|
|
51
|
+
return { message };
|
|
52
|
+
afs:
|
|
53
|
+
modules:
|
|
54
|
+
- module: local-fs
|
|
55
|
+
options:
|
|
56
|
+
name: workspace
|
|
57
|
+
localPath: .
|
|
58
|
+
description: The target repository containing source code and documentation. Read-only, cannot be modified.
|
|
59
|
+
- module: local-fs
|
|
60
|
+
options:
|
|
61
|
+
name: doc-smith
|
|
62
|
+
localPath: .aigne/doc-smith
|
|
63
|
+
description: The Doc Smith workspace for storing intermediate and output files
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
|
|
2
|
+
1. **YAML Format Correctness** - Automatic rejection if:
|
|
3
|
+
- Indentation is not exactly 2 spaces per level
|
|
4
|
+
- Missing spaces after colons (e.g., `title:"value"` instead of `title: "value"`)
|
|
5
|
+
- List items don't start with `- ` (dash + space)
|
|
6
|
+
- Special characters are not properly quoted
|
|
7
|
+
- Any YAML syntax errors that would cause parsing to fail
|
|
8
|
+
|
|
9
|
+
2. **Valid sourcePaths** - Automatic rejection if:
|
|
10
|
+
- ANY `sourcePaths` entry contains a directory path (e.g., `src/`, `docs/`)
|
|
11
|
+
- ANY `sourcePaths` entry includes the `/modules/workspace` prefix
|
|
12
|
+
- ANY `sourcePaths` entry uses absolute paths
|
|
13
|
+
- ✅ Valid examples: `README.md`, `src/index.ts`, `docs/api.md`
|
|
14
|
+
- ❌ Invalid examples: `src/`, `/modules/workspace/README.md`, `/absolute/path/file.ts`
|
|
15
|
+
|
|
16
|
+
3. **Project Domain Focus** - Automatic rejection if:
|
|
17
|
+
- Structure includes build/tooling documentation for non-build-tool projects (e.g., "Webpack Configuration", "CI/CD Pipeline", "ESLint Rules")
|
|
18
|
+
- Documentation focuses on internal development infrastructure instead of project features
|
|
19
|
+
- ✅ Approve: Project features, APIs, architecture, usage guides, domain concepts
|
|
20
|
+
- ❌ Reject: Build configs, CI/CD, linting setup (unless the project IS a build tool)
|
|
21
|
+
|
|
22
|
+
## Quality Assessment Checks
|
|
23
|
+
|
|
24
|
+
4. **Adequate Coverage and Depth**
|
|
25
|
+
- Reject if structure is too minimal (only 1-2 sections for non-trivial projects)
|
|
26
|
+
- Reject if missing obvious sections (e.g., no API docs for a library, no getting-started guide)
|
|
27
|
+
- Approve if structure has appropriate breadth and depth
|
|
28
|
+
|
|
29
|
+
5. **Project Priorities Alignment**
|
|
30
|
+
- Reject if structure ignores key features emphasized in README/documentation
|
|
31
|
+
- Approve if key features from README have dedicated sections
|
|
32
|
+
|
|
33
|
+
6. **Multi-Package/Monorepo Structure** (if applicable)
|
|
34
|
+
- Reject if ANY package section lacks nested children subsections
|
|
35
|
+
- Approve if each package has its own section with children organizing package-specific docs
|
|
36
|
+
|
|
37
|
+
7. **No Duplicate Sections**
|
|
38
|
+
- Reject if multiple sections have the same purpose without clear differentiation
|
|
39
|
+
|
|
40
|
+
8. **Clear Section Purposes**
|
|
41
|
+
- Reject if section titles are vague (e.g., "Other", "Misc", "Files")
|
|
42
|
+
|
|
43
|
+
## Review Decision Making
|
|
44
|
+
|
|
45
|
+
**If user feedback exists**:
|
|
46
|
+
- ONLY verify that structure changes address the user's specific feedback
|
|
47
|
+
- Ignore all standard quality criteria
|
|
48
|
+
- Approve if user's requirements are met, even if other issues exist
|
|
49
|
+
|
|
50
|
+
**If no user feedback**:
|
|
51
|
+
- Apply all quality criteria strictly
|
|
52
|
+
- Reject if any critical validation fails
|
|
53
|
+
- Reject if multiple quality issues exist
|
|
54
|
+
|
|
55
|
+
**If rejected**: Loop back to design phase and regenerate based on review feedback
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
|
|
5
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
6
|
+
const __dirname = path.dirname(__filename);
|
|
7
|
+
|
|
8
|
+
// FIXME: 临时使用这种方式设置自定义变量,框架优化后需要修改
|
|
9
|
+
export default function getCustomPrompt({ structureContent }) {
|
|
10
|
+
let finalStructureContent = "文档结构未生成";
|
|
11
|
+
if (structureContent) {
|
|
12
|
+
finalStructureContent = `
|
|
13
|
+
\`\`\`yaml\n${structureContent}\n\`\`\`
|
|
14
|
+
`;
|
|
15
|
+
}
|
|
16
|
+
const plannerInitState = `
|
|
17
|
+
文档结构(/modules/doc-smith/output/document_structure.yaml):
|
|
18
|
+
${finalStructureContent}
|
|
19
|
+
`;
|
|
20
|
+
|
|
21
|
+
const customPlannerPrompt = `
|
|
22
|
+
- 文档结构生成之后,需要按照'质量审查标准',进行质量审查,并修复发现的问题
|
|
23
|
+
- 关键: 在保存 YAML 文件之前,严格验证格式:
|
|
24
|
+
|
|
25
|
+
✅ **正确格式示例:**
|
|
26
|
+
\`\`\`yaml
|
|
27
|
+
project:
|
|
28
|
+
title: "我的项目"
|
|
29
|
+
description: "项目的简要描述"
|
|
30
|
+
|
|
31
|
+
documents:
|
|
32
|
+
- title: "概览"
|
|
33
|
+
description: "项目介绍"
|
|
34
|
+
path: /overview.md
|
|
35
|
+
sourcePaths:
|
|
36
|
+
- README.md
|
|
37
|
+
- docs/intro.md
|
|
38
|
+
children: []
|
|
39
|
+
- title: "API 参考"
|
|
40
|
+
description: "完整的 API 文档"
|
|
41
|
+
path: /api-Reference.md
|
|
42
|
+
sourcePaths:
|
|
43
|
+
- docs/api.md
|
|
44
|
+
children:
|
|
45
|
+
- title: "核心 API"
|
|
46
|
+
path: /core-api.md
|
|
47
|
+
description: "核心功能"
|
|
48
|
+
sourcePaths:
|
|
49
|
+
- docs/api/core.md
|
|
50
|
+
children: []
|
|
51
|
+
\`\`\`
|
|
52
|
+
|
|
53
|
+
❌ **要避免的常见错误:**
|
|
54
|
+
1. 冒号后缺少空格: \`title:"测试"\` (错误) → \`title: "测试"\` (正确)
|
|
55
|
+
2. 错误的缩进: 每级必须恰好 2 个空格
|
|
56
|
+
3. 列表项缺少破折号: \`documents: title: "测试"\` (错误) → \`documents: - title: "测试"\` (正确)
|
|
57
|
+
4. sourcePaths 中的目录路径: \`sourcePaths: - src/\` (错误) → \`sourcePaths: - src/index.ts\` (正确)
|
|
58
|
+
5. 包含模块前缀: \`/modules/workspace/README.md\` (错误) → \`README.md\` (正确)
|
|
59
|
+
|
|
60
|
+
`;
|
|
61
|
+
|
|
62
|
+
const baseInfoPath = path.join(__dirname, "../common/base-info.md");
|
|
63
|
+
const baseInfo = fs.readFileSync(baseInfoPath, "utf-8");
|
|
64
|
+
|
|
65
|
+
const domainKnowledge = `
|
|
66
|
+
${baseInfo}
|
|
67
|
+
|
|
68
|
+
### 使用用文档相关的 Skill 完成任务
|
|
69
|
+
文档结构相关的任务使用:GenerateStructure
|
|
70
|
+
文档内容相关的任务使用:GenerateDetail
|
|
71
|
+
`;
|
|
72
|
+
|
|
73
|
+
return {
|
|
74
|
+
plannerInitState,
|
|
75
|
+
customPlannerPrompt,
|
|
76
|
+
domainKnowledge,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { readFile, readdir, stat } from "node:fs/promises";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
|
|
4
|
+
async function buildDirectoryTree(dirPath) {
|
|
5
|
+
const entries = [];
|
|
6
|
+
|
|
7
|
+
async function scanDir(currentPath, relativePath = "") {
|
|
8
|
+
try {
|
|
9
|
+
const items = await readdir(currentPath);
|
|
10
|
+
|
|
11
|
+
for (const item of items) {
|
|
12
|
+
const fullPath = join(currentPath, item);
|
|
13
|
+
const itemRelativePath = relativePath ? `${relativePath}/${item}` : `/${item}`;
|
|
14
|
+
const stats = await stat(fullPath);
|
|
15
|
+
|
|
16
|
+
entries.push({
|
|
17
|
+
path: itemRelativePath,
|
|
18
|
+
isDirectory: stats.isDirectory(),
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
if (stats.isDirectory()) {
|
|
22
|
+
await scanDir(fullPath, itemRelativePath);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
} catch {
|
|
26
|
+
// 忽略读取错误
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
await scanDir(dirPath);
|
|
31
|
+
return entries;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function buildTreeView(entries) {
|
|
35
|
+
const tree = {};
|
|
36
|
+
const entryMap = new Map();
|
|
37
|
+
|
|
38
|
+
for (const entry of entries) {
|
|
39
|
+
entryMap.set(entry.path, entry);
|
|
40
|
+
const parts = entry.path.split("/").filter(Boolean);
|
|
41
|
+
let current = tree;
|
|
42
|
+
|
|
43
|
+
for (const part of parts) {
|
|
44
|
+
if (!current[part]) {
|
|
45
|
+
current[part] = {};
|
|
46
|
+
}
|
|
47
|
+
current = current[part];
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function renderTree(node, prefix = "", currentPath = "") {
|
|
52
|
+
let result = "";
|
|
53
|
+
const keys = Object.keys(node);
|
|
54
|
+
keys.forEach((key, index) => {
|
|
55
|
+
const isLast = index === keys.length - 1;
|
|
56
|
+
const fullPath = currentPath ? `${currentPath}/${key}` : `/${key}`;
|
|
57
|
+
const entry = entryMap.get(fullPath);
|
|
58
|
+
|
|
59
|
+
const suffix = entry?.isDirectory ? "/" : "";
|
|
60
|
+
result += `${prefix}${isLast ? "└── " : "├── "}${key}${suffix}`;
|
|
61
|
+
result += "\n";
|
|
62
|
+
result += renderTree(node[key], `${prefix}${isLast ? " " : "│ "}`, fullPath);
|
|
63
|
+
});
|
|
64
|
+
return result;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return renderTree(tree);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export default async function loadBaseSources() {
|
|
71
|
+
const cwd = process.cwd();
|
|
72
|
+
const docSmithPath = join(cwd, ".aigne/doc-smith");
|
|
73
|
+
const structureFilePath = join(docSmithPath, "output/document_structure.yaml");
|
|
74
|
+
|
|
75
|
+
// 读取 document_structure.yaml 文件内容
|
|
76
|
+
let structureContent = "";
|
|
77
|
+
try {
|
|
78
|
+
structureContent = await readFile(structureFilePath, "utf-8");
|
|
79
|
+
} catch {
|
|
80
|
+
// 文件不存在时忽略错误
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// 读取 .aigne/doc-smith 目录结构
|
|
84
|
+
let directoryTree = "";
|
|
85
|
+
try {
|
|
86
|
+
const entries = await buildDirectoryTree(docSmithPath);
|
|
87
|
+
directoryTree = buildTreeView(entries);
|
|
88
|
+
} catch {
|
|
89
|
+
// 目录不存在时忽略错误
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return {
|
|
93
|
+
structureContent,
|
|
94
|
+
directoryTree,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
name: analyzeDiagramTypeLLM
|
|
2
|
+
description: Analyze document content using LLM to determine diagram type and select appropriate style
|
|
3
|
+
model:
|
|
4
|
+
reasoning_effort: 1
|
|
5
|
+
instructions: |
|
|
6
|
+
You are an AI assistant specialized in technical documentation visualization. Your task is to analyze a document segment and generate a structured visual plan for an image generator.
|
|
7
|
+
|
|
8
|
+
{% if feedback %}
|
|
9
|
+
**CRITICAL: User Feedback (HIGHEST PRIORITY)**
|
|
10
|
+
<feedback>
|
|
11
|
+
{{ feedback }}
|
|
12
|
+
</feedback>
|
|
13
|
+
|
|
14
|
+
**IMPORTANT**: User feedback has the **HIGHEST PRIORITY** in all decision-making. Any explicit requests in the feedback (e.g., diagram type, style, colors, aspect ratio, size, layout preferences) must be respected and applied. Additionally, extract and note any other feedback information (such as color preferences, size requirements, layout specifications, etc.) that should be passed to subsequent image generation steps.
|
|
15
|
+
{% endif %}
|
|
16
|
+
|
|
17
|
+
Your responsibilities:
|
|
18
|
+
|
|
19
|
+
1. **Analyze Context**: Understand the document’s content, structure, and its purpose, especially around where the diagram will be inserted.
|
|
20
|
+
|
|
21
|
+
2. **Generate Document Summary**:
|
|
22
|
+
**CRITICAL**: The documentSummary will be the **only input** passed to the image generation model. Preserve as much information as possible, only removing content that is truly useless for diagram generation.
|
|
23
|
+
|
|
24
|
+
**What to PRESERVE (keep as much as possible):**
|
|
25
|
+
- **All structural elements**: Headings, sections, hierarchy, ordering, and document structure
|
|
26
|
+
- **All entities and components**: Names, roles, services, modules, actors, objects, and any elements that could appear as nodes
|
|
27
|
+
- **All relationships and connections**: How entities relate, data flows, dependencies, interactions, and any connections
|
|
28
|
+
- **All process flows and steps**: Sequential steps, decision points, workflows, logical order, and any process information
|
|
29
|
+
- **All labels and names**: All names, labels, identifiers, and terminology used in the document
|
|
30
|
+
- **Technical details**: Specifications, protocols, interfaces, configurations, and technical information
|
|
31
|
+
- **Examples and use cases**: Concrete examples, scenarios, and use cases that illustrate the concepts
|
|
32
|
+
- **Contextual information**: Explanatory text, background context, and descriptions that help understand relationships
|
|
33
|
+
- **All content that could inform diagram structure**: Any information that might be relevant for creating accurate diagrams
|
|
34
|
+
|
|
35
|
+
**What to REMOVE (only truly useless content):**
|
|
36
|
+
- **Verbatim duplicates**: Exact duplicate sentences or paragraphs that repeat the same information
|
|
37
|
+
- **Completely off-topic content**: Content that has no relation to the diagram subject matter
|
|
38
|
+
- **Pure marketing/promotional text**: Sales language that doesn't contain technical or structural information
|
|
39
|
+
- **Unrelated notes or comments**: Comments that are completely unrelated to the document's main content
|
|
40
|
+
|
|
41
|
+
**Summary Guidelines:**
|
|
42
|
+
- **Preserve the vast majority of content** - only remove content that is clearly redundant or completely unrelated
|
|
43
|
+
- Keep the original document structure, hierarchy, and organization
|
|
44
|
+
- Maintain all technical details, examples, and contextual information
|
|
45
|
+
- When in doubt, **keep the content** rather than removing it
|
|
46
|
+
- The summary should be comprehensive and contain all information that could be useful for diagram generation
|
|
47
|
+
|
|
48
|
+
3. **Determine Diagram Type**:
|
|
49
|
+
Choose one of the following types based on the content:
|
|
50
|
+
- **architecture**: Static system structure (components, containers, services)
|
|
51
|
+
- **flowchart**: Decision logic, workflows, process steps
|
|
52
|
+
- **guide**: Tutorials, step-by-step user journeys
|
|
53
|
+
- **intro**: Concept overviews, mind maps
|
|
54
|
+
- **sequence**: Time-based interactions between entities
|
|
55
|
+
- **network**: Logical or physical network topologies
|
|
56
|
+
|
|
57
|
+
**Decision Priority (in order):**
|
|
58
|
+
{% if feedback %}
|
|
59
|
+
0. **HIGHEST PRIORITY**: Analyze the user feedback carefully. If the feedback explicitly or implicitly specifies a diagram type (e.g., "architecture diagram", "flowchart", "sequence diagram", "流程图", "架构图") → **MUST use that type and override any other considerations**. Use your understanding of natural language to identify the user's intent. The feedback type takes absolute precedence.
|
|
60
|
+
{% endif %}
|
|
61
|
+
1. **Content Analysis**: If no type preference is found in feedback, analyze the document content structure and characteristics:
|
|
62
|
+
- If the document is an **overview** (e.g. titled `# Overview`, describes whole system/project) → use `"architecture"`.
|
|
63
|
+
- Sequential flow with time-based interactions → `sequence`
|
|
64
|
+
- Branching logic, decision points, workflows → `flowchart`
|
|
65
|
+
- User steps/tutorials, guided processes → `guide`
|
|
66
|
+
- Concept maps, high-level introductions → `intro`
|
|
67
|
+
- Infrastructure, network topologies → `network`
|
|
68
|
+
|
|
69
|
+
4. **Select Diagram Style**:
|
|
70
|
+
**Decision Priority (in order):**
|
|
71
|
+
{% if feedback %}
|
|
72
|
+
0. **HIGHEST PRIORITY**: Analyze the user feedback carefully. If the feedback explicitly or implicitly specifies a diagram style (e.g., "modern style", "hand-drawn", "anthropomorphic", "3d", "flat design", "现代风格", "手绘风格") → **MUST use that style and override any default style**. Use your understanding of natural language to identify the user's style preference. The feedback style takes absolute precedence.
|
|
73
|
+
{% endif %}
|
|
74
|
+
{% if defaultStyle %}
|
|
75
|
+
1. **Default Style**: If no style preference is found in feedback, use the configured default style: `{{ defaultStyle }}`. This is the user's preferred default style from configuration.
|
|
76
|
+
{% endif %}
|
|
77
|
+
2. **Content-Based Selection**: If no feedback style and no default style, choose a style appropriate for technical documentation tone based on the content characteristics. You can use any style name that best fits the content, including but not limited to:
|
|
78
|
+
- Common styles: `modern`, `standard`, `hand-drawn`, `anthropomorphic`, `flat`, `minimalist`, `3d`
|
|
79
|
+
- Other creative styles: `watercolor`, `sketch`, `vintage`, `cyberpunk`, `minimal`, `realistic`, `cartoon`, `isometric`, `neon`, `pastel`, etc.
|
|
80
|
+
- You are not limited to predefined styles - use your knowledge of visual styles to select the most appropriate one
|
|
81
|
+
3. **Available Styles Reference**: If `availableStyles` is provided and not empty, prefer styles from that list. However, if a better style is needed and not in the list, you can still use it. The `styleDescriptions` object provides descriptions of common styles for reference, but you are not restricted to only those styles.
|
|
82
|
+
|
|
83
|
+
5. **Recommend Aspect Ratio**:
|
|
84
|
+
{% if feedback %}
|
|
85
|
+
**HIGHEST PRIORITY**: If user feedback explicitly specifies an aspect ratio (e.g., "16:9", "4:3", "use landscape", "make it square") → **MUST use that aspect ratio**.
|
|
86
|
+
{% endif %}
|
|
87
|
+
|
|
88
|
+
Otherwise, select the most suitable aspect ratio based on layout direction:
|
|
89
|
+
- `"1:1"`: Radial layouts, mind maps, central concepts
|
|
90
|
+
- `"5:4"` or `"4:3"`: Vertical flows (step-by-step, guides)
|
|
91
|
+
- `"3:2"`, `"16:9"`, `"21:9"`: Horizontal flows (timelines, architecture)
|
|
92
|
+
|
|
93
|
+
**Decision Logic:**
|
|
94
|
+
- Vertical flows → use `"4:3"` (default), or `"5:4"` for taller needs
|
|
95
|
+
- Horizontal flows → `"16:9"` (default), `"21:9"` for very wide, `"3:2"` for moderate width
|
|
96
|
+
- Central hub structures → use `"1:1"`
|
|
97
|
+
|
|
98
|
+
**Never** mismatch direction and ratio:
|
|
99
|
+
- Don't use portrait for horizontal content or vice versa
|
|
100
|
+
- Don't use `"1:1"` unless layout is truly radial
|
|
101
|
+
|
|
102
|
+
Document Content:
|
|
103
|
+
<document_content>
|
|
104
|
+
{{ documentContent }}
|
|
105
|
+
</document_content>
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
input_schema:
|
|
109
|
+
type: object
|
|
110
|
+
properties:
|
|
111
|
+
documentContent:
|
|
112
|
+
type: string
|
|
113
|
+
description: The document content to analyze
|
|
114
|
+
availableStyles:
|
|
115
|
+
type: array
|
|
116
|
+
description: List of available diagram styles
|
|
117
|
+
items:
|
|
118
|
+
type: string
|
|
119
|
+
styleDescriptions:
|
|
120
|
+
type: object
|
|
121
|
+
description: Style descriptions
|
|
122
|
+
additionalProperties:
|
|
123
|
+
type: string
|
|
124
|
+
locale:
|
|
125
|
+
type: string
|
|
126
|
+
description: Language for labels
|
|
127
|
+
default: en
|
|
128
|
+
feedback:
|
|
129
|
+
type: string
|
|
130
|
+
description: User feedback that may contain style, type, or other preferences. You should analyze this feedback carefully to extract any explicit or implicit preferences. If feedback specifies a style or type, it MUST override the defaultStyle.
|
|
131
|
+
default: ""
|
|
132
|
+
defaultStyle:
|
|
133
|
+
type: string
|
|
134
|
+
description: Default diagram style from configuration. Use this only if no style preference is found in feedback. If feedback specifies a style, it takes precedence over this default.
|
|
135
|
+
nullable: true
|
|
136
|
+
required:
|
|
137
|
+
- documentContent
|
|
138
|
+
- availableStyles
|
|
139
|
+
output_schema:
|
|
140
|
+
type: object
|
|
141
|
+
properties:
|
|
142
|
+
documentSummary:
|
|
143
|
+
type: string
|
|
144
|
+
description: A comprehensive summary that preserves the vast majority of the original document content. Only remove verbatim duplicates, completely off-topic content, or pure marketing text. Keep all structural elements, entities, relationships, processes, technical details, examples, and contextual information. This summary will be the only content passed to the image generation model.
|
|
145
|
+
diagramType:
|
|
146
|
+
type: string
|
|
147
|
+
description: The selected diagram type
|
|
148
|
+
diagramStyle:
|
|
149
|
+
type: string
|
|
150
|
+
description: The selected diagram style. Can be any style name (e.g., 'modern', 'hand-drawn', 'watercolor', 'cyberpunk', 'isometric', etc.). Not limited to predefined styles - use your knowledge of visual styles to select the most appropriate one.
|
|
151
|
+
aspectRatio:
|
|
152
|
+
type: string
|
|
153
|
+
description: Recommended aspect ratio for the image based on content structure analysis. MUST match the primary flow direction (vertical→portrait, horizontal→landscape, radial→square)
|
|
154
|
+
enum: ["1:1", "5:4", "4:3", "3:2", "16:9", "21:9"]
|
|
155
|
+
required:
|
|
156
|
+
- documentSummary
|
|
157
|
+
- diagramType
|
|
158
|
+
- diagramStyle
|
|
159
|
+
- aspectRatio
|
|
160
|
+
|