@aigne/doc-smith 0.8.6 → 0.8.7
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/output/structure-plan.json +1 -5
- package/CHANGELOG.md +7 -0
- package/README.md +3 -3
- package/agents/{chat.yaml → chat/index.yaml} +7 -7
- package/agents/generate/check-document-structure.yaml +30 -0
- package/agents/{check-structure-plan.mjs → generate/check-need-generate-structure.mjs} +20 -20
- package/agents/{structure-planning.yaml → generate/generate-structure.yaml} +6 -6
- package/agents/{docs-generator.yaml → generate/index.yaml} +11 -12
- package/agents/generate/refine-document-structure.yaml +12 -0
- package/agents/{input-generator.mjs → init/index.mjs} +12 -5
- package/agents/{manage-prefs.mjs → prefs/index.mjs} +1 -1
- package/agents/{team-publish-docs.yaml → publish/index.yaml} +1 -2
- package/agents/{publish-docs.mjs → publish/publish-docs.mjs} +6 -5
- package/agents/schema/{structure-plan-result.yaml → document-execution-structure.yaml} +3 -3
- package/agents/schema/document-structure.yaml +26 -0
- package/agents/{language-selector.mjs → translate/choose-language.mjs} +5 -5
- package/agents/{retranslate.yaml → translate/index.yaml} +11 -12
- package/agents/{translate.yaml → translate/translate-document.yaml} +3 -2
- package/agents/{batch-translate.yaml → translate/translate-multilingual.yaml} +5 -5
- package/agents/update/batch-generate-document.yaml +19 -0
- package/agents/{check-detail.mjs → update/check-document.mjs} +16 -16
- package/agents/{detail-generator-and-translate.yaml → update/generate-and-translate-document.yaml} +23 -23
- package/agents/update/generate-document.yaml +50 -0
- package/agents/{detail-regenerator.yaml → update/index.yaml} +10 -11
- package/agents/{action-success.mjs → utils/action-success.mjs} +1 -1
- package/agents/{check-detail-result.mjs → utils/check-detail-result.mjs} +3 -3
- package/agents/{check-feedback-refiner.mjs → utils/check-feedback-refiner.mjs} +6 -6
- package/agents/{find-items-by-paths.mjs → utils/choose-docs.mjs} +24 -9
- package/agents/{docs-fs.yaml → utils/docs-fs-actor.yaml} +3 -1
- package/agents/{feedback-refiner.yaml → utils/feedback-refiner.yaml} +2 -4
- package/agents/{find-item-by-path.mjs → utils/find-item-by-path.mjs} +16 -6
- package/agents/{find-user-preferences-by-path.mjs → utils/find-user-preferences-by-path.mjs} +1 -1
- package/agents/utils/format-document-structure.mjs +25 -0
- package/agents/{load-sources.mjs → utils/load-sources.mjs} +41 -28
- package/agents/{save-docs.mjs → utils/save-docs.mjs} +16 -16
- package/agents/{save-single-doc.mjs → utils/save-single-doc.mjs} +2 -2
- package/agents/{transform-detail-datasources.mjs → utils/transform-detail-datasources.mjs} +1 -1
- package/aigne.yaml +35 -35
- package/docs-mcp/analyze-docs-relevance.yaml +10 -10
- package/docs-mcp/docs-search.yaml +5 -3
- package/package.json +10 -8
- package/prompts/{document → detail/custom}/custom-code-block.md +6 -6
- package/prompts/detail/custom/custom-components.md +172 -0
- package/prompts/{document → detail}/d2-chart/rules.md +95 -1
- package/prompts/{document → detail}/detail-example.md +80 -61
- package/prompts/{document/detail-generator.md → detail/document-rules.md} +4 -8
- package/prompts/{content-detail-generator.md → detail/generate-document.md} +48 -25
- package/prompts/{check-structure-planning-result.md → structure/check-document-structure.md} +23 -17
- package/prompts/{document/structure-planning.md → structure/document-rules.md} +0 -2
- package/prompts/{structure-planning.md → structure/generate-structure.md} +51 -30
- package/prompts/{document → structure}/structure-example.md +2 -2
- package/prompts/{document → structure}/structure-getting-started.md +2 -2
- package/prompts/translate/glossary.md +6 -0
- package/prompts/{translator.md → translate/translate-document.md} +29 -10
- package/prompts/{feedback-refiner.md → utils/feedback-refiner.md} +8 -8
- package/tests/agents/chat/chat.test.mjs +46 -0
- package/tests/agents/generate/check-document-structure.test.mjs +51 -0
- package/tests/agents/generate/check-need-generate-structure.test.mjs +292 -0
- package/tests/agents/generate/generate-structure.test.mjs +51 -0
- package/tests/{input-generator.test.mjs → agents/init/init.test.mjs} +13 -13
- package/tests/agents/prefs/prefs.test.mjs +431 -0
- package/tests/agents/publish/publish-docs.test.mjs +642 -0
- package/tests/agents/translate/choose-language.test.mjs +311 -0
- package/tests/agents/translate/translate-document.test.mjs +51 -0
- package/tests/agents/update/check-document.test.mjs +523 -0
- package/tests/agents/update/generate-document.test.mjs +51 -0
- package/tests/agents/utils/action-success.test.mjs +54 -0
- package/tests/{check-detail-result.test.mjs → agents/utils/check-detail-result.test.mjs} +98 -98
- package/tests/agents/utils/check-feedback-refiner.test.mjs +478 -0
- package/tests/agents/utils/choose-docs.test.mjs +417 -0
- package/tests/agents/utils/exit.test.mjs +70 -0
- package/tests/agents/utils/feedback-refiner.test.mjs +51 -0
- package/tests/agents/utils/find-item-by-path.test.mjs +526 -0
- package/tests/agents/utils/find-user-preferences-by-path.test.mjs +382 -0
- package/tests/agents/utils/format-document-structure.test.mjs +264 -0
- package/tests/agents/utils/fs.test.mjs +267 -0
- package/tests/{load-sources.test.mjs → agents/utils/load-sources.test.mjs} +153 -25
- package/tests/{save-docs.test.mjs → agents/utils/save-docs.test.mjs} +11 -5
- package/tests/agents/utils/save-output.test.mjs +315 -0
- package/tests/agents/utils/save-single-doc.test.mjs +364 -0
- package/tests/agents/utils/transform-detail-datasources.test.mjs +363 -0
- package/tests/utils/auth-utils.test.mjs +358 -0
- package/tests/utils/blocklet.test.mjs +334 -0
- package/tests/{conflict-resolution.test.mjs → utils/conflict-detector.test.mjs} +3 -3
- package/tests/utils/constants.test.mjs +295 -0
- package/tests/utils/d2-utils.test.mjs +423 -0
- package/tests/{deploy.test.mjs → utils/deploy.test.mjs} +25 -36
- package/tests/utils/docs-finder-utils.test.mjs +625 -0
- package/tests/utils/file-utils.test.mjs +213 -0
- package/tests/{kroki-utils.test.mjs → utils/kroki-utils.test.mjs} +2 -2
- package/tests/utils/load-config.test.mjs +141 -0
- package/tests/{mermaid-validation.test.mjs → utils/mermaid-validator.test.mjs} +2 -2
- package/tests/utils/mock-chat-model.mjs +12 -0
- package/tests/{preferences-utils.test.mjs → utils/preferences-utils.test.mjs} +1 -1
- package/tests/{save-value-to-config.test.mjs → utils/save-value-to-config.test.mjs} +61 -4
- package/tests/utils/utils.test.mjs +939 -0
- package/utils/conflict-detector.mjs +1 -1
- package/utils/constants.mjs +5 -3
- package/utils/d2-utils.mjs +194 -0
- package/utils/docs-finder-utils.mjs +26 -26
- package/utils/icon-map.mjs +26 -0
- package/{agents → utils}/load-config.mjs +2 -18
- package/utils/markdown-checker.mjs +5 -5
- package/agents/batch-docs-detail-generator.yaml +0 -19
- package/agents/check-structure-planning-result.yaml +0 -30
- package/agents/content-detail-generator.yaml +0 -50
- package/agents/format-structure-plan.mjs +0 -25
- package/agents/reflective-structure-planner.yaml +0 -12
- package/agents/schema/structure-plan.yaml +0 -26
- package/prompts/document/custom-components.md +0 -104
- package/tests/README.md +0 -93
- package/tests/utils.test.mjs +0 -2067
- /package/agents/{exit.mjs → utils/exit.mjs} +0 -0
- /package/agents/{fs.mjs → utils/fs.mjs} +0 -0
- /package/agents/{save-output.mjs → utils/save-output.mjs} +0 -0
- /package/prompts/{document → detail}/d2-chart/official-examples.md +0 -0
- /package/prompts/{document → detail}/jsx/rules.md +0 -0
|
@@ -136,11 +136,7 @@
|
|
|
136
136
|
"description": "Understand the built-in checks DocSmith performs to ensure high-quality, well-formatted, and error-free documentation, including link checking and diagram validation.",
|
|
137
137
|
"path": "/advanced/quality-assurance",
|
|
138
138
|
"parentId": "/advanced",
|
|
139
|
-
"sourceIds": [
|
|
140
|
-
"utils/markdown-checker.mjs",
|
|
141
|
-
"utils/mermaid-validator.mjs",
|
|
142
|
-
"utils/kroki-utils.mjs"
|
|
143
|
-
]
|
|
139
|
+
"sourceIds": ["utils/markdown-checker.mjs", "utils/mermaid-validator.mjs", "utils/d2-utils.mjs"]
|
|
144
140
|
},
|
|
145
141
|
{
|
|
146
142
|
"title": "Changelog",
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.8.7](https://github.com/AIGNE-io/aigne-doc-smith/compare/v0.8.6...v0.9.0) (2025-09-12)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* support defining API parameters with field element ([#104](https://github.com/AIGNE-io/aigne-doc-smith/issues/104)) ([2296ead](https://github.com/AIGNE-io/aigne-doc-smith/commit/2296ead15a00aaf809b3854bf349361f0213f522))
|
|
9
|
+
|
|
3
10
|
## [0.8.6](https://github.com/AIGNE-io/aigne-doc-smith/compare/v0.8.5...v0.8.6) (2025-09-11)
|
|
4
11
|
|
|
5
12
|
|
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
[](https://star-history.com/#AIGNE-io/aigne-doc-smith)
|
|
2
2
|
[](https://github.com/AIGNE-io/aigne-doc-smith/issues)
|
|
3
3
|
[](https://codecov.io/gh/AIGNE-io/aigne-doc-smith)
|
|
4
|
-
[](https://www.npmjs.com/package/@aigne/doc-smith)
|
|
5
5
|
|
|
6
6
|
# AIGNE DocSmith
|
|
7
7
|
|
|
@@ -17,7 +17,7 @@ As shown in the diagram, DocSmith integrates seamlessly with other [AIGNE](https
|
|
|
17
17
|
|
|
18
18
|
## Features
|
|
19
19
|
|
|
20
|
-
- **Automated Structure
|
|
20
|
+
- **Automated Generate Document Structure:** Intelligently analyzes your codebase to generate a comprehensive and logical document structure.
|
|
21
21
|
- **AI-Powered Content Generation:** Populates the document structure with detailed, high-quality content.
|
|
22
22
|
- **Multi-Language Support:** Seamlessly translates your documentation into 12 languages including English, Chinese, Japanese, Korean, Spanish, French, German, Portuguese, Russian, Italian, and Arabic.
|
|
23
23
|
- **AIGNE Hub Integration:** Use [AIGNE Hub](https://www.aigne.io/en/hub) as your LLM provider without needing your own API keys, with easy switching between different large language models.
|
|
@@ -185,7 +185,7 @@ aigne doc update --docs overview.md --feedback "Add more comprehensive FAQ entri
|
|
|
185
185
|
|
|
186
186
|
**Interactive Mode:** When run without parameters, `aigne doc update` will present an interactive menu for you to select which document to regenerate and provide feedback.
|
|
187
187
|
|
|
188
|
-
#### Optimize Structure
|
|
188
|
+
#### Optimize Document Structure
|
|
189
189
|
|
|
190
190
|
Improve the overall documentation structure based on feedback:
|
|
191
191
|
|
|
@@ -21,10 +21,10 @@ instructions: |
|
|
|
21
21
|
input_key: message
|
|
22
22
|
memory: true
|
|
23
23
|
skills:
|
|
24
|
-
-
|
|
25
|
-
-
|
|
26
|
-
-
|
|
27
|
-
-
|
|
28
|
-
-
|
|
29
|
-
-
|
|
30
|
-
-
|
|
24
|
+
- ../init/index.mjs
|
|
25
|
+
- ../generate/index.yaml
|
|
26
|
+
- ../update/index.yaml
|
|
27
|
+
- ../publish/index.yaml
|
|
28
|
+
- ../translate/index.yaml
|
|
29
|
+
- ../utils/docs-fs-actor.yaml
|
|
30
|
+
- ../utils/exit.mjs
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
name: checkDocumentStructure
|
|
2
|
+
description: Check the Document Structure to ensure it meets expectations, especially in scenarios with previous generation results and user feedback.
|
|
3
|
+
instructions:
|
|
4
|
+
url: ../../prompts/structure/check-document-structure.md
|
|
5
|
+
input_schema:
|
|
6
|
+
type: object
|
|
7
|
+
properties:
|
|
8
|
+
documentStructure:
|
|
9
|
+
$ref: ../schema/document-structure.yaml
|
|
10
|
+
description: Newly generated document structure.
|
|
11
|
+
originalDocumentStructure:
|
|
12
|
+
$ref: ../schema/document-structure.yaml
|
|
13
|
+
description: Previous generation's document structure for comparison. If it doesn't exist, the check passes by default.
|
|
14
|
+
feedback:
|
|
15
|
+
type: string
|
|
16
|
+
description: User feedback provided for the previous generation's results.
|
|
17
|
+
required:
|
|
18
|
+
- documentStructure
|
|
19
|
+
output_schema:
|
|
20
|
+
type: object
|
|
21
|
+
properties:
|
|
22
|
+
isValid:
|
|
23
|
+
type: boolean
|
|
24
|
+
description: Whether the check passes. true indicates pass, false indicates failure.
|
|
25
|
+
structureReviewFeedback:
|
|
26
|
+
type: string
|
|
27
|
+
description: Detailed explanation of the check results. If it fails, clearly specify which parts do not meet requirements.
|
|
28
|
+
required:
|
|
29
|
+
- isValid
|
|
30
|
+
- structureReviewFeedback
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import { access } from "node:fs/promises";
|
|
2
2
|
import { join } from "node:path";
|
|
3
|
-
import { getActiveRulesForScope } from "
|
|
3
|
+
import { getActiveRulesForScope } from "../../utils/preferences-utils.mjs";
|
|
4
4
|
import {
|
|
5
5
|
getCurrentGitHead,
|
|
6
6
|
getProjectInfo,
|
|
7
7
|
hasFileChangesBetweenCommits,
|
|
8
8
|
loadConfigFromFile,
|
|
9
9
|
saveValueToConfig,
|
|
10
|
-
} from "
|
|
10
|
+
} from "../../utils/utils.mjs";
|
|
11
11
|
|
|
12
|
-
export default async function
|
|
13
|
-
{
|
|
12
|
+
export default async function checkNeedGenerateStructure(
|
|
13
|
+
{ originalDocumentStructure, feedback, lastGitHead, docsDir, forceRegenerate, ...rest },
|
|
14
14
|
options,
|
|
15
15
|
) {
|
|
16
|
-
// Check if we need to regenerate structure
|
|
16
|
+
// Check if we need to regenerate document structure
|
|
17
17
|
let shouldRegenerate = false;
|
|
18
18
|
let finalFeedback = feedback;
|
|
19
19
|
let submittedFeedback = feedback;
|
|
20
20
|
|
|
21
|
-
// Prompt for feedback if
|
|
22
|
-
if (
|
|
21
|
+
// Prompt for feedback if originalDocumentStructure exists and no feedback provided
|
|
22
|
+
if (originalDocumentStructure && !feedback) {
|
|
23
23
|
const userFeedback = await options.prompts.input({
|
|
24
24
|
message: "How can we improve the documentation structure? (press Enter to skip):",
|
|
25
25
|
});
|
|
@@ -30,8 +30,8 @@ export default async function checkStructurePlan(
|
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
// If no feedback and
|
|
34
|
-
if (
|
|
33
|
+
// If no feedback and originalDocumentStructure exists, check for git changes
|
|
34
|
+
if (originalDocumentStructure) {
|
|
35
35
|
// If no lastGitHead, check if _sidebar.md exists to determine if we should regenerate
|
|
36
36
|
if (!lastGitHead) {
|
|
37
37
|
try {
|
|
@@ -78,16 +78,16 @@ export default async function checkStructurePlan(
|
|
|
78
78
|
`;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
// If no regeneration needed, return original structure
|
|
82
|
-
if (
|
|
81
|
+
// If no regeneration needed, return original document structure
|
|
82
|
+
if (originalDocumentStructure && !finalFeedback && !shouldRegenerate) {
|
|
83
83
|
return {
|
|
84
|
-
|
|
84
|
+
documentStructure: originalDocumentStructure,
|
|
85
85
|
};
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
const panningAgent = options.context.agents["
|
|
88
|
+
const panningAgent = options.context.agents["refineDocumentStructure"];
|
|
89
89
|
|
|
90
|
-
// Get user preferences for structure
|
|
90
|
+
// Get user preferences for document structure and global scope
|
|
91
91
|
const structureRules = getActiveRulesForScope("structure", []);
|
|
92
92
|
const globalRules = getActiveRulesForScope("global", []);
|
|
93
93
|
|
|
@@ -100,7 +100,7 @@ export default async function checkStructurePlan(
|
|
|
100
100
|
|
|
101
101
|
const result = await options.context.invoke(panningAgent, {
|
|
102
102
|
feedback: finalFeedback || "",
|
|
103
|
-
|
|
103
|
+
originalDocumentStructure,
|
|
104
104
|
userPreferences,
|
|
105
105
|
...rest,
|
|
106
106
|
});
|
|
@@ -155,12 +155,12 @@ export default async function checkStructurePlan(
|
|
|
155
155
|
return {
|
|
156
156
|
...result,
|
|
157
157
|
feedback: "", // clear feedback
|
|
158
|
-
|
|
158
|
+
documentStructureFeedback: submittedFeedback,
|
|
159
159
|
projectInfoMessage: message,
|
|
160
|
-
|
|
161
|
-
?
|
|
162
|
-
: JSON.parse(JSON.stringify(result.
|
|
160
|
+
originalDocumentStructure: originalDocumentStructure
|
|
161
|
+
? originalDocumentStructure
|
|
162
|
+
: JSON.parse(JSON.stringify(result.documentStructure || [])),
|
|
163
163
|
};
|
|
164
164
|
}
|
|
165
165
|
|
|
166
|
-
|
|
166
|
+
checkNeedGenerateStructure.taskTitle = "Check if document structure needs generate or update";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
name:
|
|
2
|
-
description:
|
|
1
|
+
name: generateStructure
|
|
2
|
+
description: Generate the structure and organization of your documentation
|
|
3
3
|
instructions:
|
|
4
|
-
url:
|
|
4
|
+
url: ../../prompts/structure/generate-structure.md
|
|
5
5
|
input_schema:
|
|
6
6
|
type: object
|
|
7
7
|
properties:
|
|
@@ -13,7 +13,7 @@ input_schema:
|
|
|
13
13
|
description: Primary language for documentation (e.g., zh, en, ja)
|
|
14
14
|
datasources:
|
|
15
15
|
type: string
|
|
16
|
-
description: Project content and context to help
|
|
16
|
+
description: Project content and context to help generate document structure
|
|
17
17
|
targetAudience:
|
|
18
18
|
type: string
|
|
19
19
|
description: Target audience for the documentation
|
|
@@ -45,8 +45,8 @@ output_schema:
|
|
|
45
45
|
projectDesc:
|
|
46
46
|
type: string
|
|
47
47
|
description: Brief project description generated from content analysis (under 50 words)
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
documentStructure: ../schema/document-structure.yaml
|
|
49
|
+
documentStructureTree:
|
|
50
50
|
type: string
|
|
51
51
|
description: |
|
|
52
52
|
Visual tree structure showing documentation hierarchy with indented levels for easy review:
|
|
@@ -5,15 +5,14 @@ alias:
|
|
|
5
5
|
- g
|
|
6
6
|
description: Generate complete documentation for your project
|
|
7
7
|
skills:
|
|
8
|
-
- url:
|
|
8
|
+
- url: ../init/index.mjs
|
|
9
9
|
default_input:
|
|
10
10
|
skipIfExists: true
|
|
11
|
-
-
|
|
12
|
-
- ./
|
|
13
|
-
-
|
|
14
|
-
- url: ./save-output.mjs
|
|
11
|
+
- ../utils/load-sources.mjs
|
|
12
|
+
- ./check-need-generate-structure.mjs
|
|
13
|
+
- url: ../utils/save-output.mjs
|
|
15
14
|
default_input:
|
|
16
|
-
saveKey:
|
|
15
|
+
saveKey: documentStructure
|
|
17
16
|
savePath:
|
|
18
17
|
$get: outputDir
|
|
19
18
|
fileName: structure-plan.json
|
|
@@ -24,7 +23,7 @@ skills:
|
|
|
24
23
|
$merge([
|
|
25
24
|
$,
|
|
26
25
|
{
|
|
27
|
-
'
|
|
26
|
+
'documentExecutionStructure': $map(documentStructure, function($item) {
|
|
28
27
|
$merge([
|
|
29
28
|
$item,
|
|
30
29
|
{
|
|
@@ -35,12 +34,12 @@ skills:
|
|
|
35
34
|
"datasources": ""
|
|
36
35
|
}
|
|
37
36
|
])
|
|
38
|
-
-
|
|
39
|
-
-
|
|
40
|
-
- url:
|
|
37
|
+
- ../utils/format-document-structure.mjs
|
|
38
|
+
- ../update/batch-generate-document.yaml
|
|
39
|
+
- url: ../utils/check-feedback-refiner.mjs
|
|
41
40
|
default_input:
|
|
42
|
-
stage:
|
|
43
|
-
-
|
|
41
|
+
stage: document_structure
|
|
42
|
+
- ../utils/save-docs.mjs
|
|
44
43
|
|
|
45
44
|
input_schema:
|
|
46
45
|
type: object
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
type: team
|
|
2
|
+
name: refineDocumentStructure
|
|
3
|
+
description: A team of agents that generate the structure of the documentation.
|
|
4
|
+
skills:
|
|
5
|
+
- generate-structure.yaml
|
|
6
|
+
task_title: Generate the structure of the documentation
|
|
7
|
+
task_render_mode: collapse
|
|
8
|
+
reflection:
|
|
9
|
+
reviewer: check-document-structure.yaml
|
|
10
|
+
is_approved: isValid
|
|
11
|
+
max_iterations: 3
|
|
12
|
+
return_last_on_max_iterations: true
|
|
@@ -2,7 +2,7 @@ import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
|
2
2
|
import { dirname, join } from "node:path";
|
|
3
3
|
import chalk from "chalk";
|
|
4
4
|
import { stringify as yamlStringify } from "yaml";
|
|
5
|
-
import { getFilteredOptions } from "
|
|
5
|
+
import { getFilteredOptions } from "../../utils/conflict-detector.mjs";
|
|
6
6
|
import {
|
|
7
7
|
DEPTH_RECOMMENDATION_LOGIC,
|
|
8
8
|
DOCUMENT_STYLES,
|
|
@@ -11,14 +11,15 @@ import {
|
|
|
11
11
|
READER_KNOWLEDGE_LEVELS,
|
|
12
12
|
SUPPORTED_LANGUAGES,
|
|
13
13
|
TARGET_AUDIENCES,
|
|
14
|
-
} from "
|
|
14
|
+
} from "../../utils/constants.mjs";
|
|
15
|
+
import loadConfig from "../../utils/load-config.mjs";
|
|
15
16
|
import {
|
|
16
17
|
detectSystemLanguage,
|
|
17
18
|
getAvailablePaths,
|
|
18
19
|
getProjectInfo,
|
|
19
20
|
isGlobPattern,
|
|
20
21
|
validatePath,
|
|
21
|
-
} from "
|
|
22
|
+
} from "../../utils/utils.mjs";
|
|
22
23
|
|
|
23
24
|
// UI constants
|
|
24
25
|
const _PRESS_ENTER_TO_FINISH = "Press Enter to finish";
|
|
@@ -31,7 +32,7 @@ const _PRESS_ENTER_TO_FINISH = "Press Enter to finish";
|
|
|
31
32
|
* @returns {Promise<Object>}
|
|
32
33
|
*/
|
|
33
34
|
export default async function init(
|
|
34
|
-
{ outputPath = ".aigne/doc-smith", fileName = "config.yaml", skipIfExists = false },
|
|
35
|
+
{ outputPath = ".aigne/doc-smith", fileName = "config.yaml", skipIfExists = false, appUrl },
|
|
35
36
|
options,
|
|
36
37
|
) {
|
|
37
38
|
if (skipIfExists) {
|
|
@@ -39,7 +40,8 @@ export default async function init(
|
|
|
39
40
|
const configContent = await readFile(filePath, "utf8").catch(() => null);
|
|
40
41
|
// Only skip if file exists AND has non-empty content
|
|
41
42
|
if (configContent && configContent.trim() !== "") {
|
|
42
|
-
|
|
43
|
+
// load config from file
|
|
44
|
+
return loadConfig({ config: filePath, appUrl });
|
|
43
45
|
}
|
|
44
46
|
}
|
|
45
47
|
|
|
@@ -340,6 +342,11 @@ export default async function init(
|
|
|
340
342
|
console.log("💡 You can edit the configuration file anytime to modify settings.\n");
|
|
341
343
|
console.log(`🚀 Ready to generate docs? Run: ${chalk.cyan("aigne doc generate")}\n`);
|
|
342
344
|
|
|
345
|
+
// load config from file
|
|
346
|
+
if (skipIfExists) {
|
|
347
|
+
return loadConfig({ config: filePath, appUrl });
|
|
348
|
+
}
|
|
349
|
+
|
|
343
350
|
return {};
|
|
344
351
|
} catch (error) {
|
|
345
352
|
console.error(`❌ Failed to save configuration file: ${error.message}`);
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { basename, join } from "node:path";
|
|
2
|
+
|
|
2
3
|
import { publishDocs as publishDocsFn } from "@aigne/publish-docs";
|
|
3
4
|
import chalk from "chalk";
|
|
4
5
|
import fs from "fs-extra";
|
|
5
6
|
|
|
6
|
-
import { getAccessToken } from "
|
|
7
|
-
import { DISCUSS_KIT_STORE_URL, TMP_DIR, TMP_DOCS_DIR } from "
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { getGithubRepoUrl, loadConfigFromFile, saveValueToConfig } from "
|
|
7
|
+
import { getAccessToken } from "../../utils/auth-utils.mjs";
|
|
8
|
+
import { DISCUSS_KIT_STORE_URL, TMP_DIR, TMP_DOCS_DIR } from "../../utils/constants.mjs";
|
|
9
|
+
import { beforePublishHook, ensureTmpDir } from "../../utils/d2-utils.mjs";
|
|
10
|
+
import { deploy } from "../../utils/deploy.mjs";
|
|
11
|
+
import { getGithubRepoUrl, loadConfigFromFile, saveValueToConfig } from "../../utils/utils.mjs";
|
|
11
12
|
|
|
12
13
|
const DEFAULT_APP_URL = "https://docsmith.aigne.io";
|
|
13
14
|
|
|
@@ -8,7 +8,7 @@ items:
|
|
|
8
8
|
type: string
|
|
9
9
|
path:
|
|
10
10
|
type: string
|
|
11
|
-
description:
|
|
11
|
+
description: Path in URL format, cannot be empty, must start with /, no need to include language level, e.g., /zh/about should return /about
|
|
12
12
|
parentId:
|
|
13
13
|
type:
|
|
14
14
|
- string
|
|
@@ -20,12 +20,12 @@ items:
|
|
|
20
20
|
properties:
|
|
21
21
|
language:
|
|
22
22
|
type: string
|
|
23
|
-
description:
|
|
23
|
+
description: Language code, such as zh, en, ja, etc.
|
|
24
24
|
sourceIds:
|
|
25
25
|
type: array
|
|
26
26
|
items:
|
|
27
27
|
type: string
|
|
28
|
-
description:
|
|
28
|
+
description: Associated sourceId from dataSources for subsequent translation and content generation, must come from sourceId in datasources, cannot have fake ids, cannot be empty
|
|
29
29
|
required:
|
|
30
30
|
- title
|
|
31
31
|
- description
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
type: array
|
|
2
|
+
items:
|
|
3
|
+
type: object
|
|
4
|
+
properties:
|
|
5
|
+
title:
|
|
6
|
+
type: string
|
|
7
|
+
description:
|
|
8
|
+
type: string
|
|
9
|
+
path:
|
|
10
|
+
type: string
|
|
11
|
+
description: Path in URL format, cannot be empty, cannot contain spaces or special characters, must start with /, no need to include language level, e.g., /zh/about should return /about
|
|
12
|
+
parentId:
|
|
13
|
+
type:
|
|
14
|
+
- string
|
|
15
|
+
- "null"
|
|
16
|
+
description: Parent node path, if null indicates it is a top-level node
|
|
17
|
+
sourceIds:
|
|
18
|
+
type: array
|
|
19
|
+
description: Associated sourceId from dataSources for subsequent translation and content generation, must come from sourceId in datasources, cannot have fake ids, **cannot be empty**
|
|
20
|
+
items:
|
|
21
|
+
type: string
|
|
22
|
+
required:
|
|
23
|
+
- title
|
|
24
|
+
- description
|
|
25
|
+
- path
|
|
26
|
+
- sourceIds
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { SUPPORTED_LANGUAGES } from "
|
|
2
|
-
import { loadConfigFromFile, saveValueToConfig } from "
|
|
1
|
+
import { SUPPORTED_LANGUAGES } from "../../utils/constants.mjs";
|
|
2
|
+
import { loadConfigFromFile, saveValueToConfig } from "../../utils/utils.mjs";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Interactive language selector for translation from configured languages
|
|
@@ -9,7 +9,7 @@ import { loadConfigFromFile, saveValueToConfig } from "../utils/utils.mjs";
|
|
|
9
9
|
* @param {Object} options - Options object with prompts
|
|
10
10
|
* @returns {Promise<Object>} Selected languages
|
|
11
11
|
*/
|
|
12
|
-
export default async function
|
|
12
|
+
export default async function chooseLanguage({ langs, locale, selectedDocs }, options) {
|
|
13
13
|
let selectedLanguages = [];
|
|
14
14
|
|
|
15
15
|
// Load existing config to get current translation languages
|
|
@@ -19,7 +19,7 @@ export default async function languageSelector({ langs, locale, selectedDocs },
|
|
|
19
19
|
// Get primary language from config or parameter
|
|
20
20
|
const primaryLanguage = locale || existingConfig?.locale || "en";
|
|
21
21
|
|
|
22
|
-
// Filter out the primary language from available choices (like
|
|
22
|
+
// Filter out the primary language from available choices (like init.mjs)
|
|
23
23
|
const availableTranslationLanguages = SUPPORTED_LANGUAGES.filter(
|
|
24
24
|
(lang) => lang.code !== primaryLanguage,
|
|
25
25
|
);
|
|
@@ -90,7 +90,7 @@ export default async function languageSelector({ langs, locale, selectedDocs },
|
|
|
90
90
|
};
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
|
|
93
|
+
chooseLanguage.input_schema = {
|
|
94
94
|
type: "object",
|
|
95
95
|
properties: {
|
|
96
96
|
langs: {
|
|
@@ -2,19 +2,18 @@ type: team
|
|
|
2
2
|
name: translate
|
|
3
3
|
description: Translate documents into other languages
|
|
4
4
|
skills:
|
|
5
|
-
- url:
|
|
5
|
+
- url: ../init/index.mjs
|
|
6
6
|
default_input:
|
|
7
7
|
skipIfExists: true
|
|
8
|
-
-
|
|
9
|
-
- ./load-sources.mjs
|
|
8
|
+
- ../utils/load-sources.mjs
|
|
10
9
|
- type: transform
|
|
11
10
|
task_render_mode: hide
|
|
12
11
|
jsonata: |
|
|
13
12
|
$merge([
|
|
14
13
|
$,
|
|
15
14
|
{
|
|
16
|
-
'
|
|
17
|
-
'
|
|
15
|
+
'documentStructure': originalDocumentStructure,
|
|
16
|
+
'documentExecutionStructure': $map(originalDocumentStructure, function($item) {
|
|
18
17
|
$merge([
|
|
19
18
|
$item,
|
|
20
19
|
{
|
|
@@ -24,23 +23,23 @@ skills:
|
|
|
24
23
|
})
|
|
25
24
|
}
|
|
26
25
|
])
|
|
27
|
-
- url:
|
|
26
|
+
- url: ../utils/choose-docs.mjs
|
|
28
27
|
default_input:
|
|
29
28
|
isTranslate: true
|
|
30
|
-
-
|
|
29
|
+
- ../translate/choose-language.mjs
|
|
31
30
|
- type: team
|
|
32
|
-
name:
|
|
31
|
+
name: batchTranslateDocument
|
|
33
32
|
skills:
|
|
34
|
-
-
|
|
35
|
-
- url:
|
|
33
|
+
- ../translate/translate-multilingual.yaml
|
|
34
|
+
- url: ../utils/save-single-doc.mjs
|
|
36
35
|
default_input:
|
|
37
36
|
isTranslate: true
|
|
38
37
|
iterate_on: selectedDocs
|
|
39
38
|
concurrency: 3
|
|
40
|
-
- url:
|
|
39
|
+
- url: ../utils/check-feedback-refiner.mjs
|
|
41
40
|
default_input:
|
|
42
41
|
stage: translation_refine
|
|
43
|
-
- url:
|
|
42
|
+
- url: ../utils/action-success.mjs
|
|
44
43
|
default_input:
|
|
45
44
|
action: "✅ Translation completed"
|
|
46
45
|
input_schema:
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
name:
|
|
1
|
+
name: translateDocument
|
|
2
2
|
description: Translate content to another language
|
|
3
3
|
instructions:
|
|
4
|
-
url:
|
|
4
|
+
url: ../../prompts/translate/translate-document.md
|
|
5
|
+
task_render_mode: collapse
|
|
5
6
|
input_schema:
|
|
6
7
|
type: object
|
|
7
8
|
properties:
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
type: team
|
|
2
|
-
name:
|
|
3
|
-
description:
|
|
2
|
+
name: translateMultilingual
|
|
3
|
+
description: Batch translate documents to multiple languages
|
|
4
4
|
skills:
|
|
5
5
|
- type: team
|
|
6
6
|
task_render_mode: collapse
|
|
7
7
|
name: translate
|
|
8
8
|
skills:
|
|
9
|
-
- url:
|
|
9
|
+
- url: ../utils/find-user-preferences-by-path.mjs
|
|
10
10
|
default_input:
|
|
11
11
|
scope: translation
|
|
12
|
-
-
|
|
12
|
+
- ../translate/translate-document.yaml
|
|
13
13
|
- type: transform
|
|
14
14
|
jsonata: |
|
|
15
15
|
$merge([
|
|
@@ -17,7 +17,7 @@ skills:
|
|
|
17
17
|
{ "reviewContent": translation }
|
|
18
18
|
])
|
|
19
19
|
reflection:
|
|
20
|
-
reviewer:
|
|
20
|
+
reviewer: ../utils/check-detail-result.mjs
|
|
21
21
|
is_approved: isApproved
|
|
22
22
|
max_iterations: 5
|
|
23
23
|
return_last_on_max_iterations: true
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
type: team
|
|
2
|
+
name: batchGenerateDocument
|
|
3
|
+
description: Batch generate document details
|
|
4
|
+
skills:
|
|
5
|
+
- ./check-document.mjs
|
|
6
|
+
input_schema:
|
|
7
|
+
type: object
|
|
8
|
+
properties:
|
|
9
|
+
datasources:
|
|
10
|
+
type: string
|
|
11
|
+
description: Context for document structure generation, used to assist generate document structure
|
|
12
|
+
documentExecutionStructure: ../schema/document-execution-structure.yaml
|
|
13
|
+
modifiedFiles:
|
|
14
|
+
type: array
|
|
15
|
+
items: { type: string }
|
|
16
|
+
description: Array of modified files since last generation
|
|
17
|
+
iterate_on: documentExecutionStructure
|
|
18
|
+
concurrency: 3
|
|
19
|
+
mode: sequential
|