@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,183 @@
|
|
|
1
|
+
import {
|
|
2
|
+
detectWorkspaceMode,
|
|
3
|
+
loadConfig,
|
|
4
|
+
DOC_SMITH_DIR,
|
|
5
|
+
SOURCES_DIR,
|
|
6
|
+
WORKSPACE_MODES,
|
|
7
|
+
} from "./workspace.mjs";
|
|
8
|
+
|
|
9
|
+
// AIGNE framework placeholder for current working directory
|
|
10
|
+
const CWD = "$" + "{CWD}";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Generate base AFS modules (workspace and sources)
|
|
14
|
+
* @param {string} mode - Workspace mode (project | standalone)
|
|
15
|
+
* @returns {Array} - AFS module configuration array
|
|
16
|
+
*/
|
|
17
|
+
function generateBaseModules(mode) {
|
|
18
|
+
const modules = [];
|
|
19
|
+
|
|
20
|
+
if (mode === WORKSPACE_MODES.PROJECT) {
|
|
21
|
+
// Project mode: workspace is .aigne/doc-smith, sources is CWD
|
|
22
|
+
modules.push({
|
|
23
|
+
module: "local-fs",
|
|
24
|
+
options: {
|
|
25
|
+
name: "workspace",
|
|
26
|
+
localPath: `${CWD}/${DOC_SMITH_DIR}`,
|
|
27
|
+
description:
|
|
28
|
+
"Doc-smith workspace directory\n" +
|
|
29
|
+
"- Read-write access to documentation files\n" +
|
|
30
|
+
"- Use absolute path for file operations",
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
modules.push({
|
|
35
|
+
module: "local-fs",
|
|
36
|
+
options: {
|
|
37
|
+
name: "sources",
|
|
38
|
+
localPath: CWD,
|
|
39
|
+
description:
|
|
40
|
+
"Source code directory (project root)\n" +
|
|
41
|
+
"- Read-only access to source files\n" +
|
|
42
|
+
"- Used for documentation generation",
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
} else {
|
|
46
|
+
// Standalone mode: workspace is CWD, sources is CWD/sources
|
|
47
|
+
modules.push({
|
|
48
|
+
module: "local-fs",
|
|
49
|
+
options: {
|
|
50
|
+
name: "workspace",
|
|
51
|
+
localPath: CWD,
|
|
52
|
+
description:
|
|
53
|
+
"Doc-smith workspace directory\n" +
|
|
54
|
+
"- Read-write access to documentation files\n" +
|
|
55
|
+
"- Use absolute path for file operations",
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
modules.push({
|
|
60
|
+
module: "local-fs",
|
|
61
|
+
options: {
|
|
62
|
+
name: "sources",
|
|
63
|
+
localPath: `${CWD}/${SOURCES_DIR}`,
|
|
64
|
+
description:
|
|
65
|
+
"Source code directory\n" +
|
|
66
|
+
"- Read-only access to source files\n" +
|
|
67
|
+
"- Used for documentation generation",
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return modules;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Generate skill module configuration
|
|
77
|
+
* @param {string} skillName - Skill name
|
|
78
|
+
* @param {string} skillPath - Skill relative path
|
|
79
|
+
* @param {string} description - Skill description
|
|
80
|
+
* @returns {Object} - AFS module configuration
|
|
81
|
+
*/
|
|
82
|
+
function generateSkillModule(skillName, skillPath, description) {
|
|
83
|
+
return {
|
|
84
|
+
module: "local-fs",
|
|
85
|
+
options: {
|
|
86
|
+
agentSkills: true,
|
|
87
|
+
name: skillName,
|
|
88
|
+
localPath: skillPath,
|
|
89
|
+
description:
|
|
90
|
+
description +
|
|
91
|
+
"\n- Read-only access to skill definition files\n" +
|
|
92
|
+
"- Do NOT modify files in this directory",
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Generate history module configuration
|
|
99
|
+
* @returns {Object} - History module configuration
|
|
100
|
+
*/
|
|
101
|
+
function generateHistoryModule() {
|
|
102
|
+
return {
|
|
103
|
+
module: "history",
|
|
104
|
+
options: {
|
|
105
|
+
storage: {
|
|
106
|
+
url: "file:./.aigne/history.db",
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Generate complete AFS module configuration
|
|
114
|
+
* @param {Object} options - Configuration options
|
|
115
|
+
* @param {Object} options.workspace - Workspace info { mode, configPath }
|
|
116
|
+
* @param {string} options.skillName - Skill name
|
|
117
|
+
* @param {string} options.skillPath - Skill relative path
|
|
118
|
+
* @param {string} options.skillDescription - Skill description
|
|
119
|
+
* @param {boolean} options.includeHistory - Whether to include history module
|
|
120
|
+
* @returns {Promise<Array>} - AFS module configuration array
|
|
121
|
+
*/
|
|
122
|
+
export async function generateAfsModules({
|
|
123
|
+
workspace,
|
|
124
|
+
skillName,
|
|
125
|
+
skillPath,
|
|
126
|
+
skillDescription = "Agent skill for document operations",
|
|
127
|
+
includeHistory = false,
|
|
128
|
+
} = {}) {
|
|
129
|
+
// Determine workspace mode
|
|
130
|
+
let mode;
|
|
131
|
+
if (workspace) {
|
|
132
|
+
const config = await loadConfig(workspace.configPath);
|
|
133
|
+
mode = config?.mode || workspace.mode;
|
|
134
|
+
} else {
|
|
135
|
+
const detected = await detectWorkspaceMode();
|
|
136
|
+
mode = detected?.mode || WORKSPACE_MODES.STANDALONE;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const modules = [];
|
|
140
|
+
|
|
141
|
+
// Add history module (if needed)
|
|
142
|
+
if (includeHistory) {
|
|
143
|
+
modules.push(generateHistoryModule());
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// Add base modules (workspace and sources)
|
|
147
|
+
modules.push(...generateBaseModules(mode));
|
|
148
|
+
|
|
149
|
+
// Add skill module
|
|
150
|
+
if (skillName && skillPath) {
|
|
151
|
+
modules.push(generateSkillModule(skillName, skillPath, skillDescription));
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return modules;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Generate AFS modules for doc-smith main agent
|
|
159
|
+
* @param {Object} workspace - Workspace info
|
|
160
|
+
* @returns {Promise<Array>} - AFS module configuration array
|
|
161
|
+
*/
|
|
162
|
+
export async function generateDocSmithAfsModules(workspace) {
|
|
163
|
+
return generateAfsModules({
|
|
164
|
+
workspace,
|
|
165
|
+
skillName: "doc-smith",
|
|
166
|
+
skillPath: "../../skills/doc-smith",
|
|
167
|
+
skillDescription: "Agent skill for document operations",
|
|
168
|
+
includeHistory: true,
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Generate AFS modules for doc-smith-docs-detail agent
|
|
174
|
+
* @returns {Promise<Array>} - AFS module configuration array
|
|
175
|
+
*/
|
|
176
|
+
export async function generateDocsDetailAfsModules() {
|
|
177
|
+
return generateAfsModules({
|
|
178
|
+
skillName: "doc-smith-docs-detail",
|
|
179
|
+
skillPath: "../../skills/doc-smith-docs-detail",
|
|
180
|
+
skillDescription: "Agent skill for document detail generation",
|
|
181
|
+
includeHistory: false,
|
|
182
|
+
});
|
|
183
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { resolve } from "node:path";
|
|
2
|
+
import { detectWorkspaceModeSync } from "./workspace.mjs";
|
|
3
|
+
|
|
4
|
+
// Use unified workspace detection logic
|
|
5
|
+
const { workspaceBase: WORKSPACE_BASE } = detectWorkspaceModeSync();
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Path constants definition
|
|
9
|
+
* All paths are absolute paths based on workspace
|
|
10
|
+
*/
|
|
11
|
+
export const PATHS = {
|
|
12
|
+
// Workspace root directory
|
|
13
|
+
WORKSPACE_BASE,
|
|
14
|
+
|
|
15
|
+
// Temp directory
|
|
16
|
+
TMP_DIR: resolve(WORKSPACE_BASE, ".tmp"),
|
|
17
|
+
|
|
18
|
+
// Cache directory
|
|
19
|
+
CACHE: resolve(WORKSPACE_BASE, "cache"),
|
|
20
|
+
|
|
21
|
+
// Document structure file
|
|
22
|
+
DOCUMENT_STRUCTURE: resolve(WORKSPACE_BASE, "planning/document-structure.yaml"),
|
|
23
|
+
|
|
24
|
+
// Documents directory
|
|
25
|
+
DOCS_DIR: resolve(WORKSPACE_BASE, "docs"),
|
|
26
|
+
|
|
27
|
+
// Assets directory (images, etc.)
|
|
28
|
+
ASSETS_DIR: resolve(WORKSPACE_BASE, "assets"),
|
|
29
|
+
|
|
30
|
+
// Config file
|
|
31
|
+
CONFIG: resolve(WORKSPACE_BASE, "config.yaml"),
|
|
32
|
+
|
|
33
|
+
// Glossary
|
|
34
|
+
GLOSSARY: resolve(WORKSPACE_BASE, "intent/GLOSSARY.md"),
|
|
35
|
+
|
|
36
|
+
// Planning directory
|
|
37
|
+
PLANNING_DIR: resolve(WORKSPACE_BASE, "planning"),
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Error code constants
|
|
42
|
+
* Unified management of error types
|
|
43
|
+
*/
|
|
44
|
+
export const ERROR_CODES = {
|
|
45
|
+
// File system related
|
|
46
|
+
FILE_NOT_FOUND: "FILE_NOT_FOUND",
|
|
47
|
+
FILE_READ_ERROR: "FILE_READ_ERROR",
|
|
48
|
+
FILE_WRITE_ERROR: "FILE_WRITE_ERROR",
|
|
49
|
+
FILE_OPERATION_ERROR: "FILE_OPERATION_ERROR",
|
|
50
|
+
|
|
51
|
+
// Document structure related
|
|
52
|
+
MISSING_STRUCTURE_FILE: "MISSING_STRUCTURE_FILE",
|
|
53
|
+
INVALID_STRUCTURE_FILE: "INVALID_STRUCTURE_FILE",
|
|
54
|
+
|
|
55
|
+
// Config related
|
|
56
|
+
MISSING_CONFIG_FILE: "MISSING_CONFIG_FILE",
|
|
57
|
+
MISSING_LOCALE: "MISSING_LOCALE",
|
|
58
|
+
|
|
59
|
+
// Content related
|
|
60
|
+
EMPTY_CONTENT: "EMPTY_CONTENT",
|
|
61
|
+
INVALID_CONTENT: "INVALID_CONTENT",
|
|
62
|
+
|
|
63
|
+
// Path related
|
|
64
|
+
INVALID_PATH: "INVALID_PATH",
|
|
65
|
+
PATH_NOT_IN_STRUCTURE: "PATH_NOT_IN_STRUCTURE",
|
|
66
|
+
INVALID_DOC_PATHS: "INVALID_DOC_PATHS",
|
|
67
|
+
|
|
68
|
+
// Language related
|
|
69
|
+
INVALID_LANGUAGE: "INVALID_LANGUAGE",
|
|
70
|
+
MISSING_LANGS: "MISSING_LANGS",
|
|
71
|
+
MISSING_SOURCE_FILE: "MISSING_SOURCE_FILE",
|
|
72
|
+
|
|
73
|
+
// Content validation related
|
|
74
|
+
SOURCE_LOCALE_MISMATCH: "SOURCE_LOCALE_MISMATCH",
|
|
75
|
+
MISSING_TRANSLATE_LANGUAGE: "MISSING_TRANSLATE_LANGUAGE",
|
|
76
|
+
INVALID_LINK_FORMAT: "INVALID_LINK_FORMAT",
|
|
77
|
+
|
|
78
|
+
// Other
|
|
79
|
+
SAVE_ERROR: "SAVE_ERROR",
|
|
80
|
+
UNEXPECTED_ERROR: "UNEXPECTED_ERROR",
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* File type constants
|
|
85
|
+
*/
|
|
86
|
+
export const FILE_TYPES = {
|
|
87
|
+
META: ".meta.yaml",
|
|
88
|
+
MARKDOWN: ".md",
|
|
89
|
+
YAML: ".yaml",
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Document metadata defaults
|
|
94
|
+
*/
|
|
95
|
+
export const DOC_META_DEFAULTS = {
|
|
96
|
+
KIND: "doc",
|
|
97
|
+
};
|
|
@@ -5,11 +5,7 @@ import { createConnect } from "@aigne/cli/utils/aigne-hub/credential.js";
|
|
|
5
5
|
import chalk from "chalk";
|
|
6
6
|
import open from "open";
|
|
7
7
|
import { joinURL, withQuery } from "ufo";
|
|
8
|
-
import {
|
|
9
|
-
ComponentNotFoundError,
|
|
10
|
-
getComponentMountPoint,
|
|
11
|
-
InvalidBlockletError,
|
|
12
|
-
} from "./blocklet.mjs";
|
|
8
|
+
import { ComponentNotFoundError, getComponentMountPoint, InvalidBlockletError } from "./http.mjs";
|
|
13
9
|
import {
|
|
14
10
|
BLOCKLET_ADD_COMPONENT_DOCS,
|
|
15
11
|
CLOUD_SERVICE_URL_PROD,
|
|
@@ -17,7 +13,7 @@ import {
|
|
|
17
13
|
DISCUSS_KIT_DID,
|
|
18
14
|
DISCUSS_KIT_STORE_URL,
|
|
19
15
|
PAYMENT_KIT_DID,
|
|
20
|
-
} from "./constants
|
|
16
|
+
} from "./constants.mjs";
|
|
21
17
|
import { createStore } from "./store/index.mjs";
|
|
22
18
|
|
|
23
19
|
const WELLKNOWN_SERVICE_PATH_PREFIX = "/.well-known/service";
|
|
@@ -156,12 +152,13 @@ export async function getAccessToken(appUrl, ltToken = "", locale = "en") {
|
|
|
156
152
|
|
|
157
153
|
// Save the access token to config file
|
|
158
154
|
await saveTokenToConfigFile(targetHostname, { DOC_DISCUSS_KIT_ACCESS_TOKEN: accessToken });
|
|
159
|
-
} catch {
|
|
155
|
+
} catch (error) {
|
|
156
|
+
console.error(error.message);
|
|
160
157
|
throw new Error(
|
|
161
158
|
`${chalk.yellow("⚠️ Failed to obtain access token. This may be due to network issues or authorization timeout.")}\n\n` +
|
|
162
159
|
`${chalk.bold("💡 Solution:")}\n` +
|
|
163
160
|
` • Step 1: Ensure your network can access the service URL: ${chalk.cyan(targetOrigin)}\n` +
|
|
164
|
-
` • Step 2:
|
|
161
|
+
` • Step 2: Re-run the document publishing process\n` +
|
|
165
162
|
` • Step 3: If prompted, select ${chalk.cyan("Resume previous website setup")} to continue from where you left off\n\n`,
|
|
166
163
|
);
|
|
167
164
|
}
|
|
@@ -245,7 +242,7 @@ export async function getOfficialAccessToken(baseUrl, openPage = true, locale =
|
|
|
245
242
|
`${chalk.yellow("⚠️ Failed to obtain official access token. This may be due to network issues or authorization timeout.")}\n\n` +
|
|
246
243
|
`${chalk.bold("💡 Solution:")}\n` +
|
|
247
244
|
` • Step 1: Ensure your network can access the official service URL: ${chalk.cyan(targetOrigin)}\n` +
|
|
248
|
-
` • Step 2:
|
|
245
|
+
` • Step 2: Re-run the document publishing process\n`,
|
|
249
246
|
);
|
|
250
247
|
}
|
|
251
248
|
|
|
@@ -2,14 +2,13 @@ import { stat } from "node:fs/promises";
|
|
|
2
2
|
import chalk from "chalk";
|
|
3
3
|
import { joinURL } from "ufo";
|
|
4
4
|
|
|
5
|
-
import { getComponentInfoWithMountPoint } from "
|
|
5
|
+
import { getComponentInfoWithMountPoint, requestWithAuthToken } from "./http.mjs";
|
|
6
6
|
import {
|
|
7
7
|
CLOUD_SERVICE_URL_PROD,
|
|
8
8
|
CLOUD_SERVICE_URL_STAGING,
|
|
9
9
|
DISCUSS_KIT_DID,
|
|
10
|
-
} from "
|
|
11
|
-
import {
|
|
12
|
-
import { uploadFiles } from "../../utils/upload-files.mjs";
|
|
10
|
+
} from "./constants.mjs";
|
|
11
|
+
import { uploadFiles } from "./upload.mjs";
|
|
13
12
|
|
|
14
13
|
export default async function updateBranding({ appUrl, projectInfo, accessToken, finalPath }) {
|
|
15
14
|
try {
|
package/utils/config.mjs
ADDED
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
import { existsSync, mkdirSync } from "node:fs";
|
|
2
|
+
import fs from "node:fs/promises";
|
|
3
|
+
import { constants } from "node:fs";
|
|
4
|
+
import { parse, stringify as yamlStringify } from "yaml";
|
|
5
|
+
import { PATHS, ERROR_CODES } from "./agent-constants.mjs";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Load config from config.yaml file
|
|
9
|
+
* @returns {Promise<Object|null>} - The config object or null if file doesn't exist
|
|
10
|
+
*/
|
|
11
|
+
export async function loadConfigFromFile() {
|
|
12
|
+
try {
|
|
13
|
+
if (!existsSync(PATHS.CONFIG)) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const configContent = await fs.readFile(PATHS.CONFIG, "utf8");
|
|
18
|
+
return parse(configContent);
|
|
19
|
+
} catch (error) {
|
|
20
|
+
console.warn("Failed to read config file:", error.message);
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Handle string value formatting and updating in YAML config
|
|
27
|
+
* @param {string} key - The configuration key
|
|
28
|
+
* @param {string} value - The string value to save
|
|
29
|
+
* @param {string} comment - Optional comment
|
|
30
|
+
* @param {string} fileContent - Current file content
|
|
31
|
+
* @returns {string} Updated file content
|
|
32
|
+
*/
|
|
33
|
+
function handleStringValueUpdate(key, value, comment, fileContent) {
|
|
34
|
+
// Skip if key is empty to avoid "Empty regular expressions are not allowed" error
|
|
35
|
+
if (!key || !key.trim()) {
|
|
36
|
+
return fileContent;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const yamlObject = { [key]: value };
|
|
40
|
+
const yamlContent = yamlStringify(yamlObject).trim();
|
|
41
|
+
const formattedValue = yamlContent.substring(yamlContent.indexOf(":") + 1).trim();
|
|
42
|
+
|
|
43
|
+
const lines = fileContent.split("\n");
|
|
44
|
+
const keyRegex = new RegExp(`^${key}:\\s*`);
|
|
45
|
+
const keyIndex = lines.findIndex((line) => line.match(keyRegex));
|
|
46
|
+
|
|
47
|
+
if (keyIndex !== -1) {
|
|
48
|
+
lines[keyIndex] = `${key}: ${formattedValue}`;
|
|
49
|
+
} else {
|
|
50
|
+
if (comment) {
|
|
51
|
+
lines.push(`# ${comment}`);
|
|
52
|
+
}
|
|
53
|
+
lines.push(`${key}: ${formattedValue}`);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return lines.join("\n");
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Handle array value formatting and updating in YAML config
|
|
61
|
+
* @param {string} key - The configuration key
|
|
62
|
+
* @param {Array} value - The array value to save
|
|
63
|
+
* @param {string} comment - Optional comment
|
|
64
|
+
* @param {string} fileContent - Current file content
|
|
65
|
+
* @returns {string} Updated file content
|
|
66
|
+
*/
|
|
67
|
+
function handleArrayValueUpdate(key, value, comment, fileContent) {
|
|
68
|
+
if (!key || !key.trim()) {
|
|
69
|
+
return fileContent;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const yamlObject = { [key]: value };
|
|
73
|
+
const yamlContent = yamlStringify(yamlObject).trim();
|
|
74
|
+
const formattedValue = yamlContent;
|
|
75
|
+
|
|
76
|
+
const lines = fileContent.split("\n");
|
|
77
|
+
const keyStartIndex = lines.findIndex((line) => line.match(new RegExp(`^${key}:\\s*`)));
|
|
78
|
+
|
|
79
|
+
if (keyStartIndex !== -1) {
|
|
80
|
+
let keyEndIndex = keyStartIndex;
|
|
81
|
+
for (let i = keyStartIndex + 1; i < lines.length; i++) {
|
|
82
|
+
const line = lines[i].trim();
|
|
83
|
+
if (line === "" || line.startsWith("#") || (!line.startsWith("- ") && !line.match(/^\w+:/))) {
|
|
84
|
+
if (!line.startsWith("- ")) {
|
|
85
|
+
keyEndIndex = i - 1;
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
} else if (line.match(/^\w+:/)) {
|
|
89
|
+
keyEndIndex = i - 1;
|
|
90
|
+
break;
|
|
91
|
+
} else if (line.startsWith("- ")) {
|
|
92
|
+
keyEndIndex = i;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (keyEndIndex === keyStartIndex) {
|
|
97
|
+
const keyLine = lines[keyStartIndex];
|
|
98
|
+
if (keyLine.includes("[") || !keyLine.endsWith(":")) {
|
|
99
|
+
keyEndIndex = keyStartIndex;
|
|
100
|
+
} else {
|
|
101
|
+
for (let i = keyStartIndex + 1; i < lines.length; i++) {
|
|
102
|
+
const line = lines[i].trim();
|
|
103
|
+
if (line.startsWith("- ")) {
|
|
104
|
+
keyEndIndex = i;
|
|
105
|
+
} else if (line !== "" && !line.startsWith("#")) {
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const replacementLines = formattedValue.split("\n");
|
|
113
|
+
lines.splice(keyStartIndex, keyEndIndex - keyStartIndex + 1, ...replacementLines);
|
|
114
|
+
|
|
115
|
+
if (comment && keyStartIndex > 0 && !lines[keyStartIndex - 1].trim().startsWith("# ")) {
|
|
116
|
+
lines.splice(keyStartIndex, 0, `# ${comment}`);
|
|
117
|
+
}
|
|
118
|
+
} else {
|
|
119
|
+
if (comment) {
|
|
120
|
+
lines.push(`# ${comment}`);
|
|
121
|
+
}
|
|
122
|
+
const formattedLines = formattedValue.split("\n");
|
|
123
|
+
lines.push(...formattedLines);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return lines.join("\n");
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Save value to config.yaml file
|
|
131
|
+
* @param {string} key - The config key to save
|
|
132
|
+
* @param {string|Array} value - The value to save (can be string or array)
|
|
133
|
+
* @param {string} [comment] - Optional comment to add above the key
|
|
134
|
+
*/
|
|
135
|
+
export async function saveValueToConfig(key, value, comment) {
|
|
136
|
+
if (value === undefined) {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
try {
|
|
141
|
+
const workspaceDir = PATHS.WORKSPACE_BASE;
|
|
142
|
+
if (!existsSync(workspaceDir)) {
|
|
143
|
+
mkdirSync(workspaceDir, { recursive: true });
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
let fileContent = "";
|
|
147
|
+
|
|
148
|
+
if (existsSync(PATHS.CONFIG)) {
|
|
149
|
+
fileContent = await fs.readFile(PATHS.CONFIG, "utf8");
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
let updatedContent;
|
|
153
|
+
if (Array.isArray(value)) {
|
|
154
|
+
updatedContent = handleArrayValueUpdate(key, value, comment, fileContent);
|
|
155
|
+
} else {
|
|
156
|
+
updatedContent = handleStringValueUpdate(key, value, comment, fileContent);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
await fs.writeFile(PATHS.CONFIG, updatedContent);
|
|
160
|
+
} catch (error) {
|
|
161
|
+
console.warn(`Failed to save ${key} to config.yaml:`, error.message);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Generate configuration YAML content
|
|
167
|
+
* @param {Object} input - Input configuration object
|
|
168
|
+
* @returns {string} - YAML configuration string
|
|
169
|
+
*/
|
|
170
|
+
export function generateConfigYAML(input) {
|
|
171
|
+
const config = {
|
|
172
|
+
workspaceVersion: input.workspaceVersion || "1.0",
|
|
173
|
+
createdAt: input.createdAt || new Date().toISOString(),
|
|
174
|
+
projectName: (input.projectName || "").trim(),
|
|
175
|
+
projectDesc: (input.projectDesc || "").trim(),
|
|
176
|
+
projectLogo: input.projectLogo || "",
|
|
177
|
+
locale: input.locale || "en",
|
|
178
|
+
translateLanguages: input.translateLanguages?.filter((lang) => lang.trim()) || [],
|
|
179
|
+
docsDir: input.docsDir || "./docs",
|
|
180
|
+
sourcesPath: input.sourcesPath || [],
|
|
181
|
+
source: input.source || null,
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
let yaml = "# Workspace metadata\n";
|
|
185
|
+
const metadataSection = yamlStringify({
|
|
186
|
+
workspaceVersion: config.workspaceVersion,
|
|
187
|
+
createdAt: config.createdAt,
|
|
188
|
+
}).trim();
|
|
189
|
+
yaml += `${metadataSection}\n\n`;
|
|
190
|
+
|
|
191
|
+
yaml += "# Project information for documentation publishing\n";
|
|
192
|
+
const projectSection = yamlStringify({
|
|
193
|
+
projectName: config.projectName,
|
|
194
|
+
projectDesc: config.projectDesc,
|
|
195
|
+
projectLogo: config.projectLogo,
|
|
196
|
+
}).trim();
|
|
197
|
+
|
|
198
|
+
yaml += `${projectSection}\n\n`;
|
|
199
|
+
|
|
200
|
+
yaml += "# Language settings\n";
|
|
201
|
+
const localeSection = yamlStringify({ locale: config.locale }).trim();
|
|
202
|
+
yaml += `${localeSection}\n`;
|
|
203
|
+
|
|
204
|
+
if (config.translateLanguages.length > 0) {
|
|
205
|
+
const translateLanguagesSection = yamlStringify({
|
|
206
|
+
translateLanguages: config.translateLanguages,
|
|
207
|
+
}).trim();
|
|
208
|
+
yaml += `${translateLanguagesSection}\n`;
|
|
209
|
+
} else {
|
|
210
|
+
yaml += "# translateLanguages: # A list of languages to translate the documentation to.\n";
|
|
211
|
+
yaml += "# - zh # Example: Chinese translation\n";
|
|
212
|
+
yaml += "# - en # Example: English translation\n";
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
yaml += "\n# Source repository configuration\n";
|
|
216
|
+
if (config.source) {
|
|
217
|
+
const sourceSection = yamlStringify({ source: config.source }).trim();
|
|
218
|
+
yaml += `${sourceSection}\n`;
|
|
219
|
+
} else {
|
|
220
|
+
yaml += "# source: # Git submodule source repository\n";
|
|
221
|
+
yaml += "# type: git-submodule\n";
|
|
222
|
+
yaml += "# path: sources/my-project\n";
|
|
223
|
+
yaml += "# url: https://github.com/user/repo.git\n";
|
|
224
|
+
yaml += "# branch: main\n";
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
yaml += "\n# Documentation directory and source paths\n";
|
|
228
|
+
const docsDirSection = yamlStringify({ docsDir: config.docsDir }).trim();
|
|
229
|
+
yaml += `${docsDirSection} # The directory where the generated documentation will be saved.\n`;
|
|
230
|
+
|
|
231
|
+
const sourcesPathSection = yamlStringify({
|
|
232
|
+
sourcesPath: config.sourcesPath,
|
|
233
|
+
}).trim();
|
|
234
|
+
yaml += `${sourcesPathSection.replace(/^sourcesPath:/, "sourcesPath: # The source code paths to analyze.")}\n`;
|
|
235
|
+
|
|
236
|
+
return yaml;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Load config file to get the primary locale
|
|
241
|
+
* @returns {Promise<string>} - Primary language code
|
|
242
|
+
* @throws {Error} - Throws when config file doesn't exist or locale field is missing
|
|
243
|
+
*/
|
|
244
|
+
export async function loadLocale() {
|
|
245
|
+
try {
|
|
246
|
+
await fs.access(PATHS.CONFIG, constants.F_OK | constants.R_OK);
|
|
247
|
+
const content = await fs.readFile(PATHS.CONFIG, "utf8");
|
|
248
|
+
const config = parse(content);
|
|
249
|
+
|
|
250
|
+
if (!config.locale || typeof config.locale !== "string") {
|
|
251
|
+
throw new Error(ERROR_CODES.MISSING_LOCALE);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
return config.locale;
|
|
255
|
+
} catch (error) {
|
|
256
|
+
if (error.message === ERROR_CODES.MISSING_LOCALE) {
|
|
257
|
+
throw error;
|
|
258
|
+
}
|
|
259
|
+
throw new Error(ERROR_CODES.MISSING_CONFIG_FILE);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// Publishing feature related constants (minimal version)
|
|
2
|
+
|
|
3
|
+
// Component mount point ID for Discuss Kit
|
|
4
|
+
export const DISCUSS_KIT_DID = "z8ia1WEiBZ7hxURf6LwH21Wpg99vophFwSJdu";
|
|
5
|
+
export const MEDIA_KIT_DID = "z8ia1mAXo8ZE7ytGF36L5uBf9kD2kenhqFGp9";
|
|
6
|
+
export const PAYMENT_KIT_DID = "z2qaCNvKMv5GjouKdcDWexv6WqtHbpNPQDnAk";
|
|
7
|
+
|
|
8
|
+
// Default application URL for the document deployment website
|
|
9
|
+
export const CLOUD_SERVICE_URL_PROD = "https://docsmith.aigne.io";
|
|
10
|
+
export const CLOUD_SERVICE_URL_STAGING = "https://staging.docsmith.aigne.io";
|
|
11
|
+
|
|
12
|
+
// Discuss Kit related URLs
|
|
13
|
+
export const DISCUSS_KIT_STORE_URL =
|
|
14
|
+
"https://store.blocklet.dev/blocklets/z8ia1WEiBZ7hxURf6LwH21Wpg99vophFwSJdu";
|
|
15
|
+
export const BLOCKLET_ADD_COMPONENT_DOCS =
|
|
16
|
+
"https://www.arcblock.io/docs/blocklet-developer/en/7zbw0GQXgcD6sCcjVfwqqT2s";
|
|
17
|
+
|
|
18
|
+
// Supported languages for documentation
|
|
19
|
+
export const SUPPORTED_LANGUAGES = [
|
|
20
|
+
{ code: "en", label: "English (en)", sample: "Hello" },
|
|
21
|
+
{ code: "zh", label: "简体中文 (zh)", sample: "你好" },
|
|
22
|
+
{ code: "zh-TW", label: "繁體中文 (zh-TW)", sample: "你好" },
|
|
23
|
+
{ code: "ja", label: "日本語 (ja)", sample: "こんにちは" },
|
|
24
|
+
{ code: "ko", label: "한국어 (ko)", sample: "안녕하세요" },
|
|
25
|
+
{ code: "es", label: "Español (es)", sample: "Hola" },
|
|
26
|
+
{ code: "fr", label: "Français (fr)", sample: "Bonjour" },
|
|
27
|
+
{ code: "de", label: "Deutsch (de)", sample: "Hallo" },
|
|
28
|
+
{ code: "pt", label: "Português (pt)", sample: "Olá" },
|
|
29
|
+
{ code: "ru", label: "Русский (ru)", sample: "Привет" },
|
|
30
|
+
{ code: "it", label: "Italiano (it)", sample: "Ciao" },
|
|
31
|
+
{ code: "ar", label: "العربية (ar)", sample: "مرحبا" },
|
|
32
|
+
];
|
package/utils/deploy.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { BrokerClient, STEPS } from "@blocklet/payment-broker-client/node";
|
|
2
2
|
import chalk from "chalk";
|
|
3
3
|
import open from "open";
|
|
4
|
-
import { getOfficialAccessToken } from "./auth
|
|
5
|
-
import { CLOUD_SERVICE_URL_PROD } from "./constants
|
|
6
|
-
import { saveValueToConfig } from "./
|
|
4
|
+
import { getOfficialAccessToken } from "./auth.mjs";
|
|
5
|
+
import { CLOUD_SERVICE_URL_PROD } from "./constants.mjs";
|
|
6
|
+
import { saveValueToConfig } from "./config.mjs";
|
|
7
7
|
|
|
8
8
|
const BASE_URL = process.env.DOC_SMITH_BASE_URL || CLOUD_SERVICE_URL_PROD;
|
|
9
9
|
const SUCCESS_MESSAGE = {
|