@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
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
type: image
|
|
2
|
+
name: generateSlotDiagramImage
|
|
3
|
+
image_model:
|
|
4
|
+
model: google/gemini-3-pro-image-preview
|
|
5
|
+
imageConfig:
|
|
6
|
+
imageSize:
|
|
7
|
+
$get: size
|
|
8
|
+
aspectRatio:
|
|
9
|
+
$get: aspectRatio
|
|
10
|
+
|
|
11
|
+
instructions:
|
|
12
|
+
- role: system
|
|
13
|
+
url: ./prompts/system.md
|
|
14
|
+
- role: user
|
|
15
|
+
url: ./prompts/user.md
|
|
16
|
+
|
|
17
|
+
# Support image-to-image generation by passing existing image via input_file_key
|
|
18
|
+
# If existingImage is provided (array of mediaFile objects), it will be passed to the model
|
|
19
|
+
input_file_key: existingImage
|
|
20
|
+
|
|
21
|
+
input_schema:
|
|
22
|
+
type: object
|
|
23
|
+
properties:
|
|
24
|
+
documentContent:
|
|
25
|
+
type: string
|
|
26
|
+
description: The full document content for context
|
|
27
|
+
desc:
|
|
28
|
+
type: string
|
|
29
|
+
description: The AFS slot description that describes what should be illustrated
|
|
30
|
+
locale:
|
|
31
|
+
type: string
|
|
32
|
+
description: Language for diagram labels
|
|
33
|
+
default: zh
|
|
34
|
+
size:
|
|
35
|
+
type: string
|
|
36
|
+
description: Size of the generated image
|
|
37
|
+
default: "2K"
|
|
38
|
+
aspectRatio:
|
|
39
|
+
type: string
|
|
40
|
+
description: Aspect ratio of the generated image
|
|
41
|
+
enum: ["1:1", "5:4", "4:3", "3:2", "16:9", "21:9"]
|
|
42
|
+
default: "4:3"
|
|
43
|
+
existingImage:
|
|
44
|
+
type: array
|
|
45
|
+
nullable: true
|
|
46
|
+
description: Array of mediaFile objects for existing diagram image (for image-to-image generation)
|
|
47
|
+
items:
|
|
48
|
+
type: object
|
|
49
|
+
properties:
|
|
50
|
+
type:
|
|
51
|
+
type: string
|
|
52
|
+
description: File type, should be "local"
|
|
53
|
+
path:
|
|
54
|
+
type: string
|
|
55
|
+
description: Absolute path to the image file
|
|
56
|
+
filename:
|
|
57
|
+
type: string
|
|
58
|
+
description: Image filename
|
|
59
|
+
mimeType:
|
|
60
|
+
type: string
|
|
61
|
+
description: MIME type of the image (e.g., "image/png", "image/jpeg")
|
|
62
|
+
useImageToImage:
|
|
63
|
+
type: boolean
|
|
64
|
+
description: Whether to use image-to-image generation mode
|
|
65
|
+
default: false
|
|
66
|
+
feedback:
|
|
67
|
+
type: string
|
|
68
|
+
description: User feedback for image editing (used in image-to-image mode to guide modifications)
|
|
69
|
+
default: ""
|
|
70
|
+
required:
|
|
71
|
+
- documentContent
|
|
72
|
+
- desc
|
|
73
|
+
- aspectRatio
|
|
74
|
+
|
|
75
|
+
include_input_in_output: true
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generate final summary report for image generation tasks
|
|
3
|
+
* @param {Object} input - Input parameters
|
|
4
|
+
* @param {string} input.locale - Main language
|
|
5
|
+
* @param {Array} input.generationTasks - Generation task list (from prepare-generation)
|
|
6
|
+
* @param {Array} input.processAllSlots - Execution result list (from team iterate)
|
|
7
|
+
* @param {number} input.newTasks - Number of new tasks
|
|
8
|
+
* @param {number} input.updateTasks - Number of update tasks
|
|
9
|
+
* @param {number} input.skippedTasks - Number of skipped tasks
|
|
10
|
+
* @returns {Object} - Object containing formatted message and statistics
|
|
11
|
+
*/
|
|
12
|
+
export default function generateSummary(input) {
|
|
13
|
+
const { locale, generationTasks, processAllSlots, newTasks, updateTasks, skippedTasks } = input;
|
|
14
|
+
|
|
15
|
+
// If no tasks
|
|
16
|
+
if (!generationTasks || generationTasks.length === 0) {
|
|
17
|
+
return {
|
|
18
|
+
message: `⏭️ No image slots to generate`,
|
|
19
|
+
summary: {
|
|
20
|
+
locale,
|
|
21
|
+
totalTasks: 0,
|
|
22
|
+
newImages: 0,
|
|
23
|
+
updatedImages: 0,
|
|
24
|
+
skippedImages: skippedTasks || 0,
|
|
25
|
+
successTasks: 0,
|
|
26
|
+
failedTasks: 0,
|
|
27
|
+
generatedImages: [],
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Count successful and failed tasks
|
|
33
|
+
const results = processAllSlots || [];
|
|
34
|
+
const successTasks = results.filter((r) => r?.success);
|
|
35
|
+
const failedTasks = results.filter((r) => r && !r.success);
|
|
36
|
+
|
|
37
|
+
const successCount = successTasks.length;
|
|
38
|
+
const failedCount = failedTasks.length;
|
|
39
|
+
|
|
40
|
+
// Generate list of successful image paths (show up to 10)
|
|
41
|
+
const successPaths = successTasks.map((r) => r.imagePath).filter(Boolean);
|
|
42
|
+
const displayPaths =
|
|
43
|
+
successPaths.length > 10
|
|
44
|
+
? [...successPaths.slice(0, 10), `... and ${successPaths.length - 10} more images`]
|
|
45
|
+
: successPaths;
|
|
46
|
+
|
|
47
|
+
// Generate list of failed tasks
|
|
48
|
+
const failedKeys = failedTasks.map((r) => ({
|
|
49
|
+
key: r.key,
|
|
50
|
+
error: r.message || r.error || "Unknown error",
|
|
51
|
+
}));
|
|
52
|
+
|
|
53
|
+
// Generate formatted message
|
|
54
|
+
let message = `
|
|
55
|
+
✅ Image generation tasks completed
|
|
56
|
+
|
|
57
|
+
📊 **Generation Statistics**:
|
|
58
|
+
- Main language: ${locale}
|
|
59
|
+
- Total tasks: ${generationTasks.length}
|
|
60
|
+
- New images: ${newTasks || 0}
|
|
61
|
+
- Updated images: ${updateTasks || 0}
|
|
62
|
+
- Skipped images: ${skippedTasks || 0}
|
|
63
|
+
- Succeeded: ${successCount}
|
|
64
|
+
- Failed: ${failedCount}
|
|
65
|
+
`;
|
|
66
|
+
|
|
67
|
+
if (successPaths.length > 0) {
|
|
68
|
+
message += `
|
|
69
|
+
📷 **Generated Images**:
|
|
70
|
+
${displayPaths.map((path) => ` - ${path}`).join("\n")}
|
|
71
|
+
`;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (failedKeys.length > 0) {
|
|
75
|
+
message += `
|
|
76
|
+
❌ **Failed Tasks**:
|
|
77
|
+
${failedKeys.map((f) => ` - ${f.key}: ${f.error}`).join("\n")}
|
|
78
|
+
`;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
message += `
|
|
82
|
+
💡 **Tips**:
|
|
83
|
+
- Images saved to assets/{key}/images/${locale}.png
|
|
84
|
+
- Metadata saved to assets/{key}/.meta.yaml
|
|
85
|
+
`;
|
|
86
|
+
|
|
87
|
+
return {
|
|
88
|
+
message: message.trim(),
|
|
89
|
+
summary: {
|
|
90
|
+
locale,
|
|
91
|
+
totalTasks: generationTasks.length,
|
|
92
|
+
newImages: newTasks || 0,
|
|
93
|
+
updatedImages: updateTasks || 0,
|
|
94
|
+
skippedImages: skippedTasks || 0,
|
|
95
|
+
successTasks: successCount,
|
|
96
|
+
failedTasks: failedCount,
|
|
97
|
+
generatedImages: successPaths,
|
|
98
|
+
failedKeys,
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Add description
|
|
104
|
+
generateSummary.description =
|
|
105
|
+
"Generate final summary report for image generation tasks. " +
|
|
106
|
+
"Aggregate generation statistics (main language, new/update/skip counts, success/failure tasks, etc.), generate readable formatted message. " +
|
|
107
|
+
"List generated image paths and failed task information.";
|
|
108
|
+
|
|
109
|
+
// Define input schema
|
|
110
|
+
generateSummary.input_schema = {
|
|
111
|
+
type: "object",
|
|
112
|
+
properties: {
|
|
113
|
+
locale: {
|
|
114
|
+
type: "string",
|
|
115
|
+
description: "Main language code",
|
|
116
|
+
},
|
|
117
|
+
generationTasks: {
|
|
118
|
+
type: "array",
|
|
119
|
+
description: "Generation task list",
|
|
120
|
+
items: {
|
|
121
|
+
type: "object",
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
processAllSlots: {
|
|
125
|
+
type: "array",
|
|
126
|
+
description: "Execution result list",
|
|
127
|
+
items: {
|
|
128
|
+
type: "object",
|
|
129
|
+
properties: {
|
|
130
|
+
success: { type: "boolean" },
|
|
131
|
+
key: { type: "string" },
|
|
132
|
+
imagePath: { type: "string" },
|
|
133
|
+
message: { type: "string" },
|
|
134
|
+
error: { type: "string" },
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
newTasks: {
|
|
139
|
+
type: "number",
|
|
140
|
+
description: "Number of new tasks",
|
|
141
|
+
},
|
|
142
|
+
updateTasks: {
|
|
143
|
+
type: "number",
|
|
144
|
+
description: "Number of update tasks",
|
|
145
|
+
},
|
|
146
|
+
skippedTasks: {
|
|
147
|
+
type: "number",
|
|
148
|
+
description: "Number of skipped tasks",
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
// Define output schema
|
|
154
|
+
generateSummary.output_schema = {
|
|
155
|
+
type: "object",
|
|
156
|
+
required: ["message", "summary"],
|
|
157
|
+
properties: {
|
|
158
|
+
message: {
|
|
159
|
+
type: "string",
|
|
160
|
+
description: "Formatted summary message containing generation statistics and tips",
|
|
161
|
+
},
|
|
162
|
+
summary: {
|
|
163
|
+
type: "object",
|
|
164
|
+
description: "Structured statistics data",
|
|
165
|
+
properties: {
|
|
166
|
+
locale: {
|
|
167
|
+
type: "string",
|
|
168
|
+
description: "Main language code",
|
|
169
|
+
},
|
|
170
|
+
totalTasks: {
|
|
171
|
+
type: "number",
|
|
172
|
+
description: "Total task count",
|
|
173
|
+
},
|
|
174
|
+
newImages: {
|
|
175
|
+
type: "number",
|
|
176
|
+
description: "Number of new images",
|
|
177
|
+
},
|
|
178
|
+
updatedImages: {
|
|
179
|
+
type: "number",
|
|
180
|
+
description: "Number of updated images",
|
|
181
|
+
},
|
|
182
|
+
skippedImages: {
|
|
183
|
+
type: "number",
|
|
184
|
+
description: "Number of skipped images",
|
|
185
|
+
},
|
|
186
|
+
successTasks: {
|
|
187
|
+
type: "number",
|
|
188
|
+
description: "Number of successful tasks",
|
|
189
|
+
},
|
|
190
|
+
failedTasks: {
|
|
191
|
+
type: "number",
|
|
192
|
+
description: "Number of failed tasks",
|
|
193
|
+
},
|
|
194
|
+
generatedImages: {
|
|
195
|
+
type: "array",
|
|
196
|
+
items: { type: "string" },
|
|
197
|
+
description: "List of generated image paths",
|
|
198
|
+
},
|
|
199
|
+
failedKeys: {
|
|
200
|
+
type: "array",
|
|
201
|
+
items: {
|
|
202
|
+
type: "object",
|
|
203
|
+
properties: {
|
|
204
|
+
key: { type: "string" },
|
|
205
|
+
error: { type: "string" },
|
|
206
|
+
},
|
|
207
|
+
},
|
|
208
|
+
description: "List of failed tasks",
|
|
209
|
+
},
|
|
210
|
+
},
|
|
211
|
+
},
|
|
212
|
+
},
|
|
213
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
type: team
|
|
2
|
+
name: generateImages
|
|
3
|
+
alias:
|
|
4
|
+
- gen-images
|
|
5
|
+
description: |
|
|
6
|
+
Scan AFS image slots in main language documents and batch generate main language images. Supports the following features:
|
|
7
|
+
- Scan all documents for slots and generate images
|
|
8
|
+
- Scan specified documents for slots and generate images
|
|
9
|
+
- Support force regeneration of existing images
|
|
10
|
+
|
|
11
|
+
skills:
|
|
12
|
+
- url: ./scan-image-slots.mjs # Scan slots in main language documents
|
|
13
|
+
- url: ./prepare-generation.mjs # Prepare image generation tasks (dedup, check existing images)
|
|
14
|
+
- type: team
|
|
15
|
+
name: processAllSlots # Batch generate images
|
|
16
|
+
skills:
|
|
17
|
+
- url: ./prepare-image-generation.mjs
|
|
18
|
+
- url: ./generate-image.yaml
|
|
19
|
+
- url: ./save-image-result.mjs
|
|
20
|
+
iterate_on: generationTasks
|
|
21
|
+
concurrency: 5 # Concurrent generation
|
|
22
|
+
- url: ./generate-summary.mjs # Generate summary report
|
|
23
|
+
|
|
24
|
+
input_schema:
|
|
25
|
+
type: object
|
|
26
|
+
properties:
|
|
27
|
+
docs:
|
|
28
|
+
type: array
|
|
29
|
+
items:
|
|
30
|
+
type: string
|
|
31
|
+
description: |
|
|
32
|
+
Document path list to process (optional), must be path field from document structure yaml. Processes all documents if not provided or empty array.
|
|
33
|
+
force:
|
|
34
|
+
type: boolean
|
|
35
|
+
default: false
|
|
36
|
+
description: |
|
|
37
|
+
Whether to force regenerate existing images (defaults to only generating missing images)
|
|
38
|
+
|
|
39
|
+
mode: sequential
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
import { readFile, access, stat } from "node:fs/promises";
|
|
2
|
+
import { constants } from "node:fs";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { parse as yamlParse } from "yaml";
|
|
5
|
+
import { PATHS } from "../../utils/agent-constants.mjs";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Check if image directory exists
|
|
9
|
+
* @param {string} key - Image key
|
|
10
|
+
* @returns {Promise<boolean>}
|
|
11
|
+
*/
|
|
12
|
+
async function imageDirectoryExists(key) {
|
|
13
|
+
const dirPath = join(PATHS.ASSETS_DIR, key);
|
|
14
|
+
try {
|
|
15
|
+
const stats = await stat(dirPath);
|
|
16
|
+
return stats.isDirectory();
|
|
17
|
+
} catch (_error) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Read image meta information
|
|
24
|
+
* @param {string} key - Image key
|
|
25
|
+
* @returns {Promise<Object|null>} - Meta information or null (if file does not exist)
|
|
26
|
+
*/
|
|
27
|
+
async function readImageMeta(key) {
|
|
28
|
+
const metaPath = join(PATHS.ASSETS_DIR, key, ".meta.yaml");
|
|
29
|
+
|
|
30
|
+
try {
|
|
31
|
+
await access(metaPath, constants.F_OK | constants.R_OK);
|
|
32
|
+
const content = await readFile(metaPath, "utf8");
|
|
33
|
+
return yamlParse(content);
|
|
34
|
+
} catch (_error) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Check if image file exists
|
|
41
|
+
* @param {string} key - Image key
|
|
42
|
+
* @param {string} locale - Language code
|
|
43
|
+
* @returns {Promise<string|null>} - Image path or null (if not exists)
|
|
44
|
+
*/
|
|
45
|
+
async function getExistingImagePath(key, locale) {
|
|
46
|
+
const imagePath = join(PATHS.ASSETS_DIR, key, "images", `${locale}.png`);
|
|
47
|
+
|
|
48
|
+
try {
|
|
49
|
+
await access(imagePath, constants.F_OK | constants.R_OK);
|
|
50
|
+
return imagePath;
|
|
51
|
+
} catch (_error) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Determine if document hash has changed
|
|
58
|
+
* @param {Array} currentDocs - Current document list
|
|
59
|
+
* @param {Array} metaDocs - Document list recorded in meta
|
|
60
|
+
* @returns {boolean} - Whether there are changes
|
|
61
|
+
*/
|
|
62
|
+
function hasDocumentChanges(currentDocs, metaDocs) {
|
|
63
|
+
if (!metaDocs || metaDocs.length === 0) {
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Convert meta documents to map (path -> hash)
|
|
68
|
+
const metaHashMap = new Map(metaDocs.map((doc) => [doc.path, doc.hash]));
|
|
69
|
+
|
|
70
|
+
// Check hash of each current document
|
|
71
|
+
for (const doc of currentDocs) {
|
|
72
|
+
const metaHash = metaHashMap.get(doc.path);
|
|
73
|
+
if (!metaHash || metaHash !== doc.hash) {
|
|
74
|
+
return true; // Hash differs or new document
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Prepare image generation tasks
|
|
83
|
+
* @param {Object} input - Input parameters
|
|
84
|
+
* @param {string} input.locale - Main language
|
|
85
|
+
* @param {Array} input.slots - Scanned slot list
|
|
86
|
+
* @param {boolean} input.force - Whether to force regeneration
|
|
87
|
+
* @returns {Promise<Object>} - Task list
|
|
88
|
+
*/
|
|
89
|
+
export default async function prepareGeneration(input) {
|
|
90
|
+
try {
|
|
91
|
+
const { locale, slots, force = false } = input;
|
|
92
|
+
|
|
93
|
+
if (!locale) {
|
|
94
|
+
throw new Error(
|
|
95
|
+
"Missing main language parameter, please check if doc-smith workspace has been initialized and files have been generated!",
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (!slots || slots.length === 0) {
|
|
100
|
+
return {
|
|
101
|
+
success: true,
|
|
102
|
+
locale,
|
|
103
|
+
generationTasks: [],
|
|
104
|
+
message: "No image slots found to generate",
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const generationTasks = [];
|
|
109
|
+
let skippedCount = 0;
|
|
110
|
+
|
|
111
|
+
// Check each slot
|
|
112
|
+
for (const slot of slots) {
|
|
113
|
+
const { key, id, desc, documents } = slot;
|
|
114
|
+
|
|
115
|
+
// Check if image directory exists
|
|
116
|
+
const dirExists = await imageDirectoryExists(key);
|
|
117
|
+
|
|
118
|
+
let needsGeneration = false;
|
|
119
|
+
let isUpdate = false;
|
|
120
|
+
let existingImagePath = null;
|
|
121
|
+
|
|
122
|
+
if (force) {
|
|
123
|
+
// Force regeneration
|
|
124
|
+
needsGeneration = true;
|
|
125
|
+
isUpdate = dirExists;
|
|
126
|
+
if (isUpdate) {
|
|
127
|
+
existingImagePath = await getExistingImagePath(key, locale);
|
|
128
|
+
}
|
|
129
|
+
} else if (!dirExists) {
|
|
130
|
+
// Image directory does not exist, needs generation
|
|
131
|
+
needsGeneration = true;
|
|
132
|
+
isUpdate = false;
|
|
133
|
+
} else {
|
|
134
|
+
// Image directory exists, check if hash changed
|
|
135
|
+
const meta = await readImageMeta(key);
|
|
136
|
+
|
|
137
|
+
if (!meta) {
|
|
138
|
+
// Meta file does not exist, regenerate
|
|
139
|
+
needsGeneration = true;
|
|
140
|
+
isUpdate = false;
|
|
141
|
+
} else {
|
|
142
|
+
const hasChanges = hasDocumentChanges(documents, meta.documents);
|
|
143
|
+
|
|
144
|
+
if (hasChanges) {
|
|
145
|
+
// Document has changes, update image
|
|
146
|
+
needsGeneration = true;
|
|
147
|
+
isUpdate = true;
|
|
148
|
+
existingImagePath = await getExistingImagePath(key, locale);
|
|
149
|
+
} else {
|
|
150
|
+
// No changes, skip
|
|
151
|
+
needsGeneration = false;
|
|
152
|
+
skippedCount++;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
if (needsGeneration) {
|
|
158
|
+
generationTasks.push({
|
|
159
|
+
key,
|
|
160
|
+
id,
|
|
161
|
+
desc,
|
|
162
|
+
documents,
|
|
163
|
+
isUpdate,
|
|
164
|
+
existingImagePath,
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
return {
|
|
170
|
+
success: true,
|
|
171
|
+
locale,
|
|
172
|
+
generationTasks,
|
|
173
|
+
totalSlots: slots.length,
|
|
174
|
+
newTasks: generationTasks.filter((t) => !t.isUpdate).length,
|
|
175
|
+
updateTasks: generationTasks.filter((t) => t.isUpdate).length,
|
|
176
|
+
skippedTasks: skippedCount,
|
|
177
|
+
message: `Preparing to generate ${generationTasks.length} images (new: ${generationTasks.filter((t) => !t.isUpdate).length}, update: ${generationTasks.filter((t) => t.isUpdate).length}, skip: ${skippedCount})`,
|
|
178
|
+
};
|
|
179
|
+
} catch (error) {
|
|
180
|
+
throw new Error(`Error preparing image generation tasks: ${error.message}`);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// Add description
|
|
185
|
+
prepareGeneration.description =
|
|
186
|
+
"Check existing image directories and meta information, compare document hashes, " +
|
|
187
|
+
"determine which images need generation or update, and generate task list.";
|
|
188
|
+
|
|
189
|
+
// Define input schema
|
|
190
|
+
prepareGeneration.input_schema = {
|
|
191
|
+
type: "object",
|
|
192
|
+
properties: {
|
|
193
|
+
locale: {
|
|
194
|
+
type: "string",
|
|
195
|
+
description: "Main language code",
|
|
196
|
+
},
|
|
197
|
+
slots: {
|
|
198
|
+
type: "array",
|
|
199
|
+
description: "Scanned slot list",
|
|
200
|
+
items: {
|
|
201
|
+
type: "object",
|
|
202
|
+
properties: {
|
|
203
|
+
key: { type: "string" },
|
|
204
|
+
id: { type: "string" },
|
|
205
|
+
desc: { type: "string" },
|
|
206
|
+
documents: {
|
|
207
|
+
type: "array",
|
|
208
|
+
items: {
|
|
209
|
+
type: "object",
|
|
210
|
+
properties: {
|
|
211
|
+
path: { type: "string" },
|
|
212
|
+
hash: { type: "string" },
|
|
213
|
+
content: { type: "string" },
|
|
214
|
+
},
|
|
215
|
+
},
|
|
216
|
+
},
|
|
217
|
+
},
|
|
218
|
+
},
|
|
219
|
+
},
|
|
220
|
+
force: {
|
|
221
|
+
type: "boolean",
|
|
222
|
+
description: "Whether to force regenerate all images",
|
|
223
|
+
default: false,
|
|
224
|
+
},
|
|
225
|
+
},
|
|
226
|
+
required: ["locale", "slots"],
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
// Define output schema
|
|
230
|
+
prepareGeneration.output_schema = {
|
|
231
|
+
type: "object",
|
|
232
|
+
required: ["success"],
|
|
233
|
+
properties: {
|
|
234
|
+
success: {
|
|
235
|
+
type: "boolean",
|
|
236
|
+
description: "Whether operation succeeded",
|
|
237
|
+
},
|
|
238
|
+
locale: {
|
|
239
|
+
type: "string",
|
|
240
|
+
description: "Main language code",
|
|
241
|
+
},
|
|
242
|
+
generationTasks: {
|
|
243
|
+
type: "array",
|
|
244
|
+
description: "List of tasks to generate",
|
|
245
|
+
items: {
|
|
246
|
+
type: "object",
|
|
247
|
+
properties: {
|
|
248
|
+
key: { type: "string" },
|
|
249
|
+
id: { type: "string" },
|
|
250
|
+
desc: { type: "string" },
|
|
251
|
+
documents: { type: "array" },
|
|
252
|
+
isUpdate: { type: "boolean" },
|
|
253
|
+
existingImagePath: { type: "string", nullable: true },
|
|
254
|
+
},
|
|
255
|
+
},
|
|
256
|
+
},
|
|
257
|
+
totalSlots: {
|
|
258
|
+
type: "number",
|
|
259
|
+
description: "Total slot count",
|
|
260
|
+
},
|
|
261
|
+
newTasks: {
|
|
262
|
+
type: "number",
|
|
263
|
+
description: "Number of new tasks",
|
|
264
|
+
},
|
|
265
|
+
updateTasks: {
|
|
266
|
+
type: "number",
|
|
267
|
+
description: "Number of update tasks",
|
|
268
|
+
},
|
|
269
|
+
skippedTasks: {
|
|
270
|
+
type: "number",
|
|
271
|
+
description: "Number of skipped tasks",
|
|
272
|
+
},
|
|
273
|
+
message: {
|
|
274
|
+
type: "string",
|
|
275
|
+
description: "Operation result description",
|
|
276
|
+
},
|
|
277
|
+
error: {
|
|
278
|
+
type: "string",
|
|
279
|
+
description: "Error code (present on failure)",
|
|
280
|
+
},
|
|
281
|
+
suggestion: {
|
|
282
|
+
type: "string",
|
|
283
|
+
description: "Suggested action (present on failure)",
|
|
284
|
+
},
|
|
285
|
+
},
|
|
286
|
+
};
|