@aigne/doc-smith 0.9.9-beta → 0.9.9-beta.2
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 +19 -0
- package/agents/create/aggregate-document-structure.mjs +21 -0
- package/agents/create/analyze-diagram-type-llm.yaml +1 -2
- package/agents/create/analyze-diagram-type.mjs +160 -2
- package/agents/create/generate-diagram-image.yaml +31 -0
- package/agents/create/generate-structure.yaml +1 -12
- package/agents/create/replace-d2-with-image.mjs +12 -27
- package/agents/create/user-add-document/add-documents-to-structure.mjs +1 -1
- package/agents/create/user-review-document-structure.mjs +1 -1
- package/agents/create/utils/merge-document-structures.mjs +9 -3
- package/agents/localize/index.yaml +4 -0
- package/agents/localize/save-doc-translation-or-skip.mjs +18 -0
- package/agents/localize/set-review-content.mjs +58 -0
- package/agents/localize/translate-diagram.yaml +62 -0
- package/agents/localize/translate-document-wrapper.mjs +34 -0
- package/agents/localize/translate-multilingual.yaml +15 -9
- package/agents/localize/translate-or-skip-diagram.mjs +52 -0
- package/agents/publish/translate-meta.mjs +58 -6
- package/agents/update/generate-diagram.yaml +25 -8
- package/agents/update/index.yaml +1 -8
- package/agents/update/save-and-translate-document.mjs +5 -1
- package/agents/update/update-single/update-single-document-detail.mjs +52 -10
- package/agents/utils/analyze-feedback-intent.mjs +197 -80
- package/agents/utils/check-detail-result.mjs +14 -1
- package/agents/utils/choose-docs.mjs +3 -43
- package/agents/utils/save-doc-translation.mjs +2 -33
- package/agents/utils/save-doc.mjs +3 -37
- package/aigne.yaml +2 -2
- package/package.json +1 -1
- package/prompts/detail/diagram/generate-image-user.md +50 -1
- package/utils/d2-utils.mjs +10 -3
- package/utils/delete-diagram-images.mjs +3 -3
- package/utils/diagram-version-utils.mjs +14 -0
- package/utils/image-compress.mjs +1 -1
- package/utils/sync-diagram-to-translations.mjs +3 -3
- package/utils/translate-diagram-images.mjs +790 -0
- package/agents/update/check-sync-image-flag.mjs +0 -55
- package/agents/update/sync-images-and-exit.mjs +0 -148
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Check if --diagram-sync flag is set via command line arguments or environment variable
|
|
3
|
-
* Returns the flag value and passes through all input
|
|
4
|
-
*
|
|
5
|
-
* --diagram-sync: Auto-select all documents with banana images and sync to translations
|
|
6
|
-
*/
|
|
7
|
-
export default function checkSyncImageFlag(input) {
|
|
8
|
-
let shouldSyncImages = false;
|
|
9
|
-
|
|
10
|
-
// Check command line arguments first (highest priority)
|
|
11
|
-
if (process.argv) {
|
|
12
|
-
const hasSyncImageFlag = process.argv.some((arg) => arg === "--diagram-sync" || arg === "-ds");
|
|
13
|
-
if (hasSyncImageFlag) {
|
|
14
|
-
shouldSyncImages = true;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// Check input parameter
|
|
19
|
-
if (input["diagram-sync"] === true || input.diagramSync === true) {
|
|
20
|
-
shouldSyncImages = true;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// Check environment variable
|
|
24
|
-
if (process.env.DOC_SMITH_SYNC_IMAGES === "true" || process.env.DOC_SMITH_SYNC_IMAGES === "1") {
|
|
25
|
-
shouldSyncImages = true;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// Return all input plus the flag
|
|
29
|
-
return {
|
|
30
|
-
...input,
|
|
31
|
-
shouldSyncImages,
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
checkSyncImageFlag.input_schema = {
|
|
36
|
-
type: "object",
|
|
37
|
-
properties: {
|
|
38
|
-
"diagram-sync": {
|
|
39
|
-
type: ["boolean", "string"],
|
|
40
|
-
description:
|
|
41
|
-
"Flag to sync images to translations (can also use --diagram-sync CLI arg or DOC_SMITH_SYNC_IMAGES env var)",
|
|
42
|
-
},
|
|
43
|
-
},
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
checkSyncImageFlag.output_schema = {
|
|
47
|
-
type: "object",
|
|
48
|
-
properties: {
|
|
49
|
-
shouldSyncImages: {
|
|
50
|
-
type: "boolean",
|
|
51
|
-
description: "Whether to sync images to translations",
|
|
52
|
-
},
|
|
53
|
-
},
|
|
54
|
-
required: ["shouldSyncImages"],
|
|
55
|
-
};
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import { syncDiagramToTranslations } from "../../utils/sync-diagram-to-translations.mjs";
|
|
2
|
-
import { readFileContent } from "../../utils/docs-finder-utils.mjs";
|
|
3
|
-
import { getFileName } from "../../utils/utils.mjs";
|
|
4
|
-
import { debug } from "../../utils/debug.mjs";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Sync images to translations and exit if shouldSyncImages is true
|
|
8
|
-
* Otherwise, passes through input for normal update flow
|
|
9
|
-
*
|
|
10
|
-
* This agent combines:
|
|
11
|
-
* - Image synchronization logic
|
|
12
|
-
* - Flow routing (sync vs normal update)
|
|
13
|
-
* - Early exit handling
|
|
14
|
-
*/
|
|
15
|
-
export default async function syncImagesAndExit(input, options) {
|
|
16
|
-
// If shouldSyncImages is false, pass through for normal update flow
|
|
17
|
-
if (!input.shouldSyncImages) {
|
|
18
|
-
return input;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// Sync images flow
|
|
22
|
-
const { selectedDocs = [], docsDir, locale = "en" } = input;
|
|
23
|
-
|
|
24
|
-
if (!docsDir) {
|
|
25
|
-
throw new Error("docsDir is required for image sync. Please ensure config is loaded.");
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
if (!Array.isArray(selectedDocs) || selectedDocs.length === 0) {
|
|
29
|
-
const actionSuccessAgent = options.context?.agents?.["actionSuccess"];
|
|
30
|
-
if (actionSuccessAgent) {
|
|
31
|
-
await options.context.invoke(actionSuccessAgent, {
|
|
32
|
-
action: "ℹ️ No documents selected for image sync",
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
// Exit normally to prevent passing to next steps
|
|
36
|
-
process.exit(0);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const results = {
|
|
40
|
-
updated: 0,
|
|
41
|
-
skipped: 0,
|
|
42
|
-
errors: [],
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
// Process each document
|
|
46
|
-
for (const doc of selectedDocs) {
|
|
47
|
-
try {
|
|
48
|
-
// Use content from doc if available, otherwise read from file
|
|
49
|
-
let mainContent = doc.content;
|
|
50
|
-
if (!mainContent) {
|
|
51
|
-
const mainFileName = getFileName(doc.path, locale);
|
|
52
|
-
mainContent = await readFileContent(docsDir, mainFileName);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
if (!mainContent) {
|
|
56
|
-
debug(`⚠️ Could not read main document: ${doc.path}`);
|
|
57
|
-
results.skipped++;
|
|
58
|
-
continue;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// Sync images to translation documents
|
|
62
|
-
const syncResult = await syncDiagramToTranslations(mainContent, doc.path, docsDir, locale);
|
|
63
|
-
|
|
64
|
-
results.updated += syncResult.updated;
|
|
65
|
-
results.skipped += syncResult.skipped;
|
|
66
|
-
results.errors.push(...syncResult.errors);
|
|
67
|
-
|
|
68
|
-
if (syncResult.updated > 0) {
|
|
69
|
-
debug(`✅ Synced images from ${doc.path} to ${syncResult.updated} translation file(s)`);
|
|
70
|
-
} else if (syncResult.skipped > 0) {
|
|
71
|
-
debug(
|
|
72
|
-
`⏭️ No changes needed for ${doc.path} (${syncResult.skipped} translation file(s) already in sync)`,
|
|
73
|
-
);
|
|
74
|
-
}
|
|
75
|
-
} catch (error) {
|
|
76
|
-
debug(`❌ Error syncing images for ${doc.path}: ${error.message}`);
|
|
77
|
-
results.errors.push({
|
|
78
|
-
doc: doc.path,
|
|
79
|
-
error: error.message,
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
// Generate success message
|
|
85
|
-
const message = `✅ Image sync completed: ${results.updated} translation file(s) updated, ${results.skipped} skipped${
|
|
86
|
-
results.errors.length > 0 ? `, ${results.errors.length} error(s)` : ""
|
|
87
|
-
}`;
|
|
88
|
-
|
|
89
|
-
// Show success message
|
|
90
|
-
const actionSuccessAgent = options.context?.agents?.["actionSuccess"];
|
|
91
|
-
if (actionSuccessAgent) {
|
|
92
|
-
await options.context.invoke(actionSuccessAgent, {
|
|
93
|
-
action: message,
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
// Exit normally to prevent passing to next steps and avoid validation errors
|
|
98
|
-
// This ensures a clean exit after successful image sync
|
|
99
|
-
process.exit(0);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
syncImagesAndExit.input_schema = {
|
|
103
|
-
type: "object",
|
|
104
|
-
properties: {
|
|
105
|
-
shouldSyncImages: {
|
|
106
|
-
type: "boolean",
|
|
107
|
-
description: "Whether to trigger image sync to translations",
|
|
108
|
-
},
|
|
109
|
-
selectedDocs: {
|
|
110
|
-
type: "array",
|
|
111
|
-
description: "Array of selected documents to sync images from",
|
|
112
|
-
},
|
|
113
|
-
docsDir: {
|
|
114
|
-
type: "string",
|
|
115
|
-
description: "Documentation directory where documents are stored",
|
|
116
|
-
},
|
|
117
|
-
locale: {
|
|
118
|
-
type: "string",
|
|
119
|
-
description: "Main language locale (e.g., 'en', 'zh')",
|
|
120
|
-
default: "en",
|
|
121
|
-
},
|
|
122
|
-
},
|
|
123
|
-
required: ["shouldSyncImages"],
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
syncImagesAndExit.output_schema = {
|
|
127
|
-
type: "object",
|
|
128
|
-
properties: {
|
|
129
|
-
message: {
|
|
130
|
-
type: "string",
|
|
131
|
-
description: "Summary message of the sync operation",
|
|
132
|
-
},
|
|
133
|
-
updated: {
|
|
134
|
-
type: "number",
|
|
135
|
-
description: "Number of translation files successfully updated",
|
|
136
|
-
},
|
|
137
|
-
skipped: {
|
|
138
|
-
type: "number",
|
|
139
|
-
description: "Number of translation files skipped (no changes needed)",
|
|
140
|
-
},
|
|
141
|
-
errors: {
|
|
142
|
-
type: "array",
|
|
143
|
-
description: "Array of errors encountered during sync",
|
|
144
|
-
},
|
|
145
|
-
},
|
|
146
|
-
};
|
|
147
|
-
|
|
148
|
-
syncImagesAndExit.task_render_mode = "hide";
|