@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
package/agents/init/index.mjs
DELETED
|
@@ -1,643 +0,0 @@
|
|
|
1
|
-
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
2
|
-
import { dirname, join } from "node:path";
|
|
3
|
-
import chalk from "chalk";
|
|
4
|
-
import { stringify as yamlStringify } from "yaml";
|
|
5
|
-
import { getFilteredOptions } from "../../utils/conflict-detector.mjs";
|
|
6
|
-
import {
|
|
7
|
-
DEFAULT_REASONING_EFFORT_LEVEL,
|
|
8
|
-
DEFAULT_THINKING_EFFORT_LEVEL,
|
|
9
|
-
DEPTH_RECOMMENDATION_LOGIC,
|
|
10
|
-
DIAGRAM_STYLES,
|
|
11
|
-
DOCUMENT_STYLES,
|
|
12
|
-
DOCUMENTATION_DEPTH,
|
|
13
|
-
PURPOSE_TO_KNOWLEDGE_MAPPING,
|
|
14
|
-
READER_KNOWLEDGE_LEVELS,
|
|
15
|
-
SUPPORTED_LANGUAGES,
|
|
16
|
-
TARGET_AUDIENCES,
|
|
17
|
-
} from "../../utils/constants/index.mjs";
|
|
18
|
-
import { isRemoteFile } from "../../utils/file-utils.mjs";
|
|
19
|
-
import loadConfig from "../../utils/load-config.mjs";
|
|
20
|
-
import {
|
|
21
|
-
detectSystemLanguage,
|
|
22
|
-
getAvailablePaths,
|
|
23
|
-
getProjectInfo,
|
|
24
|
-
isGlobPattern,
|
|
25
|
-
validatePath,
|
|
26
|
-
} from "../../utils/utils.mjs";
|
|
27
|
-
import mapReasoningEffortLevel from "../utils/map-reasoning-effort-level.mjs";
|
|
28
|
-
import { validateDocDir } from "./validate.mjs";
|
|
29
|
-
|
|
30
|
-
const _PRESS_ENTER_TO_FINISH = "Press Enter to finish";
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Guides the user through a multi-turn dialog to generate a YAML configuration file.
|
|
34
|
-
* @param {Object} params
|
|
35
|
-
* @param {string} params.outputPath - The path to the output file.
|
|
36
|
-
* @param {string} params.fileName - The name of the file.
|
|
37
|
-
* @returns {Promise<Object>}
|
|
38
|
-
*/
|
|
39
|
-
export default async function init(input, options) {
|
|
40
|
-
const config = await _init(input, options);
|
|
41
|
-
|
|
42
|
-
// Set thinking effort (lite/standard/pro) and map to reasoningEffort
|
|
43
|
-
options.context.userContext.thinkingEffort =
|
|
44
|
-
config.thinking?.effort || DEFAULT_THINKING_EFFORT_LEVEL;
|
|
45
|
-
|
|
46
|
-
// Set global reasoningEffort based on thinkingEffort
|
|
47
|
-
options.context.userContext.reasoningEffort = mapReasoningEffortLevel(
|
|
48
|
-
{ level: DEFAULT_REASONING_EFFORT_LEVEL },
|
|
49
|
-
options,
|
|
50
|
-
)?.reasoningEffort;
|
|
51
|
-
|
|
52
|
-
// for translation agent
|
|
53
|
-
if (config.translateLanguages) {
|
|
54
|
-
config.translates = config.translateLanguages.map((lang) => ({ language: lang }));
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return {
|
|
58
|
-
...config,
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
async function _init(
|
|
63
|
-
{
|
|
64
|
-
outputPath = ".aigne/doc-smith",
|
|
65
|
-
fileName = "config.yaml",
|
|
66
|
-
skipIfExists = false,
|
|
67
|
-
appUrl,
|
|
68
|
-
checkOnly = false,
|
|
69
|
-
},
|
|
70
|
-
options,
|
|
71
|
-
) {
|
|
72
|
-
// Check if we're in checkOnly mode
|
|
73
|
-
if (checkOnly) {
|
|
74
|
-
const filePath = join(outputPath, fileName);
|
|
75
|
-
const configContent = await readFile(filePath, "utf8").catch(() => null);
|
|
76
|
-
|
|
77
|
-
if (!configContent || configContent.trim() === "") {
|
|
78
|
-
console.log("⚠️ No configuration file found.");
|
|
79
|
-
console.log(
|
|
80
|
-
`🚀 Run ${chalk.cyan("aigne doc init")} to set up your documentation configuration.`,
|
|
81
|
-
);
|
|
82
|
-
process.exit(0);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
// Config exists, load and return it
|
|
86
|
-
return loadConfig({ config: filePath, appUrl });
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
if (skipIfExists) {
|
|
90
|
-
const filePath = join(outputPath, fileName);
|
|
91
|
-
const configContent = await readFile(filePath, "utf8").catch(() => null);
|
|
92
|
-
// Only skip if file exists AND has non-empty content
|
|
93
|
-
if (configContent && configContent.trim() !== "") {
|
|
94
|
-
// load config from file
|
|
95
|
-
const config = await loadConfig({ config: filePath, appUrl });
|
|
96
|
-
const isValid = validateDocDir(config.docsDir);
|
|
97
|
-
if (typeof isValid === "string") {
|
|
98
|
-
console.log(
|
|
99
|
-
`${chalk.red("Invalid docsDir")}: ${isValid}\nPlease check your configuration.`,
|
|
100
|
-
);
|
|
101
|
-
process.exit(1);
|
|
102
|
-
}
|
|
103
|
-
if (!isValid) {
|
|
104
|
-
console.log(`${chalk.red("Invalid docsDir")}, please check your configuration.`);
|
|
105
|
-
process.exit(1);
|
|
106
|
-
}
|
|
107
|
-
return config;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
console.log("🚀 Welcome to AIGNE DocSmith!");
|
|
112
|
-
console.log("Let's set up your documentation preferences.\n");
|
|
113
|
-
|
|
114
|
-
const input = {};
|
|
115
|
-
|
|
116
|
-
const purposeChoices = await options.prompts.checkbox({
|
|
117
|
-
message: "📝 [1/9]: What should your documentation help readers achieve?",
|
|
118
|
-
choices: Object.entries(DOCUMENT_STYLES)
|
|
119
|
-
.filter(([key]) => key !== "custom")
|
|
120
|
-
.map(([key, style]) => ({
|
|
121
|
-
name: `${style.name}`,
|
|
122
|
-
description: style.description,
|
|
123
|
-
value: key,
|
|
124
|
-
})),
|
|
125
|
-
validate: (input) => {
|
|
126
|
-
if (input.length === 0) {
|
|
127
|
-
return "You must choose at least one goal for your documentation.";
|
|
128
|
-
}
|
|
129
|
-
return true;
|
|
130
|
-
},
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
let prioritizedPurposes = purposeChoices;
|
|
134
|
-
if (purposeChoices.length === 1 && purposeChoices.includes("mixedPurpose")) {
|
|
135
|
-
const topPriorities = await options.prompts.checkbox({
|
|
136
|
-
message: "🎯 Which is most important? (Select up to 2 priorities)",
|
|
137
|
-
choices: Object.entries(DOCUMENT_STYLES)
|
|
138
|
-
.filter(([key]) => key !== "custom" && key !== "mixedPurpose")
|
|
139
|
-
.map(([key, style]) => ({
|
|
140
|
-
name: `${style.name}`,
|
|
141
|
-
description: style.description,
|
|
142
|
-
value: key,
|
|
143
|
-
})),
|
|
144
|
-
validate: (input) => {
|
|
145
|
-
if (input.length === 0) {
|
|
146
|
-
return "You must choose at least one priority.";
|
|
147
|
-
}
|
|
148
|
-
if (input.length > 2) {
|
|
149
|
-
return "You may only choose up to 2 priorities.";
|
|
150
|
-
}
|
|
151
|
-
return true;
|
|
152
|
-
},
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
prioritizedPurposes = topPriorities;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
input.documentPurpose = prioritizedPurposes;
|
|
159
|
-
|
|
160
|
-
const audienceChoices = await options.prompts.checkbox({
|
|
161
|
-
message: "👥 [2/9]: Who will be reading your documentation?",
|
|
162
|
-
choices: Object.entries(TARGET_AUDIENCES)
|
|
163
|
-
.filter(([key]) => key !== "custom")
|
|
164
|
-
.map(([key, audience]) => ({
|
|
165
|
-
name: `${audience.name}`,
|
|
166
|
-
description: audience.description,
|
|
167
|
-
value: key,
|
|
168
|
-
})),
|
|
169
|
-
validate: (input) => {
|
|
170
|
-
if (input.length === 0) {
|
|
171
|
-
return "You must choose at least one audience.";
|
|
172
|
-
}
|
|
173
|
-
return true;
|
|
174
|
-
},
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
input.targetAudienceTypes = audienceChoices;
|
|
178
|
-
|
|
179
|
-
const mappedPurpose = prioritizedPurposes.find(
|
|
180
|
-
(purpose) => PURPOSE_TO_KNOWLEDGE_MAPPING[purpose],
|
|
181
|
-
);
|
|
182
|
-
const defaultKnowledge = mappedPurpose ? PURPOSE_TO_KNOWLEDGE_MAPPING[mappedPurpose] : null;
|
|
183
|
-
|
|
184
|
-
const { filteredOptions: filteredKnowledgeOptions } = getFilteredOptions(
|
|
185
|
-
"readerKnowledgeLevel",
|
|
186
|
-
{ documentPurpose: prioritizedPurposes, targetAudienceTypes: audienceChoices },
|
|
187
|
-
READER_KNOWLEDGE_LEVELS,
|
|
188
|
-
);
|
|
189
|
-
|
|
190
|
-
const knowledgeChoice = await options.prompts.select({
|
|
191
|
-
message: "🧠 [3/9]: How much do your readers already know about your project?",
|
|
192
|
-
choices: Object.entries(filteredKnowledgeOptions).map(([key, level]) => ({
|
|
193
|
-
name: `${level.name}`,
|
|
194
|
-
description: level.description,
|
|
195
|
-
value: key,
|
|
196
|
-
})),
|
|
197
|
-
default: defaultKnowledge,
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
// Save reader knowledge level choice as key
|
|
201
|
-
input.readerKnowledgeLevel = knowledgeChoice;
|
|
202
|
-
|
|
203
|
-
// 4. Documentation depth - how comprehensive should the documentation be?
|
|
204
|
-
// Determine default based on priority: Purpose > Audience > Knowledge Level
|
|
205
|
-
const getDepthDefault = () => {
|
|
206
|
-
// Check priority order: purposes -> audiences -> knowledgeLevels
|
|
207
|
-
const checks = [
|
|
208
|
-
() => {
|
|
209
|
-
const purpose = prioritizedPurposes.find((p) => DEPTH_RECOMMENDATION_LOGIC.purposes[p]);
|
|
210
|
-
return purpose ? DEPTH_RECOMMENDATION_LOGIC.purposes[purpose] : null;
|
|
211
|
-
},
|
|
212
|
-
() => {
|
|
213
|
-
const audience = audienceChoices.find((a) => DEPTH_RECOMMENDATION_LOGIC.audiences[a]);
|
|
214
|
-
return audience ? DEPTH_RECOMMENDATION_LOGIC.audiences[audience] : null;
|
|
215
|
-
},
|
|
216
|
-
() => DEPTH_RECOMMENDATION_LOGIC.knowledgeLevels[knowledgeChoice] || null,
|
|
217
|
-
];
|
|
218
|
-
|
|
219
|
-
return checks.find((check) => check())?.() || null;
|
|
220
|
-
};
|
|
221
|
-
|
|
222
|
-
const defaultDepth = getDepthDefault();
|
|
223
|
-
|
|
224
|
-
// Filter documentation depth options based on all previous selections
|
|
225
|
-
const { filteredOptions: filteredDepthOptions } = getFilteredOptions(
|
|
226
|
-
"documentationDepth",
|
|
227
|
-
{
|
|
228
|
-
documentPurpose: prioritizedPurposes,
|
|
229
|
-
targetAudienceTypes: audienceChoices,
|
|
230
|
-
readerKnowledgeLevel: knowledgeChoice,
|
|
231
|
-
},
|
|
232
|
-
DOCUMENTATION_DEPTH,
|
|
233
|
-
);
|
|
234
|
-
|
|
235
|
-
const depthChoice = await options.prompts.select({
|
|
236
|
-
message: "📊 [4/9]: How detailed should your documentation be?",
|
|
237
|
-
choices: Object.entries(filteredDepthOptions).map(([key, depth]) => ({
|
|
238
|
-
name: `${depth.name}`,
|
|
239
|
-
description: depth.description,
|
|
240
|
-
value: key,
|
|
241
|
-
})),
|
|
242
|
-
default: defaultDepth,
|
|
243
|
-
});
|
|
244
|
-
|
|
245
|
-
// Save documentation depth choice as key
|
|
246
|
-
input.documentationDepth = depthChoice;
|
|
247
|
-
|
|
248
|
-
// 5. Language settings
|
|
249
|
-
// Detect system language and use as default
|
|
250
|
-
const systemLanguage = detectSystemLanguage();
|
|
251
|
-
|
|
252
|
-
// Let user select primary language from supported list
|
|
253
|
-
const primaryLanguageChoice = await options.prompts.select({
|
|
254
|
-
message: "🌐 [5/9]: What is the main language of your documentation?",
|
|
255
|
-
choices: SUPPORTED_LANGUAGES.map((lang) => ({
|
|
256
|
-
name: `${lang.label} - ${lang.sample}`,
|
|
257
|
-
value: lang.code,
|
|
258
|
-
})),
|
|
259
|
-
default: systemLanguage,
|
|
260
|
-
});
|
|
261
|
-
|
|
262
|
-
input.locale = primaryLanguageChoice;
|
|
263
|
-
|
|
264
|
-
// 6. Translation languages
|
|
265
|
-
// Filter out the primary language from available choices
|
|
266
|
-
const availableTranslationLanguages = SUPPORTED_LANGUAGES.filter(
|
|
267
|
-
(lang) => lang.code !== primaryLanguageChoice,
|
|
268
|
-
);
|
|
269
|
-
|
|
270
|
-
const translateLanguageChoices = await options.prompts.checkbox({
|
|
271
|
-
message: "🔄 [6/9]: What languages should we translate to?",
|
|
272
|
-
choices: availableTranslationLanguages.map((lang) => ({
|
|
273
|
-
name: `${lang.label} - ${lang.sample}`,
|
|
274
|
-
value: lang.code,
|
|
275
|
-
})),
|
|
276
|
-
});
|
|
277
|
-
|
|
278
|
-
input.translateLanguages = translateLanguageChoices;
|
|
279
|
-
|
|
280
|
-
// 7. Documentation directory
|
|
281
|
-
const docsDirInput = await options.prompts.input({
|
|
282
|
-
message: `📁 [7/9]: Where should we save your documentation?`,
|
|
283
|
-
default: `${outputPath}/docs`,
|
|
284
|
-
validate: validateDocDir,
|
|
285
|
-
});
|
|
286
|
-
input.docsDir = docsDirInput.trim() || `${outputPath}/docs`;
|
|
287
|
-
|
|
288
|
-
// 8. Content sources
|
|
289
|
-
console.log("🔍 [8/9]: Data Sources");
|
|
290
|
-
console.log("Please specify the data source we should analyze to generate your documentation.");
|
|
291
|
-
console.log(
|
|
292
|
-
` 1. Use paths like ${chalk.green("./src")}, ${chalk.green("./README.md")} or ${chalk.green("!./src/private")}.`,
|
|
293
|
-
);
|
|
294
|
-
console.log(
|
|
295
|
-
` 2. Use globs like ${chalk.green("src/**/*.js")} or ${chalk.green(
|
|
296
|
-
"!private/**/*.js",
|
|
297
|
-
)} for more specific file matching.`,
|
|
298
|
-
);
|
|
299
|
-
console.log(` 3. Use URLs like ${chalk.green("https://example.com/openapi.yaml")}.`);
|
|
300
|
-
console.log("💡 If you leave this empty, we will scan the entire directory.");
|
|
301
|
-
|
|
302
|
-
const sourcePaths = [];
|
|
303
|
-
while (true) {
|
|
304
|
-
const selectedPath = await options.prompts.search({
|
|
305
|
-
message: "Please enter a valid data source:",
|
|
306
|
-
source: async (input) => {
|
|
307
|
-
if (!input || input.trim() === "") {
|
|
308
|
-
return [
|
|
309
|
-
{
|
|
310
|
-
name: "",
|
|
311
|
-
value: "",
|
|
312
|
-
description: _PRESS_ENTER_TO_FINISH,
|
|
313
|
-
},
|
|
314
|
-
];
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
let isIgnore = false;
|
|
318
|
-
const searchTerm = input.trim();
|
|
319
|
-
let cleanSearchTerm = searchTerm;
|
|
320
|
-
if (cleanSearchTerm.startsWith("!")) {
|
|
321
|
-
isIgnore = true;
|
|
322
|
-
cleanSearchTerm = searchTerm.slice(1);
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
// Search for matching files and folders in current directory
|
|
326
|
-
const availablePaths = getAvailablePaths(cleanSearchTerm);
|
|
327
|
-
|
|
328
|
-
// Also add option to use as glob pattern
|
|
329
|
-
const options = [...availablePaths].map((x) => ({
|
|
330
|
-
...x,
|
|
331
|
-
name: isIgnore ? `!${x.name}` : x.name,
|
|
332
|
-
value: isIgnore ? `!${x.value}` : x.value,
|
|
333
|
-
}));
|
|
334
|
-
|
|
335
|
-
// Check if input looks like a glob pattern
|
|
336
|
-
const isGlobPatternResult = isGlobPattern(searchTerm);
|
|
337
|
-
if (isGlobPatternResult) {
|
|
338
|
-
// If it looks like a glob pattern, allow direct input
|
|
339
|
-
options.push({
|
|
340
|
-
name: searchTerm,
|
|
341
|
-
value: searchTerm,
|
|
342
|
-
description: "Use this glob pattern for file matching.",
|
|
343
|
-
});
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
if (!isIgnore && isRemoteFile(searchTerm)) {
|
|
347
|
-
options.push({
|
|
348
|
-
name: searchTerm,
|
|
349
|
-
value: searchTerm,
|
|
350
|
-
description: "Use this remote url for content source.",
|
|
351
|
-
});
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
return options;
|
|
355
|
-
},
|
|
356
|
-
});
|
|
357
|
-
|
|
358
|
-
// Check if user chose to exit
|
|
359
|
-
if (!selectedPath || selectedPath.trim() === "" || selectedPath === _PRESS_ENTER_TO_FINISH) {
|
|
360
|
-
break;
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
const trimmedPath = selectedPath.trim();
|
|
364
|
-
|
|
365
|
-
// Check if it's a glob pattern
|
|
366
|
-
const isGlobPatternResult = isGlobPattern(trimmedPath);
|
|
367
|
-
|
|
368
|
-
if (isRemoteFile(trimmedPath)) {
|
|
369
|
-
// For remote urls, just add them without validation
|
|
370
|
-
if (sourcePaths.includes(trimmedPath)) {
|
|
371
|
-
console.log(`⚠️ URL already exists: ${trimmedPath}`);
|
|
372
|
-
continue;
|
|
373
|
-
}
|
|
374
|
-
sourcePaths.push(trimmedPath);
|
|
375
|
-
} else if (isGlobPatternResult) {
|
|
376
|
-
// For glob patterns, just add them without validation
|
|
377
|
-
if (sourcePaths.includes(trimmedPath)) {
|
|
378
|
-
console.log(`⚠️ Pattern already exists: ${trimmedPath}`);
|
|
379
|
-
continue;
|
|
380
|
-
}
|
|
381
|
-
sourcePaths.push(trimmedPath);
|
|
382
|
-
} else {
|
|
383
|
-
const cleanTrimmedPath = trimmedPath.startsWith("!") ? trimmedPath.slice(1) : trimmedPath;
|
|
384
|
-
// Use validatePath to check if path is valid for regular paths
|
|
385
|
-
const validation = validatePath(cleanTrimmedPath);
|
|
386
|
-
|
|
387
|
-
if (!validation.isValid) {
|
|
388
|
-
console.log(`⚠️ ${validation.error}`);
|
|
389
|
-
continue;
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
// Avoid duplicate paths
|
|
393
|
-
if (sourcePaths.includes(trimmedPath)) {
|
|
394
|
-
console.log(`⚠️ Path already exists: ${trimmedPath}`);
|
|
395
|
-
continue;
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
sourcePaths.push(trimmedPath);
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
// If no paths entered, use default
|
|
403
|
-
input.sourcesPath = sourcePaths.length > 0 ? sourcePaths : ["./"];
|
|
404
|
-
|
|
405
|
-
// 9. Custom rules - any specific requirements for the documentation?
|
|
406
|
-
const rulesInput = await options.prompts.input({
|
|
407
|
-
message:
|
|
408
|
-
"📋 [9/9]: Do you have any custom rules or requirements for your documentation? (Optional, press Enter to skip)",
|
|
409
|
-
default: "",
|
|
410
|
-
});
|
|
411
|
-
input.rules = rulesInput.trim();
|
|
412
|
-
|
|
413
|
-
// Save project info to config
|
|
414
|
-
const projectInfo = await getProjectInfo();
|
|
415
|
-
// Remove leading and trailing spaces (middle spaces are preserved and count toward limit)
|
|
416
|
-
input.projectName = projectInfo.name.trim();
|
|
417
|
-
input.projectDesc = projectInfo.description.trim();
|
|
418
|
-
input.projectLogo = projectInfo.icon;
|
|
419
|
-
|
|
420
|
-
// Generate YAML content
|
|
421
|
-
const yamlContent = generateYAML(input, outputPath);
|
|
422
|
-
|
|
423
|
-
// Save file
|
|
424
|
-
try {
|
|
425
|
-
const filePath = join(outputPath, fileName);
|
|
426
|
-
const dirPath = dirname(filePath);
|
|
427
|
-
|
|
428
|
-
// Create directory if it doesn't exist
|
|
429
|
-
await mkdir(dirPath, { recursive: true });
|
|
430
|
-
|
|
431
|
-
await writeFile(filePath, yamlContent, "utf8");
|
|
432
|
-
console.log(
|
|
433
|
-
`\n✅ Setup complete! Your configuration has been saved to: ${chalk.cyan(filePath)}`,
|
|
434
|
-
);
|
|
435
|
-
console.log("💡 You can edit this file at any time to change your settings.\n");
|
|
436
|
-
console.log(`🚀 To generate your documentation, run: ${chalk.cyan("aigne doc create")}\n`);
|
|
437
|
-
|
|
438
|
-
if (skipIfExists) {
|
|
439
|
-
return loadConfig({ config: filePath, appUrl });
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
return {};
|
|
443
|
-
} catch (error) {
|
|
444
|
-
console.error(
|
|
445
|
-
`❌ Sorry, I encountered an error while saving your configuration file: ${error.message}`,
|
|
446
|
-
);
|
|
447
|
-
return {
|
|
448
|
-
inputGeneratorStatus: false,
|
|
449
|
-
inputGeneratorError: error.message,
|
|
450
|
-
};
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
/**
|
|
455
|
-
* Generate YAML configuration content
|
|
456
|
-
* @param {Object} input - Input object
|
|
457
|
-
* @returns {string} YAML string
|
|
458
|
-
*/
|
|
459
|
-
export function generateYAML(input) {
|
|
460
|
-
// Create the main configuration object that will be safely serialized
|
|
461
|
-
const config = {
|
|
462
|
-
// Project information (safely handled by yaml library)
|
|
463
|
-
// Remove leading and trailing spaces (middle spaces are preserved and count toward limit)
|
|
464
|
-
projectName: (input.projectName || "").trim(),
|
|
465
|
-
projectDesc: (input.projectDesc || "").trim(),
|
|
466
|
-
projectLogo: input.projectLogo || "",
|
|
467
|
-
|
|
468
|
-
thinking: {
|
|
469
|
-
effort: input.thinking?.effort || DEFAULT_THINKING_EFFORT_LEVEL,
|
|
470
|
-
},
|
|
471
|
-
|
|
472
|
-
// Documentation configuration
|
|
473
|
-
documentPurpose: input.documentPurpose || [],
|
|
474
|
-
targetAudienceTypes: input.targetAudienceTypes || [],
|
|
475
|
-
readerKnowledgeLevel: input.readerKnowledgeLevel || "",
|
|
476
|
-
documentationDepth: input.documentationDepth || "",
|
|
477
|
-
|
|
478
|
-
// Custom rules and target audience (empty for user to fill)
|
|
479
|
-
rules: input.rules || "",
|
|
480
|
-
targetAudience: "",
|
|
481
|
-
|
|
482
|
-
// Language settings
|
|
483
|
-
locale: input.locale || "en",
|
|
484
|
-
translateLanguages: input.translateLanguages?.filter((lang) => lang.trim()) || [],
|
|
485
|
-
|
|
486
|
-
// Paths
|
|
487
|
-
docsDir: input.docsDir || "./aigne/doc-smith/docs",
|
|
488
|
-
sourcesPath: input.sourcesPath || [],
|
|
489
|
-
media: {
|
|
490
|
-
// Image filtering settings
|
|
491
|
-
minImageWidth: input.minImageWidth || 800,
|
|
492
|
-
},
|
|
493
|
-
};
|
|
494
|
-
|
|
495
|
-
// Generate comments and structure
|
|
496
|
-
let yaml = "# Project information for documentation publishing\n";
|
|
497
|
-
|
|
498
|
-
// Serialize the project info section safely with string quoting
|
|
499
|
-
const projectSection = yamlStringify({
|
|
500
|
-
projectName: config.projectName,
|
|
501
|
-
projectDesc: config.projectDesc,
|
|
502
|
-
projectLogo: config.projectLogo,
|
|
503
|
-
}).trim();
|
|
504
|
-
|
|
505
|
-
yaml += `${projectSection}\n\n`;
|
|
506
|
-
|
|
507
|
-
const modelSection = yamlStringify({
|
|
508
|
-
thinking: config.thinking,
|
|
509
|
-
}).trim();
|
|
510
|
-
|
|
511
|
-
yaml += `\
|
|
512
|
-
# AI Thinking Configuration
|
|
513
|
-
# thinking.effort: Determines the depth of reasoning and cognitive effort the AI uses when responding, available options:
|
|
514
|
-
# - lite: Fast responses with basic reasoning
|
|
515
|
-
# - standard: Balanced speed and reasoning capability
|
|
516
|
-
# - pro: In-depth reasoning with longer response times
|
|
517
|
-
${modelSection}
|
|
518
|
-
\n`;
|
|
519
|
-
|
|
520
|
-
// Add documentation configuration with comments
|
|
521
|
-
yaml += "# =============================================================================\n";
|
|
522
|
-
yaml += "# Documentation Configuration\n";
|
|
523
|
-
yaml += "# =============================================================================\n\n";
|
|
524
|
-
|
|
525
|
-
// Document Purpose with all available options
|
|
526
|
-
yaml += "# Purpose: What's the main outcome you want readers to achieve?\n";
|
|
527
|
-
yaml += "# Available options (uncomment and modify as needed):\n";
|
|
528
|
-
Object.entries(DOCUMENT_STYLES).forEach(([key, style]) => {
|
|
529
|
-
if (key !== "custom") {
|
|
530
|
-
yaml += `# ${key.padEnd(16)} - ${style.name}: ${style.description}\n`;
|
|
531
|
-
}
|
|
532
|
-
});
|
|
533
|
-
|
|
534
|
-
// Safely serialize documentPurpose
|
|
535
|
-
const documentPurposeSection = yamlStringify({ documentPurpose: config.documentPurpose }).trim();
|
|
536
|
-
yaml += `${documentPurposeSection.replace(/^documentPurpose:/, "documentPurpose:")}\n\n`;
|
|
537
|
-
|
|
538
|
-
// Target Audience Types with all available options
|
|
539
|
-
yaml += "# Target Audience: Who will be reading this most often?\n";
|
|
540
|
-
yaml += "# Available options (uncomment and modify as needed):\n";
|
|
541
|
-
Object.entries(TARGET_AUDIENCES).forEach(([key, audience]) => {
|
|
542
|
-
if (key !== "custom") {
|
|
543
|
-
yaml += `# ${key.padEnd(16)} - ${audience.name}: ${audience.description}\n`;
|
|
544
|
-
}
|
|
545
|
-
});
|
|
546
|
-
|
|
547
|
-
// Safely serialize targetAudienceTypes
|
|
548
|
-
const targetAudienceTypesSection = yamlStringify({
|
|
549
|
-
targetAudienceTypes: config.targetAudienceTypes,
|
|
550
|
-
}).trim();
|
|
551
|
-
yaml += `${targetAudienceTypesSection.replace(/^targetAudienceTypes:/, "targetAudienceTypes:")}\n\n`;
|
|
552
|
-
|
|
553
|
-
// Reader Knowledge Level with all available options
|
|
554
|
-
yaml += "# Reader Knowledge Level: What do readers typically know when they arrive?\n";
|
|
555
|
-
yaml += "# Available options (uncomment and modify as needed):\n";
|
|
556
|
-
Object.entries(READER_KNOWLEDGE_LEVELS).forEach(([key, level]) => {
|
|
557
|
-
yaml += `# ${key.padEnd(20)} - ${level.name}: ${level.description}\n`;
|
|
558
|
-
});
|
|
559
|
-
|
|
560
|
-
// Safely serialize readerKnowledgeLevel
|
|
561
|
-
const readerKnowledgeLevelSection = yamlStringify({
|
|
562
|
-
readerKnowledgeLevel: config.readerKnowledgeLevel,
|
|
563
|
-
}).trim();
|
|
564
|
-
yaml += `${readerKnowledgeLevelSection.replace(/^readerKnowledgeLevel:/, "readerKnowledgeLevel:")}\n\n`;
|
|
565
|
-
|
|
566
|
-
// Documentation Depth with all available options
|
|
567
|
-
yaml += "# Documentation Depth: How comprehensive should the documentation be?\n";
|
|
568
|
-
yaml += "# Available options (uncomment and modify as needed):\n";
|
|
569
|
-
Object.entries(DOCUMENTATION_DEPTH).forEach(([key, depth]) => {
|
|
570
|
-
yaml += `# ${key.padEnd(18)} - ${depth.name}: ${depth.description}\n`;
|
|
571
|
-
});
|
|
572
|
-
|
|
573
|
-
// Safely serialize documentationDepth
|
|
574
|
-
const documentationDepthSection = yamlStringify({
|
|
575
|
-
documentationDepth: config.documentationDepth,
|
|
576
|
-
}).trim();
|
|
577
|
-
yaml += `${documentationDepthSection.replace(/^documentationDepth:/, "documentationDepth:")}\n\n`;
|
|
578
|
-
|
|
579
|
-
// Custom Documentation Rules and Requirements
|
|
580
|
-
yaml += "# Custom Rules: Define specific documentation generation rules and requirements\n";
|
|
581
|
-
const rulesSection = yamlStringify({ rules: config.rules }).trim();
|
|
582
|
-
// Use literal style for multiline strings
|
|
583
|
-
yaml += `${rulesSection.replace(/rules: ''/, "rules: |\n ")}\n\n`;
|
|
584
|
-
|
|
585
|
-
// Target Audience Description
|
|
586
|
-
yaml += "# Target Audience: Describe your specific target audience and their characteristics.\n";
|
|
587
|
-
const targetAudienceSection = yamlStringify({ targetAudience: config.targetAudience }).trim();
|
|
588
|
-
// Use literal style for multiline strings
|
|
589
|
-
yaml += `${targetAudienceSection.replace(/targetAudience: ''/, "targetAudience: |\n ")}\n\n`;
|
|
590
|
-
|
|
591
|
-
// Glossary Configuration
|
|
592
|
-
yaml += "# Glossary: Define project-specific terms and definitions.\n";
|
|
593
|
-
yaml +=
|
|
594
|
-
'# glossary: "@glossary.md" # Path to a markdown file containing glossary definitions.\n\n';
|
|
595
|
-
|
|
596
|
-
// Language settings - safely serialize
|
|
597
|
-
const localeSection = yamlStringify({ locale: config.locale }).trim();
|
|
598
|
-
yaml += `${localeSection.replace(/^locale:/, "locale:")}\n`;
|
|
599
|
-
|
|
600
|
-
// Translation languages
|
|
601
|
-
if (config.translateLanguages.length > 0) {
|
|
602
|
-
const translateLanguagesSection = yamlStringify({
|
|
603
|
-
translateLanguages: config.translateLanguages,
|
|
604
|
-
}).trim();
|
|
605
|
-
yaml += `${translateLanguagesSection.replace(/^translateLanguages:/, "translateLanguages:")}\n`;
|
|
606
|
-
} else {
|
|
607
|
-
yaml += "# translateLanguages: # A list of languages to translate the documentation to.\n";
|
|
608
|
-
yaml += "# - zh # Example: Chinese translation\n";
|
|
609
|
-
yaml += "# - en # Example: English translation\n";
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
// Directory and source path configurations - safely serialize
|
|
613
|
-
const docsDirSection = yamlStringify({ docsDir: config.docsDir }).trim();
|
|
614
|
-
yaml += `${docsDirSection} # The directory where the generated documentation will be saved.\n`;
|
|
615
|
-
|
|
616
|
-
const sourcesPathSection = yamlStringify({ sourcesPath: config.sourcesPath }).trim();
|
|
617
|
-
yaml += `${sourcesPathSection.replace(/^sourcesPath:/, "sourcesPath: # The source code paths to analyze.")}\n`;
|
|
618
|
-
|
|
619
|
-
// Image filtering settings
|
|
620
|
-
const mediaInfoSection = yamlStringify({
|
|
621
|
-
media: config.media,
|
|
622
|
-
}).trim();
|
|
623
|
-
yaml += `# minImageWidth: Only images wider than this value (in pixels) will be used in the page generation.\n${mediaInfoSection}\n`;
|
|
624
|
-
|
|
625
|
-
// Diagramming configuration
|
|
626
|
-
yaml += "\n# Diagramming Configuration\n";
|
|
627
|
-
yaml +=
|
|
628
|
-
"# diagramming.effort: AI effort level for diagramming, 0-10, larger value means fewer diagrams\n";
|
|
629
|
-
yaml += "diagramming:\n";
|
|
630
|
-
yaml += " effort: 5 # AI effort level for diagramming, 0-10, large is less diagram\n";
|
|
631
|
-
yaml +=
|
|
632
|
-
" # Default diagram style: The primary style to use when no style is specified in feedback\n";
|
|
633
|
-
yaml += " # This style will be applied if feedback doesn't specify a different style\n";
|
|
634
|
-
yaml += " # Available options:\n";
|
|
635
|
-
Object.entries(DIAGRAM_STYLES).forEach(([key, style]) => {
|
|
636
|
-
yaml += ` # ${key.padEnd(16)} - ${style.name}: ${style.description}\n`;
|
|
637
|
-
});
|
|
638
|
-
yaml += ' # style: "modern"\n';
|
|
639
|
-
|
|
640
|
-
return yaml;
|
|
641
|
-
}
|
|
642
|
-
|
|
643
|
-
init.description = "Create a configuration file for the documentation generation process.";
|
package/agents/init/validate.mjs
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
export function validateDocDir(input) {
|
|
3
|
-
const currentDir = process.cwd();
|
|
4
|
-
const targetDir = path.resolve(input);
|
|
5
|
-
const relativePath = path.relative(currentDir, targetDir);
|
|
6
|
-
if (relativePath.length === 0) {
|
|
7
|
-
return `Can't use current directory: ${targetDir}`;
|
|
8
|
-
}
|
|
9
|
-
if (relativePath.startsWith("..")) {
|
|
10
|
-
return `Can't use directory outside current directory: ${targetDir}`;
|
|
11
|
-
}
|
|
12
|
-
if (path.isAbsolute(relativePath)) {
|
|
13
|
-
return `Can't use absolute path: ${targetDir}`;
|
|
14
|
-
}
|
|
15
|
-
return true;
|
|
16
|
-
}
|