@aigne/doc-smith 0.9.10 → 0.9.11-beta
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 +12 -0
- package/README.md +189 -219
- package/README.zh.md +270 -0
- package/agents/bash-executor/index.mjs +347 -0
- package/agents/clear/ai/intent.md +142 -0
- package/agents/clear/choose-contents.mjs +13 -65
- package/agents/clear/clear-auth-tokens.mjs +17 -21
- package/agents/clear/clear-deployment-config.mjs +33 -24
- package/agents/clear/index.yaml +1 -9
- package/agents/content-checker/ai/intent.md +209 -0
- package/agents/content-checker/clean-invalid-docs.mjs +254 -0
- package/agents/content-checker/index.mjs +191 -0
- package/agents/content-checker/validate-content.mjs +983 -0
- package/agents/generate-images/generate-image.yaml +75 -0
- package/agents/generate-images/generate-summary.mjs +213 -0
- package/agents/generate-images/index.yaml +39 -0
- package/agents/generate-images/prepare-generation.mjs +286 -0
- package/agents/generate-images/prepare-image-generation.mjs +130 -0
- package/{prompts/detail/diagram/generate-image-system.md → agents/generate-images/prompts/system.md} +22 -56
- package/agents/generate-images/prompts/user.md +85 -0
- package/agents/generate-images/save-image-result.mjs +247 -0
- package/agents/generate-images/scan-image-slots.mjs +247 -0
- package/agents/localize/index.yaml +19 -42
- package/{prompts/translate → agents/localize/prompts}/translate-document.md +0 -139
- package/agents/localize/translate-documents/generate-summary.mjs +163 -0
- package/agents/localize/translate-documents/load-glossary.mjs +52 -0
- package/agents/localize/translate-documents/prepare-translation.mjs +249 -0
- package/agents/localize/translate-documents/save-translation.mjs +171 -0
- package/agents/localize/translate-documents/translate-document-to-language.mjs +209 -0
- package/agents/localize/translate-documents/translate-document.yaml +23 -0
- package/agents/localize/translate-documents/translate-to-languages.yaml +10 -0
- package/agents/localize/translate-images/check-image-translation.mjs +225 -0
- package/agents/localize/translate-images/detect-text/detect-and-update-shared.mjs +148 -0
- package/agents/localize/translate-images/detect-text/detect-image-text.yaml +44 -0
- package/agents/localize/translate-images/detect-text/detect-images-text.yaml +21 -0
- package/agents/localize/translate-images/detect-text/prompts/detect-image-text-system.md +43 -0
- package/agents/localize/translate-images/detect-text/prompts/detect-image-text-user.md +14 -0
- package/agents/localize/translate-images/detect-text/save-text-detection.mjs +105 -0
- package/agents/localize/translate-images/prepare-image-input.mjs +124 -0
- package/agents/localize/translate-images/save-image-translation.mjs +172 -0
- package/agents/localize/translate-images/scan-doc-images.mjs +165 -0
- package/agents/localize/translate-images/translate-doc-images.yaml +24 -0
- package/agents/localize/{translate-diagram.yaml → translate-images/translate-image.yaml} +25 -14
- package/agents/publish/ai/intent.md +182 -0
- package/agents/publish/check.mjs +107 -0
- package/agents/publish/index.yaml +9 -14
- package/agents/publish/publish-docs.mjs +81 -61
- package/agents/publish/translate-meta.mjs +79 -58
- package/agents/save-document/index.mjs +260 -0
- package/agents/structure-checker/index.mjs +307 -0
- package/agents/structure-checker/validate-structure.mjs +477 -0
- package/agents/update-image/analyze-feedback.yaml +37 -0
- package/agents/update-image/index.yaml +78 -0
- package/agents/update-image/load-existing-image.mjs +211 -0
- package/agents/update-image/prompts/analyze-feedback-system.md +43 -0
- package/agents/update-image/prompts/analyze-feedback-user.md +15 -0
- package/aigne.yaml +26 -139
- package/package.json +16 -48
- package/scripts/README.md +90 -0
- package/scripts/install.sh +86 -0
- package/scripts/uninstall.sh +52 -0
- package/skills/doc-smith/SKILL.md +285 -0
- package/skills/doc-smith/ai/intent/sources-improve.md +290 -0
- package/skills/doc-smith/references/changeset-guide.md +171 -0
- package/skills/doc-smith/references/document-content-guide.md +214 -0
- package/skills/doc-smith/references/document-structure-schema.md +138 -0
- package/skills/doc-smith/references/patch-guide.md +96 -0
- package/skills/doc-smith/references/structure-confirmation-guide.md +133 -0
- package/skills/doc-smith/references/structure-planning-guide.md +149 -0
- package/skills/doc-smith/references/update-workflow.md +108 -0
- package/skills/doc-smith/references/user-intent-guide.md +175 -0
- package/skills/doc-smith/references/workspace-initialization.md +376 -0
- package/skills/doc-smith-docs-detail/SKILL.md +356 -0
- package/skills/doc-smith-docs-detail/ai/intent.md +271 -0
- package/skills-entry/doc-smith/ai/intent.md +260 -0
- package/skills-entry/doc-smith/index.mjs +66 -0
- package/skills-entry/doc-smith/prompt.md +57 -0
- package/skills-entry/doc-smith/utils.mjs +27 -0
- package/skills-entry/doc-smith-docs-detail/batch.yaml +56 -0
- package/skills-entry/doc-smith-docs-detail/index.mjs +95 -0
- package/skills-entry/doc-smith-docs-detail/prompt.md +64 -0
- package/utils/afs-factory.mjs +183 -0
- package/utils/agent-constants.mjs +97 -0
- package/utils/{auth-utils.mjs → auth.mjs} +6 -9
- package/{agents/utils/update-branding.mjs → utils/branding.mjs} +3 -4
- package/utils/config.mjs +261 -0
- package/utils/constants.mjs +32 -0
- package/utils/deploy.mjs +3 -3
- package/utils/docs-converter.mjs +454 -0
- package/utils/docs.mjs +212 -0
- package/utils/document-paths.mjs +172 -0
- package/utils/files.mjs +74 -0
- package/utils/git.mjs +65 -0
- package/utils/{blocklet.mjs → http.mjs} +18 -0
- package/utils/image-slots.mjs +57 -0
- package/utils/image-utils.mjs +114 -0
- package/utils/project.mjs +95 -0
- package/utils/sources-path-resolver.mjs +76 -0
- package/utils/{upload-files.mjs → upload.mjs} +3 -3
- package/utils/workspace.mjs +371 -0
- package/agents/chat/chat-system.md +0 -38
- package/agents/chat/index.mjs +0 -59
- package/agents/chat/skills/generate-document.yaml +0 -15
- package/agents/chat/skills/list-documents.mjs +0 -15
- package/agents/chat/skills/update-document.yaml +0 -24
- package/agents/clear/clear-document-config.mjs +0 -36
- package/agents/clear/clear-document-structure.mjs +0 -102
- package/agents/clear/clear-generated-docs.mjs +0 -142
- package/agents/clear/clear-media-description.mjs +0 -129
- package/agents/create/aggregate-document-structure.mjs +0 -21
- package/agents/create/analyze-diagram-type-llm.yaml +0 -159
- package/agents/create/analyze-diagram-type.mjs +0 -455
- package/agents/create/check-document-structure.yaml +0 -30
- package/agents/create/check-need-generate-structure.mjs +0 -138
- package/agents/create/document-structure-tools/add-document.mjs +0 -85
- package/agents/create/document-structure-tools/delete-document.mjs +0 -116
- package/agents/create/document-structure-tools/move-document.mjs +0 -109
- package/agents/create/document-structure-tools/update-document.mjs +0 -84
- package/agents/create/generate-diagram-image.yaml +0 -91
- package/agents/create/generate-structure.yaml +0 -106
- package/agents/create/index.yaml +0 -45
- package/agents/create/refine-document-structure.yaml +0 -12
- package/agents/create/replace-d2-with-image.mjs +0 -610
- package/agents/create/update-document-structure.yaml +0 -54
- package/agents/create/user-add-document/add-documents-to-structure.mjs +0 -90
- package/agents/create/user-add-document/find-documents-to-add-links.yaml +0 -47
- package/agents/create/user-add-document/index.yaml +0 -46
- package/agents/create/user-add-document/prepare-documents-to-translate.mjs +0 -22
- package/agents/create/user-add-document/print-add-document-summary.mjs +0 -63
- package/agents/create/user-add-document/review-documents-with-new-links.mjs +0 -110
- package/agents/create/user-remove-document/find-documents-with-invalid-links.mjs +0 -78
- package/agents/create/user-remove-document/index.yaml +0 -40
- package/agents/create/user-remove-document/prepare-documents-to-translate.mjs +0 -22
- package/agents/create/user-remove-document/print-remove-document-summary.mjs +0 -53
- package/agents/create/user-remove-document/remove-documents-from-structure.mjs +0 -99
- package/agents/create/user-remove-document/review-documents-with-invalid-links.mjs +0 -115
- package/agents/create/user-review-document-structure.mjs +0 -139
- package/agents/create/utils/init-current-content.mjs +0 -34
- package/agents/create/utils/merge-document-structures.mjs +0 -36
- package/agents/evaluate/code-snippet.mjs +0 -97
- package/agents/evaluate/document-structure.yaml +0 -67
- package/agents/evaluate/document.yaml +0 -82
- package/agents/evaluate/generate-report.mjs +0 -85
- package/agents/evaluate/index.yaml +0 -46
- package/agents/history/index.yaml +0 -6
- package/agents/history/view.mjs +0 -78
- package/agents/init/check.mjs +0 -16
- package/agents/init/index.mjs +0 -643
- package/agents/init/validate.mjs +0 -16
- package/agents/localize/choose-language.mjs +0 -107
- package/agents/localize/record-translation-history.mjs +0 -23
- package/agents/localize/save-doc-translation-or-skip.mjs +0 -18
- package/agents/localize/set-review-content.mjs +0 -58
- package/agents/localize/translate-document-wrapper.mjs +0 -34
- package/agents/localize/translate-document.yaml +0 -24
- package/agents/localize/translate-multilingual.yaml +0 -57
- package/agents/localize/translate-or-skip-diagram.mjs +0 -52
- package/agents/media/batch-generate-media-description.yaml +0 -46
- package/agents/media/generate-media-description.yaml +0 -50
- package/agents/media/load-media-description.mjs +0 -454
- package/agents/prefs/index.mjs +0 -203
- package/agents/schema/document-structure-item.yaml +0 -26
- package/agents/schema/document-structure-refine-item.yaml +0 -23
- package/agents/schema/document-structure.yaml +0 -29
- package/agents/update/batch-generate-document.yaml +0 -27
- package/agents/update/batch-update-document.yaml +0 -7
- package/agents/update/check-diagram-flag.mjs +0 -116
- package/agents/update/check-document.mjs +0 -162
- package/agents/update/check-generate-diagram.mjs +0 -106
- package/agents/update/check-update-is-single.mjs +0 -53
- package/agents/update/document-tools/update-document-content.mjs +0 -303
- package/agents/update/generate-diagram.yaml +0 -80
- package/agents/update/generate-document.yaml +0 -70
- package/agents/update/handle-document-update.yaml +0 -103
- package/agents/update/index.yaml +0 -69
- package/agents/update/pre-check-generate-diagram.yaml +0 -44
- package/agents/update/save-and-translate-document.mjs +0 -80
- package/agents/update/update-document-detail.yaml +0 -71
- package/agents/update/update-single/update-single-document-detail.mjs +0 -322
- package/agents/update/update-single-document.yaml +0 -7
- package/agents/update/user-review-document.mjs +0 -272
- package/agents/utils/action-success.mjs +0 -16
- package/agents/utils/analyze-document-feedback-intent.yaml +0 -32
- package/agents/utils/analyze-feedback-intent.mjs +0 -253
- package/agents/utils/analyze-structure-feedback-intent.yaml +0 -29
- package/agents/utils/check-detail-result.mjs +0 -51
- package/agents/utils/check-feedback-refiner.mjs +0 -81
- package/agents/utils/choose-docs.mjs +0 -251
- package/agents/utils/document-icon-generate.yaml +0 -52
- package/agents/utils/document-title-streamline.yaml +0 -48
- package/agents/utils/ensure-document-icons.mjs +0 -129
- package/agents/utils/exit.mjs +0 -6
- package/agents/utils/feedback-refiner.yaml +0 -50
- package/agents/utils/find-item-by-path.mjs +0 -114
- package/agents/utils/find-user-preferences-by-path.mjs +0 -37
- package/agents/utils/format-document-structure.mjs +0 -35
- package/agents/utils/generate-document-or-skip.mjs +0 -41
- package/agents/utils/handle-diagram-operations.mjs +0 -263
- package/agents/utils/load-all-document-content.mjs +0 -30
- package/agents/utils/load-document-all-content.mjs +0 -96
- package/agents/utils/load-sources.mjs +0 -405
- package/agents/utils/map-reasoning-effort-level.mjs +0 -15
- package/agents/utils/post-generate.mjs +0 -133
- package/agents/utils/read-current-document-content.mjs +0 -46
- package/agents/utils/save-doc-translation.mjs +0 -30
- package/agents/utils/save-doc.mjs +0 -54
- package/agents/utils/save-output.mjs +0 -26
- package/agents/utils/save-sidebar.mjs +0 -38
- package/agents/utils/skip-if-content-exists.mjs +0 -27
- package/agents/utils/streamline-document-titles-if-needed.mjs +0 -88
- package/agents/utils/transform-detail-data-sources.mjs +0 -45
- package/assets/report-template/report.html +0 -198
- package/docs-mcp/analyze-content-relevance.yaml +0 -50
- package/docs-mcp/analyze-docs-relevance.yaml +0 -59
- package/docs-mcp/docs-search.yaml +0 -42
- package/docs-mcp/get-docs-detail.mjs +0 -41
- package/docs-mcp/get-docs-structure.mjs +0 -16
- package/docs-mcp/read-doc-content.mjs +0 -119
- package/prompts/common/document/content-rules-core.md +0 -20
- package/prompts/common/document/markdown-syntax-rules.md +0 -65
- package/prompts/common/document/media-file-list-usage-rules.md +0 -18
- package/prompts/common/document/openapi-usage-rules.md +0 -189
- package/prompts/common/document/role-and-personality.md +0 -16
- package/prompts/common/document/user-preferences.md +0 -9
- package/prompts/common/document-structure/conflict-resolution-guidance.md +0 -16
- package/prompts/common/document-structure/document-icon-generate.md +0 -116
- package/prompts/common/document-structure/document-structure-rules.md +0 -43
- package/prompts/common/document-structure/document-title-streamline.md +0 -86
- package/prompts/common/document-structure/glossary.md +0 -7
- package/prompts/common/document-structure/intj-traits.md +0 -5
- package/prompts/common/document-structure/openapi-usage-rules.md +0 -28
- package/prompts/common/document-structure/output-constraints.md +0 -18
- package/prompts/common/document-structure/user-locale-rules.md +0 -10
- package/prompts/common/document-structure/user-preferences.md +0 -9
- package/prompts/detail/custom/admonition-usage-rules.md +0 -94
- package/prompts/detail/custom/code-block-usage-rules.md +0 -163
- package/prompts/detail/custom/custom-components/x-card-usage-rules.md +0 -63
- package/prompts/detail/custom/custom-components/x-cards-usage-rules.md +0 -83
- package/prompts/detail/custom/custom-components/x-field-desc-usage-rules.md +0 -120
- package/prompts/detail/custom/custom-components/x-field-group-usage-rules.md +0 -80
- package/prompts/detail/custom/custom-components/x-field-usage-rules.md +0 -189
- package/prompts/detail/custom/custom-components-usage-rules.md +0 -18
- package/prompts/detail/diagram/generate-image-user.md +0 -81
- package/prompts/detail/diagram/guide.md +0 -29
- package/prompts/detail/diagram/official-examples.md +0 -712
- package/prompts/detail/diagram/pre-check.md +0 -23
- package/prompts/detail/diagram/role-and-personality.md +0 -2
- package/prompts/detail/diagram/rules.md +0 -46
- package/prompts/detail/diagram/system-prompt.md +0 -1139
- package/prompts/detail/diagram/user-prompt.md +0 -43
- package/prompts/detail/generate/detail-example.md +0 -457
- package/prompts/detail/generate/document-rules.md +0 -45
- package/prompts/detail/generate/system-prompt.md +0 -61
- package/prompts/detail/generate/user-prompt.md +0 -99
- package/prompts/detail/jsx/rules.md +0 -6
- package/prompts/detail/update/system-prompt.md +0 -121
- package/prompts/detail/update/user-prompt.md +0 -41
- package/prompts/evaluate/document-structure.md +0 -93
- package/prompts/evaluate/document.md +0 -149
- package/prompts/media/media-description/system-prompt.md +0 -43
- package/prompts/media/media-description/user-prompt.md +0 -17
- package/prompts/structure/check-document-structure.md +0 -93
- package/prompts/structure/document-rules.md +0 -21
- package/prompts/structure/find-documents-to-add-links.md +0 -52
- package/prompts/structure/generate/system-prompt.md +0 -13
- package/prompts/structure/generate/user-prompt.md +0 -137
- package/prompts/structure/review/structure-review-system.md +0 -81
- package/prompts/structure/structure-example.md +0 -89
- package/prompts/structure/structure-getting-started.md +0 -10
- package/prompts/structure/update/system-prompt.md +0 -93
- package/prompts/structure/update/user-prompt.md +0 -43
- package/prompts/translate/admonition.md +0 -20
- package/prompts/translate/code-block.md +0 -33
- package/prompts/utils/analyze-document-feedback-intent.md +0 -54
- package/prompts/utils/analyze-structure-feedback-intent.md +0 -43
- package/prompts/utils/feedback-refiner.md +0 -105
- package/types/document-schema.mjs +0 -55
- package/types/document-structure-schema.mjs +0 -261
- package/utils/check-document-has-diagram.mjs +0 -95
- package/utils/conflict-detector.mjs +0 -149
- package/utils/constants/index.mjs +0 -620
- package/utils/constants/linter.mjs +0 -102
- package/utils/d2-utils.mjs +0 -205
- package/utils/debug.mjs +0 -3
- package/utils/delete-diagram-images.mjs +0 -99
- package/utils/diagram-version-utils.mjs +0 -14
- package/utils/docs-finder-utils.mjs +0 -548
- package/utils/evaluate/report-utils.mjs +0 -132
- package/utils/extract-api.mjs +0 -32
- package/utils/file-utils.mjs +0 -960
- package/utils/history-utils.mjs +0 -203
- package/utils/icon-map.mjs +0 -26
- package/utils/image-compress.mjs +0 -154
- package/utils/kroki-utils.mjs +0 -173
- package/utils/linter/index.mjs +0 -50
- package/utils/load-config.mjs +0 -78
- package/utils/markdown/index.mjs +0 -26
- package/utils/markdown-checker.mjs +0 -694
- package/utils/mermaid-validator.mjs +0 -140
- package/utils/mermaid-worker-pool.mjs +0 -250
- package/utils/mermaid-worker.mjs +0 -233
- package/utils/openapi/index.mjs +0 -28
- package/utils/preferences-utils.mjs +0 -175
- package/utils/request.mjs +0 -10
- package/utils/sync-diagram-to-translations.mjs +0 -272
- package/utils/translate-diagram-images.mjs +0 -807
- package/utils/utils.mjs +0 -1354
- /package/{prompts/translate → agents/localize/prompts}/glossary.md +0 -0
|
@@ -1,405 +0,0 @@
|
|
|
1
|
-
import { statSync } from "node:fs";
|
|
2
|
-
import { readFile } from "node:fs/promises";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
import imageSize from "image-size";
|
|
5
|
-
import {
|
|
6
|
-
DEFAULT_EXCLUDE_PATTERNS,
|
|
7
|
-
DEFAULT_INCLUDE_PATTERNS,
|
|
8
|
-
INTELLIGENT_SUGGESTION_TOKEN_THRESHOLD,
|
|
9
|
-
} from "../../utils/constants/index.mjs";
|
|
10
|
-
import { loadDocumentStructure } from "../../utils/docs-finder-utils.mjs";
|
|
11
|
-
import {
|
|
12
|
-
buildSourcesContent,
|
|
13
|
-
calculateTokens,
|
|
14
|
-
getMimeType,
|
|
15
|
-
isRemoteFile,
|
|
16
|
-
loadFilesFromPaths,
|
|
17
|
-
readFileContents,
|
|
18
|
-
} from "../../utils/file-utils.mjs";
|
|
19
|
-
import { isOpenAPISpecFile } from "../../utils/openapi/index.mjs";
|
|
20
|
-
import {
|
|
21
|
-
getCurrentGitHead,
|
|
22
|
-
getModifiedFilesBetweenCommits,
|
|
23
|
-
toRelativePath,
|
|
24
|
-
} from "../../utils/utils.mjs";
|
|
25
|
-
|
|
26
|
-
const imageExts = [".jpg", ".jpeg", ".png", ".gif", ".bmp", ".webp", ".svg", ".heic", ".heif"];
|
|
27
|
-
const videoExts = [
|
|
28
|
-
".mp4",
|
|
29
|
-
".mpeg",
|
|
30
|
-
".mpg",
|
|
31
|
-
".mov",
|
|
32
|
-
".avi",
|
|
33
|
-
".flv",
|
|
34
|
-
".mkv",
|
|
35
|
-
".webm",
|
|
36
|
-
".wmv",
|
|
37
|
-
".m4v",
|
|
38
|
-
".3gpp",
|
|
39
|
-
];
|
|
40
|
-
|
|
41
|
-
export default async function loadSources(
|
|
42
|
-
{
|
|
43
|
-
sources = [],
|
|
44
|
-
sourcesPath = [],
|
|
45
|
-
includePatterns,
|
|
46
|
-
excludePatterns,
|
|
47
|
-
outputDir,
|
|
48
|
-
docsDir,
|
|
49
|
-
"doc-path": docPath,
|
|
50
|
-
boardId,
|
|
51
|
-
useDefaultPatterns = true,
|
|
52
|
-
lastGitHead,
|
|
53
|
-
reset = false,
|
|
54
|
-
media,
|
|
55
|
-
} = {},
|
|
56
|
-
options,
|
|
57
|
-
) {
|
|
58
|
-
let files = Array.isArray(sources) ? [...sources] : [];
|
|
59
|
-
const { minImageWidth } = media || { minImageWidth: 800 };
|
|
60
|
-
|
|
61
|
-
if (sourcesPath) {
|
|
62
|
-
const sourcesPathList = Array.isArray(sourcesPath) ? sourcesPath : [sourcesPath];
|
|
63
|
-
const pickSourcesPath = [];
|
|
64
|
-
const omitSourcesPath = [];
|
|
65
|
-
sourcesPathList.forEach((x) => {
|
|
66
|
-
if (typeof x !== "string" || !x) {
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
if (x.startsWith("!")) {
|
|
70
|
-
omitSourcesPath.push(x.substring(1));
|
|
71
|
-
} else {
|
|
72
|
-
pickSourcesPath.push(x);
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
const customExcludePatterns = omitSourcesPath
|
|
77
|
-
.map((x) => {
|
|
78
|
-
try {
|
|
79
|
-
const stats = statSync(x);
|
|
80
|
-
if (stats.isFile()) {
|
|
81
|
-
return x;
|
|
82
|
-
}
|
|
83
|
-
if (stats.isDirectory()) {
|
|
84
|
-
return `${x}/**`;
|
|
85
|
-
}
|
|
86
|
-
return null;
|
|
87
|
-
} catch (error) {
|
|
88
|
-
console.warn(`Failed to stat path ${x}: ${error.message}`);
|
|
89
|
-
return null;
|
|
90
|
-
}
|
|
91
|
-
})
|
|
92
|
-
.filter(Boolean);
|
|
93
|
-
const allFiles = await loadFilesFromPaths(pickSourcesPath, {
|
|
94
|
-
includePatterns,
|
|
95
|
-
excludePatterns: [
|
|
96
|
-
...new Set([
|
|
97
|
-
...(excludePatterns || []),
|
|
98
|
-
...customExcludePatterns,
|
|
99
|
-
...videoExts.map((x) => `**/*${x}`),
|
|
100
|
-
]),
|
|
101
|
-
],
|
|
102
|
-
useDefaultPatterns,
|
|
103
|
-
defaultIncludePatterns: DEFAULT_INCLUDE_PATTERNS,
|
|
104
|
-
defaultExcludePatterns: DEFAULT_EXCLUDE_PATTERNS,
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
files = files.concat(allFiles);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
files = [...new Set(files)];
|
|
111
|
-
|
|
112
|
-
// Define media file extensions
|
|
113
|
-
const mediaExtensions = [
|
|
114
|
-
...imageExts,
|
|
115
|
-
// ignore video temporary
|
|
116
|
-
// ...videoExts
|
|
117
|
-
];
|
|
118
|
-
|
|
119
|
-
// Separate source files from media files
|
|
120
|
-
const sourceFilesPaths = [];
|
|
121
|
-
const mediaFiles = [];
|
|
122
|
-
|
|
123
|
-
// Helper function to determine file type from extension
|
|
124
|
-
const getFileType = (filePath) => {
|
|
125
|
-
const ext = path.extname(filePath).toLowerCase();
|
|
126
|
-
|
|
127
|
-
if (imageExts.includes(ext)) return "image";
|
|
128
|
-
if (videoExts.includes(ext)) return "video";
|
|
129
|
-
return "media";
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
let filteredImageCount = 0;
|
|
133
|
-
|
|
134
|
-
await Promise.all(
|
|
135
|
-
files.map(async (file) => {
|
|
136
|
-
const ext = path.extname(file).toLowerCase();
|
|
137
|
-
|
|
138
|
-
if (mediaExtensions.includes(ext) && !isRemoteFile(file)) {
|
|
139
|
-
// This is a media file
|
|
140
|
-
const relativePath = path.relative(docsDir, file);
|
|
141
|
-
const fileName = path.basename(file);
|
|
142
|
-
const description = path.parse(fileName).name;
|
|
143
|
-
|
|
144
|
-
const mediaItem = {
|
|
145
|
-
name: fileName,
|
|
146
|
-
path: relativePath,
|
|
147
|
-
type: getFileType(relativePath),
|
|
148
|
-
description,
|
|
149
|
-
mimeType: getMimeType(file),
|
|
150
|
-
};
|
|
151
|
-
|
|
152
|
-
// For image files, get dimensions and filter by width
|
|
153
|
-
if (mediaItem.type === "image") {
|
|
154
|
-
try {
|
|
155
|
-
const buffer = await readFile(file);
|
|
156
|
-
const dimensions = imageSize(buffer);
|
|
157
|
-
mediaItem.width = dimensions.width;
|
|
158
|
-
mediaItem.height = dimensions.height;
|
|
159
|
-
|
|
160
|
-
// Filter out images with width less than minImageWidth, but not SVG images
|
|
161
|
-
if (dimensions.width < minImageWidth && mediaItem.mimeType !== "image/svg+xml") {
|
|
162
|
-
filteredImageCount++;
|
|
163
|
-
console.log(
|
|
164
|
-
`Ignored image: ${fileName} (${dimensions.width}x${dimensions.height}px < ${minImageWidth}px minimum)`,
|
|
165
|
-
);
|
|
166
|
-
return;
|
|
167
|
-
}
|
|
168
|
-
} catch (err) {
|
|
169
|
-
console.warn(`⚠️ Failed to get dimensions for ${fileName}: ${err.message}`);
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
mediaFiles.push(mediaItem);
|
|
174
|
-
} else {
|
|
175
|
-
// This is a source file
|
|
176
|
-
sourceFilesPaths.push(file);
|
|
177
|
-
}
|
|
178
|
-
}),
|
|
179
|
-
);
|
|
180
|
-
|
|
181
|
-
// Log summary of filtered images
|
|
182
|
-
if (filteredImageCount > 0) {
|
|
183
|
-
console.log(
|
|
184
|
-
`\nTotal ${filteredImageCount} low-resolution image(s) filtered for better documentation quality (minimum width: ${minImageWidth}px)\n`,
|
|
185
|
-
);
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
// Read all source files using the utility function
|
|
189
|
-
let sourceFiles = (await readFileContents(sourceFilesPaths, process.cwd())).map((i) => ({
|
|
190
|
-
...i,
|
|
191
|
-
tokens: calculateTokens(`\n${i.sourceId}\n${i.content}`),
|
|
192
|
-
}));
|
|
193
|
-
|
|
194
|
-
// filter OpenAPI doc should after check isLargeContext
|
|
195
|
-
sourceFiles = sourceFiles.filter((file) => {
|
|
196
|
-
if (options?.context?.userContext.openAPISpec) return true;
|
|
197
|
-
|
|
198
|
-
const isOpenAPI = isOpenAPISpecFile(file.content);
|
|
199
|
-
if (isOpenAPI && options?.context?.userContext) {
|
|
200
|
-
options.context.userContext.openAPISpec = file;
|
|
201
|
-
}
|
|
202
|
-
return !isOpenAPI;
|
|
203
|
-
});
|
|
204
|
-
|
|
205
|
-
const totalTokens = sourceFiles.reduce((sum, file) => sum + file.tokens, 0);
|
|
206
|
-
const totalLines = sourceFiles.reduce(
|
|
207
|
-
(sum, file) => sum + file.content.split("\n").filter(Boolean).length,
|
|
208
|
-
0,
|
|
209
|
-
);
|
|
210
|
-
|
|
211
|
-
const dataSources = splitSourcesToChunks(sourceFiles, INTELLIGENT_SUGGESTION_TOKEN_THRESHOLD).map(
|
|
212
|
-
(i) => ({ dataSourceChunk: buildSourcesContent(i) }),
|
|
213
|
-
);
|
|
214
|
-
|
|
215
|
-
const remoteFileList = [];
|
|
216
|
-
|
|
217
|
-
sourceFiles.forEach((file) => {
|
|
218
|
-
if (isRemoteFile(file.sourceId)) {
|
|
219
|
-
remoteFileList.push(file);
|
|
220
|
-
}
|
|
221
|
-
});
|
|
222
|
-
if (options?.context?.userContext) {
|
|
223
|
-
options.context.userContext.remoteFileList = remoteFileList;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
// all files path
|
|
227
|
-
const allFilesPaths = sourceFiles.map((x) => `- ${toRelativePath(x.sourceId)}`).join("\n");
|
|
228
|
-
|
|
229
|
-
// Get the last documentation structure
|
|
230
|
-
const originalDocumentStructure = await loadDocumentStructure(outputDir);
|
|
231
|
-
|
|
232
|
-
// Get the last output result of the specified path
|
|
233
|
-
let content;
|
|
234
|
-
if (docPath && !reset && docsDir) {
|
|
235
|
-
// First try direct path matching (original format)
|
|
236
|
-
const flatName = docPath.replace(/^\//, "").replace(/\//g, "-");
|
|
237
|
-
const fileFullName = `${flatName}.md`;
|
|
238
|
-
let filePath = path.join(docsDir, fileFullName);
|
|
239
|
-
|
|
240
|
-
try {
|
|
241
|
-
content = await readFile(filePath, "utf8");
|
|
242
|
-
} catch (err) {
|
|
243
|
-
if (err.code !== "ENOENT") {
|
|
244
|
-
console.warn(`Error reading document file ${filePath}: ${err.message}`);
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
// If not found and boardId is provided, try boardId-flattenedPath format
|
|
248
|
-
if (boardId && docPath.startsWith(`${boardId}-`)) {
|
|
249
|
-
// Extract the flattened path part after boardId-
|
|
250
|
-
const flattenedPath = docPath.substring(boardId.length + 1);
|
|
251
|
-
const boardIdFileFullName = `${flattenedPath}.md`;
|
|
252
|
-
filePath = path.join(docsDir, boardIdFileFullName);
|
|
253
|
-
|
|
254
|
-
try {
|
|
255
|
-
content = await readFile(filePath, "utf8");
|
|
256
|
-
} catch (boardIdErr) {
|
|
257
|
-
if (boardIdErr.code !== "ENOENT") {
|
|
258
|
-
console.warn(`Error reading document file ${filePath}: ${boardIdErr.message}`);
|
|
259
|
-
}
|
|
260
|
-
// The file does not exist, content remains undefined
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
// Get git change detection data
|
|
267
|
-
let modifiedFiles = [];
|
|
268
|
-
let currentGitHead = null;
|
|
269
|
-
|
|
270
|
-
if (lastGitHead) {
|
|
271
|
-
try {
|
|
272
|
-
currentGitHead = getCurrentGitHead();
|
|
273
|
-
if (currentGitHead && currentGitHead !== lastGitHead) {
|
|
274
|
-
modifiedFiles = getModifiedFilesBetweenCommits(lastGitHead, currentGitHead);
|
|
275
|
-
console.log(`Detected ${modifiedFiles.length} modified files since last generation`);
|
|
276
|
-
}
|
|
277
|
-
} catch (error) {
|
|
278
|
-
console.warn("Failed to detect git changes:", error.message);
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
return {
|
|
283
|
-
dataSources,
|
|
284
|
-
content,
|
|
285
|
-
originalDocumentStructure,
|
|
286
|
-
files,
|
|
287
|
-
modifiedFiles,
|
|
288
|
-
totalTokens,
|
|
289
|
-
totalLines,
|
|
290
|
-
mediaFiles,
|
|
291
|
-
allFilesPaths,
|
|
292
|
-
};
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
loadSources.input_schema = {
|
|
296
|
-
type: "object",
|
|
297
|
-
properties: {
|
|
298
|
-
sources: {
|
|
299
|
-
type: "array",
|
|
300
|
-
items: { type: "string" },
|
|
301
|
-
description: "Array of paths to the sources files",
|
|
302
|
-
},
|
|
303
|
-
sourcesPath: {
|
|
304
|
-
anyOf: [{ type: "string" }, { type: "array", items: { type: "string" } }],
|
|
305
|
-
description: "Directory or directories to recursively read files from",
|
|
306
|
-
},
|
|
307
|
-
includePatterns: {
|
|
308
|
-
anyOf: [{ type: "string" }, { type: "array", items: { type: "string" } }],
|
|
309
|
-
description: "Glob patterns to filter files by path or filename. If not set, include all.",
|
|
310
|
-
},
|
|
311
|
-
excludePatterns: {
|
|
312
|
-
anyOf: [{ type: "string" }, { type: "array", items: { type: "string" } }],
|
|
313
|
-
description: "Glob patterns to exclude files by path or filename. If not set, exclude none.",
|
|
314
|
-
},
|
|
315
|
-
useDefaultPatterns: {
|
|
316
|
-
type: "boolean",
|
|
317
|
-
description: "Whether to use default include/exclude patterns. Defaults to true.",
|
|
318
|
-
},
|
|
319
|
-
"doc-path": {
|
|
320
|
-
type: "string",
|
|
321
|
-
description: "The document path to load content for",
|
|
322
|
-
},
|
|
323
|
-
boardId: {
|
|
324
|
-
type: "string",
|
|
325
|
-
description: "The board ID for boardId-flattenedPath format matching",
|
|
326
|
-
},
|
|
327
|
-
lastGitHead: {
|
|
328
|
-
type: "string",
|
|
329
|
-
description: "The git HEAD from last generation for change detection",
|
|
330
|
-
},
|
|
331
|
-
},
|
|
332
|
-
required: [],
|
|
333
|
-
};
|
|
334
|
-
|
|
335
|
-
loadSources.output_schema = {
|
|
336
|
-
type: "object",
|
|
337
|
-
properties: {
|
|
338
|
-
dataSources: {
|
|
339
|
-
type: "array",
|
|
340
|
-
items: {
|
|
341
|
-
type: "object",
|
|
342
|
-
properties: {
|
|
343
|
-
dataSourceChunk: { type: "string" },
|
|
344
|
-
},
|
|
345
|
-
},
|
|
346
|
-
},
|
|
347
|
-
files: {
|
|
348
|
-
type: "array",
|
|
349
|
-
items: { type: "string" },
|
|
350
|
-
description: "Array of file paths that were loaded",
|
|
351
|
-
},
|
|
352
|
-
modifiedFiles: {
|
|
353
|
-
type: "array",
|
|
354
|
-
items: { type: "string" },
|
|
355
|
-
description: "Array of modified files since last generation",
|
|
356
|
-
},
|
|
357
|
-
mediaFiles: {
|
|
358
|
-
type: "array",
|
|
359
|
-
items: {
|
|
360
|
-
type: "object",
|
|
361
|
-
properties: {
|
|
362
|
-
name: { type: "string" },
|
|
363
|
-
path: { type: "string" },
|
|
364
|
-
type: { type: "string" },
|
|
365
|
-
width: { type: "number" },
|
|
366
|
-
height: { type: "number" },
|
|
367
|
-
mimeType: { type: "string" },
|
|
368
|
-
},
|
|
369
|
-
},
|
|
370
|
-
description: "Array of media file objects (images/videos)",
|
|
371
|
-
},
|
|
372
|
-
},
|
|
373
|
-
};
|
|
374
|
-
|
|
375
|
-
loadSources.task_render_mode = "hide";
|
|
376
|
-
|
|
377
|
-
function splitSourcesToChunks(sources, maxTokens) {
|
|
378
|
-
const chunks = [];
|
|
379
|
-
|
|
380
|
-
let currentChunk = [];
|
|
381
|
-
let currentTokens = 0;
|
|
382
|
-
|
|
383
|
-
for (const source of sources) {
|
|
384
|
-
const sourceTokens = source.tokens;
|
|
385
|
-
|
|
386
|
-
if (currentTokens + sourceTokens > maxTokens) {
|
|
387
|
-
// Start a new chunk
|
|
388
|
-
if (currentChunk.length > 0) {
|
|
389
|
-
chunks.push(currentChunk);
|
|
390
|
-
}
|
|
391
|
-
currentChunk = [source];
|
|
392
|
-
currentTokens = sourceTokens;
|
|
393
|
-
} else {
|
|
394
|
-
// Add to current chunk
|
|
395
|
-
currentChunk.push(source);
|
|
396
|
-
currentTokens += sourceTokens;
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
if (currentChunk.length > 0) {
|
|
401
|
-
chunks.push(currentChunk);
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
return chunks;
|
|
405
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
DEFAULT_REASONING_EFFORT_LEVEL,
|
|
3
|
-
DEFAULT_REASONING_EFFORT_VALUE,
|
|
4
|
-
REASONING_EFFORT_LEVELS,
|
|
5
|
-
} from "../../utils/constants/index.mjs";
|
|
6
|
-
|
|
7
|
-
export default function mapReasoningEffortLevel({ level }, options) {
|
|
8
|
-
const g =
|
|
9
|
-
REASONING_EFFORT_LEVELS[level] || REASONING_EFFORT_LEVELS[DEFAULT_REASONING_EFFORT_LEVEL];
|
|
10
|
-
|
|
11
|
-
return {
|
|
12
|
-
reasoningEffort:
|
|
13
|
-
g[options.context.userContext.thinkingEffort] ?? DEFAULT_REASONING_EFFORT_VALUE,
|
|
14
|
-
};
|
|
15
|
-
}
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import { readdir, unlink } from "node:fs/promises";
|
|
2
|
-
import { join } from "node:path";
|
|
3
|
-
import { shutdownMermaidWorkerPool } from "../../utils/mermaid-worker-pool.mjs";
|
|
4
|
-
import { getCurrentGitHead, saveGitHeadToConfig } from "../../utils/utils.mjs";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @param {Object} params
|
|
8
|
-
* @param {Array<{path: string, content: string, title: string}>} params.documentStructure
|
|
9
|
-
* @param {string} params.docsDir
|
|
10
|
-
* @param {Array<string>} [params.translateLanguages] - Translation languages
|
|
11
|
-
* @returns {Promise<Array<{ path: string, success: boolean, error?: string }>>}
|
|
12
|
-
*/
|
|
13
|
-
export default async function postGenerate({
|
|
14
|
-
documentStructure,
|
|
15
|
-
docsDir,
|
|
16
|
-
translateLanguages = [],
|
|
17
|
-
locale,
|
|
18
|
-
projectInfoMessage,
|
|
19
|
-
}) {
|
|
20
|
-
const _results = [];
|
|
21
|
-
// Save current git HEAD to config.yaml for change detection
|
|
22
|
-
try {
|
|
23
|
-
const gitHead = getCurrentGitHead();
|
|
24
|
-
await saveGitHeadToConfig(gitHead);
|
|
25
|
-
} catch (err) {
|
|
26
|
-
console.warn("Failed to save git HEAD:", err.message);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// Clean up invalid .md files that are no longer in the documentation structure
|
|
30
|
-
try {
|
|
31
|
-
await cleanupInvalidFiles(documentStructure, docsDir, translateLanguages, locale);
|
|
32
|
-
} catch (err) {
|
|
33
|
-
console.error("Failed to cleanup invalid .md files:", err.message);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const message = `
|
|
37
|
-
✅ Documentation generated successfully! (\`${documentStructure.length}\` documents → \`${docsDir}\`)
|
|
38
|
-
${projectInfoMessage || ""}
|
|
39
|
-
🚀 Next: Make your documentation live and generate a shareable link, run: \`aigne doc publish\`
|
|
40
|
-
💡 Optional: Update specific document (\`aigne doc update\`) or refine documentation structure (\`aigne doc create\`)
|
|
41
|
-
`;
|
|
42
|
-
|
|
43
|
-
// Shutdown mermaid worker pool to ensure clean exit
|
|
44
|
-
try {
|
|
45
|
-
await shutdownMermaidWorkerPool();
|
|
46
|
-
} catch (error) {
|
|
47
|
-
console.warn("Failed to shutdown mermaid worker pool:", error.message);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return {
|
|
51
|
-
message,
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Generate filename based on flatName and language
|
|
57
|
-
* @param {string} flatName - Flattened path name
|
|
58
|
-
* @param {string} language - Language code
|
|
59
|
-
* @returns {string} - Generated filename
|
|
60
|
-
*/
|
|
61
|
-
function generateFileName(flatName, language) {
|
|
62
|
-
const isEnglish = language === "en";
|
|
63
|
-
return isEnglish ? `${flatName}.md` : `${flatName}.${language}.md`;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Clean up .md files that are no longer in the documentation structure
|
|
68
|
-
* @param {Array<{path: string, title: string}>} documentStructure
|
|
69
|
-
* @param {string} docsDir
|
|
70
|
-
* @param {Array<string>} translateLanguages
|
|
71
|
-
* @param {string} locale - Main language locale (e.g., 'en', 'zh', 'fr')
|
|
72
|
-
* @returns {Promise<Array<{ path: string, success: boolean, error?: string }>>}
|
|
73
|
-
*/
|
|
74
|
-
async function cleanupInvalidFiles(documentStructure, docsDir, translateLanguages, locale) {
|
|
75
|
-
const results = [];
|
|
76
|
-
|
|
77
|
-
try {
|
|
78
|
-
// Get all .md files in docsDir
|
|
79
|
-
const files = await readdir(docsDir);
|
|
80
|
-
const mdFiles = files.filter((file) => file.endsWith(".md"));
|
|
81
|
-
|
|
82
|
-
// Generate expected file names from documentation structure
|
|
83
|
-
const expectedFiles = new Set();
|
|
84
|
-
|
|
85
|
-
// Add main document files
|
|
86
|
-
for (const { path } of documentStructure) {
|
|
87
|
-
const flatName = path.replace(/^\//, "").replace(/\//g, "-");
|
|
88
|
-
|
|
89
|
-
// Main language file
|
|
90
|
-
const mainFileName = generateFileName(flatName, locale);
|
|
91
|
-
expectedFiles.add(mainFileName);
|
|
92
|
-
|
|
93
|
-
// Add translation files for each language
|
|
94
|
-
for (const lang of translateLanguages) {
|
|
95
|
-
const translateFileName = generateFileName(flatName, lang);
|
|
96
|
-
expectedFiles.add(translateFileName);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
// Find files to delete (files that are not in expectedFiles and not _sidebar.md)
|
|
101
|
-
const filesToDelete = mdFiles.filter(
|
|
102
|
-
(file) => !expectedFiles.has(file) && file !== "_sidebar.md",
|
|
103
|
-
);
|
|
104
|
-
|
|
105
|
-
// Delete invalid files
|
|
106
|
-
for (const file of filesToDelete) {
|
|
107
|
-
try {
|
|
108
|
-
const filePath = join(docsDir, file);
|
|
109
|
-
await unlink(filePath);
|
|
110
|
-
results.push({
|
|
111
|
-
path: filePath,
|
|
112
|
-
success: true,
|
|
113
|
-
message: `Deleted invalid file: ${file}`,
|
|
114
|
-
});
|
|
115
|
-
} catch (err) {
|
|
116
|
-
console.warn(`Failed to delete invalid file: ${file}, error: ${err.message}`);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
if (filesToDelete.length > 0) {
|
|
121
|
-
console.log(`Cleaned up ${filesToDelete.length} invalid .md files from ${docsDir}`);
|
|
122
|
-
}
|
|
123
|
-
} catch (err) {
|
|
124
|
-
// If docsDir doesn't exist or can't be read, that's okay
|
|
125
|
-
if (err.code !== "ENOENT") {
|
|
126
|
-
throw err;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
return results;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
// Generate sidebar content, support nested structure, and the order is consistent with documentStructure
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { readFileContent } from "../../utils/docs-finder-utils.mjs";
|
|
2
|
-
import { getFileName } from "../../utils/utils.mjs";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Read current document content from file system
|
|
6
|
-
* Used when skipping document generation (e.g., for diagram-only updates)
|
|
7
|
-
* Only reads content if intentType is diagram-related, otherwise returns input unchanged
|
|
8
|
-
*/
|
|
9
|
-
export default async function readCurrentDocumentContent(input) {
|
|
10
|
-
const { path, docsDir, locale = "en", intentType } = input;
|
|
11
|
-
|
|
12
|
-
// Only read content if intentType is diagram-related
|
|
13
|
-
// Otherwise, return input unchanged to allow document generation to proceed
|
|
14
|
-
if (!intentType || !["addDiagram", "updateDiagram", "deleteDiagram"].includes(intentType)) {
|
|
15
|
-
return input;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
if (!path || !docsDir) {
|
|
19
|
-
return input;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
try {
|
|
23
|
-
// Read document content using the same utility as other parts of the system
|
|
24
|
-
const fileName = getFileName(path, locale);
|
|
25
|
-
const content = await readFileContent(docsDir, fileName);
|
|
26
|
-
|
|
27
|
-
if (!content) {
|
|
28
|
-
console.warn(`⚠️ Could not read content from ${fileName}`);
|
|
29
|
-
return input;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// Return content as both content, documentContent, and originalContent
|
|
33
|
-
// This matches the structure expected by downstream agents
|
|
34
|
-
return {
|
|
35
|
-
...input,
|
|
36
|
-
content,
|
|
37
|
-
documentContent: content,
|
|
38
|
-
originalContent: content,
|
|
39
|
-
};
|
|
40
|
-
} catch (error) {
|
|
41
|
-
console.warn(`Failed to read current content for ${path}: ${error.message}`);
|
|
42
|
-
return input;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
readCurrentDocumentContent.task_render_mode = "hide";
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { saveDocTranslation as _saveDocTranslation } from "../../utils/utils.mjs";
|
|
2
|
-
|
|
3
|
-
export default async function saveDocTranslation({
|
|
4
|
-
path,
|
|
5
|
-
docsDir,
|
|
6
|
-
translation,
|
|
7
|
-
language,
|
|
8
|
-
labels,
|
|
9
|
-
isShowMessage = false,
|
|
10
|
-
}) {
|
|
11
|
-
await _saveDocTranslation({
|
|
12
|
-
path,
|
|
13
|
-
docsDir,
|
|
14
|
-
language,
|
|
15
|
-
translation,
|
|
16
|
-
labels,
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
// Note: Diagram image translation is now handled by translate-diagram-images.mjs
|
|
20
|
-
// in the translate workflow, which compares timestamps and only translates when needed
|
|
21
|
-
|
|
22
|
-
if (isShowMessage) {
|
|
23
|
-
const message = `✅ Translation completed successfully.`;
|
|
24
|
-
return { message };
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return {};
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
saveDocTranslation.task_render_mode = "hide";
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { shutdownMermaidWorkerPool } from "../../utils/mermaid-worker-pool.mjs";
|
|
2
|
-
import { saveDoc as _saveDoc } from "../../utils/utils.mjs";
|
|
3
|
-
|
|
4
|
-
export default async function saveDoc({
|
|
5
|
-
path,
|
|
6
|
-
content,
|
|
7
|
-
docsDir,
|
|
8
|
-
labels,
|
|
9
|
-
locale,
|
|
10
|
-
feedback,
|
|
11
|
-
isShowMessage = false,
|
|
12
|
-
intentType,
|
|
13
|
-
originalContent,
|
|
14
|
-
...rest
|
|
15
|
-
}) {
|
|
16
|
-
await _saveDoc({
|
|
17
|
-
path,
|
|
18
|
-
content,
|
|
19
|
-
docsDir,
|
|
20
|
-
labels,
|
|
21
|
-
locale,
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
// Note: Diagram image translation is handled separately during translate operation
|
|
25
|
-
// In update/add operations, we only update the main document with timestamp
|
|
26
|
-
// Translation documents will be updated during translate operation when timestamps differ
|
|
27
|
-
|
|
28
|
-
if (isShowMessage) {
|
|
29
|
-
// Shutdown mermaid worker pool to ensure clean exit
|
|
30
|
-
try {
|
|
31
|
-
await shutdownMermaidWorkerPool();
|
|
32
|
-
} catch (error) {
|
|
33
|
-
console.warn("Failed to shutdown mermaid worker pool:", error.message);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const message = `✅ Document updated successfully.`;
|
|
37
|
-
return { message };
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return {
|
|
41
|
-
path,
|
|
42
|
-
content,
|
|
43
|
-
docsDir,
|
|
44
|
-
labels,
|
|
45
|
-
locale,
|
|
46
|
-
feedback,
|
|
47
|
-
isShowMessage,
|
|
48
|
-
intentType,
|
|
49
|
-
originalContent,
|
|
50
|
-
...rest,
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
saveDoc.task_render_mode = "hide";
|