@aigne/doc-smith 0.8.15-beta.3 → 0.8.15-beta.4
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 +7 -0
- package/agents/update/generate-diagram.yaml +30 -0
- package/agents/update/generate-document.yaml +1 -30
- package/agents/update/save-and-translate-document.mjs +2 -9
- package/agents/update/update-document-detail.yaml +1 -0
- package/agents/utils/save-doc-translation.mjs +2 -2
- package/aigne.yaml +0 -1
- package/package.json +1 -1
- package/prompts/detail/generate/user-prompt.md +1 -0
- package/utils/utils.mjs +0 -38
- package/agents/utils/save-doc-translations.mjs +0 -33
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.8.15-beta.4](https://github.com/AIGNE-io/aigne-doc-smith/compare/v0.8.15-beta.3...v0.8.15-beta.4) (2025-10-28)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* fix update translate not working ([#221](https://github.com/AIGNE-io/aigne-doc-smith/issues/221)) ([95bc49e](https://github.com/AIGNE-io/aigne-doc-smith/commit/95bc49ec8b1e18fe20dd1360d9707afdd6629bad))
|
|
9
|
+
|
|
3
10
|
## [0.8.15-beta.3](https://github.com/AIGNE-io/aigne-doc-smith/compare/v0.8.15-beta.2...v0.8.15-beta.3) (2025-10-28)
|
|
4
11
|
|
|
5
12
|
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
type: team
|
|
2
|
+
task_render_mode: collapse
|
|
3
|
+
name: generateDiagram
|
|
4
|
+
skills:
|
|
5
|
+
- ../generate/draw-diagram.yaml
|
|
6
|
+
- ../generate/wrap-diagram-code.mjs
|
|
7
|
+
reflection:
|
|
8
|
+
reviewer: ../generate/check-diagram.mjs
|
|
9
|
+
is_approved: isValid
|
|
10
|
+
max_iterations: 5
|
|
11
|
+
return_last_on_max_iterations: false
|
|
12
|
+
custom_error_message: "MUST NOT generate any diagram: validation failed after max iterations."
|
|
13
|
+
input_schema:
|
|
14
|
+
type: object
|
|
15
|
+
properties:
|
|
16
|
+
documentContent:
|
|
17
|
+
type: string
|
|
18
|
+
description: The **raw text content** of the current document. (**Note:** This is the original document and **does not include** any diagram source code.)
|
|
19
|
+
locale:
|
|
20
|
+
type: string
|
|
21
|
+
description: Language for diagram labels and text
|
|
22
|
+
default: en
|
|
23
|
+
required:
|
|
24
|
+
- documentContent
|
|
25
|
+
output_schema:
|
|
26
|
+
type: object
|
|
27
|
+
properties:
|
|
28
|
+
diagramSourceCode:
|
|
29
|
+
type: string
|
|
30
|
+
description: The **diagram source code** generated from the input text.
|
|
@@ -58,33 +58,4 @@ afs:
|
|
|
58
58
|
should search and read as needed while generating document content
|
|
59
59
|
keep_text_in_tool_uses: false
|
|
60
60
|
skills:
|
|
61
|
-
-
|
|
62
|
-
task_render_mode: collapse
|
|
63
|
-
name: generateDiagram
|
|
64
|
-
skills:
|
|
65
|
-
- ../generate/draw-diagram.yaml
|
|
66
|
-
- ../generate/wrap-diagram-code.mjs
|
|
67
|
-
reflection:
|
|
68
|
-
reviewer: ../generate/check-diagram.mjs
|
|
69
|
-
is_approved: isValid
|
|
70
|
-
max_iterations: 5
|
|
71
|
-
return_last_on_max_iterations: false
|
|
72
|
-
custom_error_message: "MUST NOT generate any diagram: validation failed after max iterations."
|
|
73
|
-
input_schema:
|
|
74
|
-
type: object
|
|
75
|
-
properties:
|
|
76
|
-
documentContent:
|
|
77
|
-
type: string
|
|
78
|
-
description: The **raw text content** of the current document. (**Note:** This is the original document and **does not include** any diagram source code.)
|
|
79
|
-
locale:
|
|
80
|
-
type: string
|
|
81
|
-
description: Language for diagram labels and text
|
|
82
|
-
default: en
|
|
83
|
-
required:
|
|
84
|
-
- documentContent
|
|
85
|
-
output_schema:
|
|
86
|
-
type: object
|
|
87
|
-
properties:
|
|
88
|
-
diagramSourceCode:
|
|
89
|
-
type: string
|
|
90
|
-
description: The **diagram source code** generated from the input text.
|
|
61
|
+
- ./generate-diagram.yaml
|
|
@@ -47,20 +47,13 @@ export default async function saveAndTranslateDocument(input, options) {
|
|
|
47
47
|
// Clear feedback to ensure translation is not affected by update feedback
|
|
48
48
|
doc.feedback = "";
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
await options.context.invoke(translateAgent, {
|
|
51
51
|
...input, // context is required
|
|
52
52
|
content: doc.content,
|
|
53
53
|
translates: doc.translates,
|
|
54
54
|
title: doc.title,
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
// Save the translated content
|
|
58
|
-
const saveTranslationsAgent = options.context.agents["saveDocTranslations"];
|
|
59
|
-
await options.context.invoke(saveTranslationsAgent, {
|
|
60
55
|
path: doc.path,
|
|
61
|
-
docsDir
|
|
62
|
-
translates: result.translates || doc.translates,
|
|
63
|
-
labels: doc.labels,
|
|
56
|
+
docsDir,
|
|
64
57
|
});
|
|
65
58
|
} catch (error) {
|
|
66
59
|
console.error(`❌ Failed to translate document ${doc.path}:`, error.message);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { saveDocTranslation as _saveDocTranslation } from "../../utils/utils.mjs";
|
|
2
2
|
|
|
3
|
-
export default async function
|
|
3
|
+
export default async function saveDocTranslation({
|
|
4
4
|
path,
|
|
5
5
|
docsDir,
|
|
6
6
|
translation,
|
|
@@ -24,4 +24,4 @@ export default async function saveDocTranslations({
|
|
|
24
24
|
return {};
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
saveDocTranslation.task_render_mode = "hide";
|
package/aigne.yaml
CHANGED
|
@@ -71,7 +71,6 @@ agents:
|
|
|
71
71
|
- ./agents/utils/transform-detail-datasources.mjs
|
|
72
72
|
- ./agents/utils/save-doc.mjs
|
|
73
73
|
- ./agents/utils/save-doc-translation.mjs
|
|
74
|
-
- ./agents/utils/save-doc-translations.mjs
|
|
75
74
|
- ./agents/utils/save-output.mjs
|
|
76
75
|
- ./agents/utils/format-document-structure.mjs
|
|
77
76
|
- ./agents/utils/find-item-by-path.mjs
|
package/package.json
CHANGED
|
@@ -97,6 +97,7 @@ Generate detailed and well-structured document for the current {{nodeName}} base
|
|
|
97
97
|
YOU SHOULD:
|
|
98
98
|
- Use AFS tools `afs_list` `afs_search` or `afs_read` to gather relevant and accurate information to enhance the content.
|
|
99
99
|
- Follow rules in `<diagram_generation_guide>`: use `generateDiagram` tool to create and embed a diagram when appropriate, following the diagram generation guidelines.
|
|
100
|
+
- If the `generateDiagram` tool is not called, do not attempt to add any diagrams.
|
|
100
101
|
|
|
101
102
|
<steps>
|
|
102
103
|
1. Analyze the provided document structure and user requirements to plan the content.
|
package/utils/utils.mjs
CHANGED
|
@@ -111,44 +111,6 @@ export async function saveDoc({ path: docPath, content, docsDir, locale, labels
|
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
/**
|
|
115
|
-
* Save a single document's translations to files
|
|
116
|
-
* @param {Object} params
|
|
117
|
-
* @param {string} params.path - Relative path (without extension)
|
|
118
|
-
* @param {string} params.docsDir - Root directory
|
|
119
|
-
* @param {Array<{language: string, translation: string}>} [params.translates] - Translation content
|
|
120
|
-
* @param {Array<string>} [params.labels] - Document labels for front matter
|
|
121
|
-
* @returns {Promise<Array<{ path: string, success: boolean, error?: string }>>}
|
|
122
|
-
*/
|
|
123
|
-
export async function saveDocTranslations({ path: docPath, docsDir, translates = [], labels }) {
|
|
124
|
-
const results = [];
|
|
125
|
-
try {
|
|
126
|
-
await fs.mkdir(docsDir, { recursive: true });
|
|
127
|
-
|
|
128
|
-
// Process all translations
|
|
129
|
-
for (const translate of translates) {
|
|
130
|
-
const translateFileName = getFileName(docPath, translate.language);
|
|
131
|
-
const translatePath = path.join(docsDir, translateFileName);
|
|
132
|
-
|
|
133
|
-
// Add labels front matter to translation content if labels are provided
|
|
134
|
-
let finalTranslationContent = processContent({
|
|
135
|
-
content: translate.translation,
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
if (labels && labels.length > 0) {
|
|
139
|
-
const frontMatter = `---\nlabels: ${JSON.stringify(labels)}\n---\n\n`;
|
|
140
|
-
finalTranslationContent = frontMatter + finalTranslationContent;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
await fs.writeFile(translatePath, finalTranslationContent, "utf8");
|
|
144
|
-
results.push({ path: translatePath, success: true });
|
|
145
|
-
}
|
|
146
|
-
} catch (err) {
|
|
147
|
-
results.push({ path: docPath, success: false, error: err.message });
|
|
148
|
-
}
|
|
149
|
-
return results;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
114
|
export async function saveDocTranslation({
|
|
153
115
|
path: docPath,
|
|
154
116
|
docsDir,
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { shutdownMermaidWorkerPool } from "../../utils/mermaid-worker-pool.mjs";
|
|
2
|
-
import { saveDocTranslations as _saveDocTranslations } from "../../utils/utils.mjs";
|
|
3
|
-
|
|
4
|
-
export default async function saveDocTranslations({
|
|
5
|
-
path,
|
|
6
|
-
docsDir,
|
|
7
|
-
translates,
|
|
8
|
-
labels,
|
|
9
|
-
isShowMessage = false,
|
|
10
|
-
}) {
|
|
11
|
-
await _saveDocTranslations({
|
|
12
|
-
path,
|
|
13
|
-
docsDir,
|
|
14
|
-
translates,
|
|
15
|
-
labels,
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
if (isShowMessage) {
|
|
19
|
-
// Shutdown mermaid worker pool to ensure clean exit
|
|
20
|
-
try {
|
|
21
|
-
await shutdownMermaidWorkerPool();
|
|
22
|
-
} catch (error) {
|
|
23
|
-
console.warn("Failed to shutdown mermaid worker pool:", error.message);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const message = `✅ Translation completed successfully.`;
|
|
27
|
-
return { message };
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return {};
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
saveDocTranslations.task_render_mode = "hide";
|