@aigne/doc-smith 0.8.12-beta.3 → 0.8.12-beta.5
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/.aigne/doc-smith/config.yaml +9 -6
- package/.aigne/doc-smith/output/structure-plan.json +123 -109
- package/.aigne/doc-smith/upload-cache.yaml +48 -0
- package/.github/workflows/publish-docs.yml +4 -7
- package/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +20 -0
- package/agents/clear/choose-contents.mjs +22 -5
- package/agents/clear/clear-auth-tokens.mjs +2 -4
- package/agents/clear/clear-deployment-config.mjs +49 -0
- package/agents/clear/clear-document-config.mjs +2 -5
- package/agents/clear/clear-document-structure.mjs +2 -6
- package/agents/clear/clear-generated-docs.mjs +0 -1
- package/agents/generate/check-need-generate-structure.mjs +15 -60
- package/agents/generate/document-structure-tools/generate-sub-structure.mjs +131 -0
- package/agents/generate/generate-structure-without-tools.yaml +65 -0
- package/agents/generate/generate-structure.yaml +7 -1
- package/agents/generate/index.yaml +0 -3
- package/agents/generate/update-document-structure.yaml +3 -0
- package/agents/generate/user-review-document-structure.mjs +7 -5
- package/agents/init/index.mjs +15 -15
- package/agents/publish/publish-docs.mjs +130 -111
- package/agents/translate/index.yaml +1 -1
- package/agents/update/batch-generate-document.yaml +1 -1
- package/agents/update/batch-update-document.yaml +1 -1
- package/agents/update/check-document.mjs +4 -19
- package/agents/update/user-review-document.mjs +4 -3
- package/agents/utils/load-sources.mjs +54 -151
- package/agents/utils/transform-detail-datasources.mjs +14 -18
- package/aigne.yaml +2 -0
- package/biome.json +1 -1
- package/docs/_sidebar.md +13 -15
- package/docs/configuration-initial-setup.ja.md +179 -0
- package/docs/configuration-initial-setup.md +179 -0
- package/docs/configuration-initial-setup.zh-TW.md +179 -0
- package/docs/configuration-initial-setup.zh.md +179 -0
- package/docs/configuration-managing-preferences.ja.md +100 -0
- package/docs/configuration-managing-preferences.md +100 -0
- package/docs/configuration-managing-preferences.zh-TW.md +100 -0
- package/docs/configuration-managing-preferences.zh.md +100 -0
- package/docs/configuration.ja.md +68 -184
- package/docs/configuration.md +62 -178
- package/docs/configuration.zh-TW.md +70 -186
- package/docs/configuration.zh.md +67 -183
- package/docs/getting-started.ja.md +46 -78
- package/docs/getting-started.md +46 -78
- package/docs/getting-started.zh-TW.md +47 -79
- package/docs/getting-started.zh.md +47 -79
- package/docs/guides-cleaning-up.ja.md +50 -0
- package/docs/guides-cleaning-up.md +50 -0
- package/docs/guides-cleaning-up.zh-TW.md +50 -0
- package/docs/guides-cleaning-up.zh.md +50 -0
- package/docs/guides-evaluating-documents.ja.md +66 -0
- package/docs/guides-evaluating-documents.md +66 -0
- package/docs/guides-evaluating-documents.zh-TW.md +66 -0
- package/docs/guides-evaluating-documents.zh.md +66 -0
- package/docs/guides-generating-documentation.ja.md +149 -0
- package/docs/guides-generating-documentation.md +149 -0
- package/docs/guides-generating-documentation.zh-TW.md +149 -0
- package/docs/guides-generating-documentation.zh.md +149 -0
- package/docs/guides-interactive-chat.ja.md +85 -0
- package/docs/guides-interactive-chat.md +85 -0
- package/docs/guides-interactive-chat.zh-TW.md +85 -0
- package/docs/guides-interactive-chat.zh.md +85 -0
- package/docs/guides-managing-history.ja.md +51 -0
- package/docs/guides-managing-history.md +51 -0
- package/docs/guides-managing-history.zh-TW.md +51 -0
- package/docs/guides-managing-history.zh.md +51 -0
- package/docs/guides-publishing-your-docs.ja.md +78 -0
- package/docs/guides-publishing-your-docs.md +78 -0
- package/docs/guides-publishing-your-docs.zh-TW.md +78 -0
- package/docs/guides-publishing-your-docs.zh.md +78 -0
- package/docs/guides-translating-documentation.ja.md +95 -0
- package/docs/guides-translating-documentation.md +95 -0
- package/docs/guides-translating-documentation.zh-TW.md +95 -0
- package/docs/guides-translating-documentation.zh.md +95 -0
- package/docs/guides-updating-documentation.ja.md +77 -0
- package/docs/guides-updating-documentation.md +77 -0
- package/docs/guides-updating-documentation.zh-TW.md +77 -0
- package/docs/guides-updating-documentation.zh.md +77 -0
- package/docs/guides.ja.md +32 -0
- package/docs/guides.md +32 -0
- package/docs/guides.zh-TW.md +32 -0
- package/docs/guides.zh.md +32 -0
- package/docs/overview.ja.md +39 -60
- package/docs/overview.md +39 -60
- package/docs/overview.zh-TW.md +39 -60
- package/docs/overview.zh.md +39 -60
- package/docs/release-notes.ja.md +255 -0
- package/docs/release-notes.md +255 -0
- package/docs/release-notes.zh-TW.md +255 -0
- package/docs/release-notes.zh.md +255 -0
- package/package.json +4 -2
- package/prompts/common/document/content-rules-core.md +1 -0
- package/prompts/common/document-structure/document-structure-rules.md +8 -9
- package/prompts/common/document-structure/output-constraints.md +1 -1
- package/prompts/structure/document-rules.md +8 -2
- package/prompts/structure/generate/system-prompt.md +27 -2
- package/prompts/structure/generate/user-prompt.md +18 -0
- package/prompts/structure/update/system-prompt.md +12 -0
- package/prompts/structure/update/user-prompt.md +3 -0
- package/tests/agents/clear/choose-contents.test.mjs +8 -4
- package/tests/agents/generate/check-need-generate-structure.test.mjs +53 -63
- package/tests/agents/generate/document-structure-tools/generate-sub-structure.test.mjs +277 -0
- package/tests/agents/init/init.test.mjs +18 -18
- package/tests/agents/publish/publish-docs.test.mjs +79 -0
- package/tests/agents/update/check-document.test.mjs +7 -67
- package/tests/agents/utils/load-sources.test.mjs +90 -90
- package/tests/agents/utils/transform-detail-datasources.test.mjs +153 -196
- package/tests/utils/file-utils.test.mjs +309 -1
- package/utils/auth-utils.mjs +9 -3
- package/utils/constants/index.mjs +3 -1
- package/utils/file-utils.mjs +315 -0
- package/utils/utils.mjs +89 -50
- package/docs/advanced-how-it-works.ja.md +0 -101
- package/docs/advanced-how-it-works.md +0 -101
- package/docs/advanced-how-it-works.zh-TW.md +0 -101
- package/docs/advanced-how-it-works.zh.md +0 -101
- package/docs/advanced-quality-assurance.ja.md +0 -92
- package/docs/advanced-quality-assurance.md +0 -92
- package/docs/advanced-quality-assurance.zh-TW.md +0 -92
- package/docs/advanced-quality-assurance.zh.md +0 -92
- package/docs/advanced.ja.md +0 -20
- package/docs/advanced.md +0 -20
- package/docs/advanced.zh-TW.md +0 -20
- package/docs/advanced.zh.md +0 -20
- package/docs/changelog.ja.md +0 -486
- package/docs/changelog.md +0 -486
- package/docs/changelog.zh-TW.md +0 -486
- package/docs/changelog.zh.md +0 -486
- package/docs/cli-reference.ja.md +0 -311
- package/docs/cli-reference.md +0 -311
- package/docs/cli-reference.zh-TW.md +0 -311
- package/docs/cli-reference.zh.md +0 -311
- package/docs/configuration-interactive-setup.ja.md +0 -138
- package/docs/configuration-interactive-setup.md +0 -138
- package/docs/configuration-interactive-setup.zh-TW.md +0 -138
- package/docs/configuration-interactive-setup.zh.md +0 -138
- package/docs/configuration-language-support.ja.md +0 -64
- package/docs/configuration-language-support.md +0 -64
- package/docs/configuration-language-support.zh-TW.md +0 -64
- package/docs/configuration-language-support.zh.md +0 -64
- package/docs/configuration-llm-setup.ja.md +0 -56
- package/docs/configuration-llm-setup.md +0 -56
- package/docs/configuration-llm-setup.zh-TW.md +0 -56
- package/docs/configuration-llm-setup.zh.md +0 -56
- package/docs/configuration-preferences.ja.md +0 -144
- package/docs/configuration-preferences.md +0 -144
- package/docs/configuration-preferences.zh-TW.md +0 -144
- package/docs/configuration-preferences.zh.md +0 -144
- package/docs/features-generate-documentation.ja.md +0 -95
- package/docs/features-generate-documentation.md +0 -95
- package/docs/features-generate-documentation.zh-TW.md +0 -95
- package/docs/features-generate-documentation.zh.md +0 -95
- package/docs/features-publish-your-docs.ja.md +0 -130
- package/docs/features-publish-your-docs.md +0 -130
- package/docs/features-publish-your-docs.zh-TW.md +0 -130
- package/docs/features-publish-your-docs.zh.md +0 -130
- package/docs/features-translate-documentation.ja.md +0 -90
- package/docs/features-translate-documentation.md +0 -90
- package/docs/features-translate-documentation.zh-TW.md +0 -90
- package/docs/features-translate-documentation.zh.md +0 -90
- package/docs/features-update-and-refine.ja.md +0 -142
- package/docs/features-update-and-refine.md +0 -142
- package/docs/features-update-and-refine.zh-TW.md +0 -143
- package/docs/features-update-and-refine.zh.md +0 -142
- package/docs/features.ja.md +0 -62
- package/docs/features.md +0 -62
- package/docs/features.zh-TW.md +0 -62
- package/docs/features.zh.md +0 -62
|
@@ -1,31 +1,22 @@
|
|
|
1
|
-
import { access } from "node:fs/promises";
|
|
2
|
-
import { join } from "node:path";
|
|
3
1
|
import chalk from "chalk";
|
|
4
2
|
import { getActiveRulesForScope } from "../../utils/preferences-utils.mjs";
|
|
5
|
-
import {
|
|
6
|
-
getCurrentGitHead,
|
|
7
|
-
getProjectInfo,
|
|
8
|
-
hasFileChangesBetweenCommits,
|
|
9
|
-
loadConfigFromFile,
|
|
10
|
-
saveValueToConfig,
|
|
11
|
-
} from "../../utils/utils.mjs";
|
|
3
|
+
import { getProjectInfo, loadConfigFromFile, saveValueToConfig } from "../../utils/utils.mjs";
|
|
12
4
|
|
|
13
5
|
export default async function checkNeedGenerateStructure(
|
|
14
|
-
{ originalDocumentStructure,
|
|
6
|
+
{ originalDocumentStructure, forceRegenerate, isLargeContext, ...rest },
|
|
15
7
|
options,
|
|
16
8
|
) {
|
|
17
9
|
// Check if originalDocumentStructure is empty and prompt user
|
|
18
10
|
if (!originalDocumentStructure) {
|
|
19
11
|
const choice = await options.prompts.select({
|
|
20
|
-
message:
|
|
21
|
-
"Your project configuration is complete. Would you like to generate the documentation structure now?",
|
|
12
|
+
message: "Project configured successfully. Generate the documentation structure now?",
|
|
22
13
|
choices: [
|
|
23
14
|
{
|
|
24
|
-
name: "
|
|
15
|
+
name: "Yes, generate now",
|
|
25
16
|
value: "generate",
|
|
26
17
|
},
|
|
27
18
|
{
|
|
28
|
-
name: "
|
|
19
|
+
name: "No, review configuration first",
|
|
29
20
|
value: "later",
|
|
30
21
|
},
|
|
31
22
|
],
|
|
@@ -50,65 +41,28 @@ export default async function checkNeedGenerateStructure(
|
|
|
50
41
|
}
|
|
51
42
|
|
|
52
43
|
// Check if we need to regenerate documentation structure
|
|
53
|
-
let
|
|
54
|
-
let finalFeedback = feedback;
|
|
55
|
-
|
|
56
|
-
// If no feedback and originalDocumentStructure exists, check for git changes
|
|
57
|
-
if (originalDocumentStructure) {
|
|
58
|
-
// If no lastGitHead, check if _sidebar.md exists to determine if we should regenerate
|
|
59
|
-
if (!lastGitHead) {
|
|
60
|
-
try {
|
|
61
|
-
// Check if _sidebar.md exists in docsDir
|
|
62
|
-
const sidebarPath = join(docsDir, "_sidebar.md");
|
|
63
|
-
await access(sidebarPath);
|
|
64
|
-
// If _sidebar.md exists, it means last execution was completed, need to regenerate
|
|
65
|
-
shouldRegenerate = true;
|
|
66
|
-
} catch {
|
|
67
|
-
// If _sidebar.md doesn't exist, it means last execution was interrupted, no need to regenerate
|
|
68
|
-
shouldRegenerate = false;
|
|
69
|
-
}
|
|
70
|
-
} else {
|
|
71
|
-
// Check if there are relevant file changes since last generation
|
|
72
|
-
const currentGitHead = getCurrentGitHead();
|
|
73
|
-
if (currentGitHead && currentGitHead !== lastGitHead) {
|
|
74
|
-
const hasChanges = hasFileChangesBetweenCommits(lastGitHead, currentGitHead);
|
|
75
|
-
if (hasChanges) {
|
|
76
|
-
shouldRegenerate = true;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
if (shouldRegenerate) {
|
|
82
|
-
finalFeedback = `
|
|
83
|
-
${finalFeedback || ""}
|
|
84
|
-
|
|
85
|
-
Update documentation structure based on the latest DataSources:
|
|
86
|
-
1. For new content, add new sections as needed or supplement existing section displays
|
|
87
|
-
2. Be cautious when deleting sections, unless all associated sourceIds have been removed
|
|
88
|
-
3. Do not modify the path of existing sections
|
|
89
|
-
4. Update section sourceIds as needed based on the latest Data Sources
|
|
90
|
-
`;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
44
|
+
let finalFeedback = "";
|
|
93
45
|
|
|
94
46
|
// user requested regeneration
|
|
95
47
|
if (forceRegenerate) {
|
|
96
|
-
shouldRegenerate = true;
|
|
97
48
|
finalFeedback = `
|
|
98
|
-
${finalFeedback || ""}
|
|
99
|
-
|
|
100
49
|
User requested forced regeneration of documentation structure. Please regenerate based on the latest Data Sources and user requirements, **allowing any modifications**.
|
|
101
50
|
`;
|
|
102
51
|
}
|
|
103
52
|
|
|
104
53
|
// If no regeneration needed, return original documentation structure
|
|
105
|
-
if (originalDocumentStructure && !
|
|
54
|
+
if (originalDocumentStructure && !forceRegenerate) {
|
|
106
55
|
return {
|
|
107
56
|
documentStructure: originalDocumentStructure,
|
|
108
57
|
};
|
|
109
58
|
}
|
|
110
59
|
|
|
111
|
-
|
|
60
|
+
// Performance optimization:
|
|
61
|
+
// Using both structured output and Tool with Gemini model causes redundant calls
|
|
62
|
+
// Only use Tool when context is very large
|
|
63
|
+
const generateStructureAgent = isLargeContext
|
|
64
|
+
? options.context.agents["generateStructure"]
|
|
65
|
+
: options.context.agents["generateStructureWithoutTools"];
|
|
112
66
|
|
|
113
67
|
// Get user preferences for documentation structure and global scope
|
|
114
68
|
const structureRules = getActiveRulesForScope("structure", []);
|
|
@@ -121,11 +75,12 @@ export default async function checkNeedGenerateStructure(
|
|
|
121
75
|
// Convert rule texts to string format for passing to the agent
|
|
122
76
|
const userPreferences = ruleTexts.length > 0 ? ruleTexts.join("\n\n") : "";
|
|
123
77
|
|
|
124
|
-
const result = await options.context.invoke(
|
|
78
|
+
const result = await options.context.invoke(generateStructureAgent, {
|
|
125
79
|
...rest,
|
|
126
80
|
originalDocumentStructure,
|
|
127
81
|
userPreferences,
|
|
128
82
|
feedback: finalFeedback || "",
|
|
83
|
+
isLargeContext,
|
|
129
84
|
});
|
|
130
85
|
|
|
131
86
|
let message = "";
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import {
|
|
2
|
+
buildSourcesContent,
|
|
3
|
+
calculateFileStats,
|
|
4
|
+
loadFilesFromPaths,
|
|
5
|
+
readFileContents,
|
|
6
|
+
} from "../../../utils/file-utils.mjs";
|
|
7
|
+
import {
|
|
8
|
+
INTELLIGENT_SUGGESTION_TOKEN_THRESHOLD,
|
|
9
|
+
DEFAULT_EXCLUDE_PATTERNS,
|
|
10
|
+
DEFAULT_INCLUDE_PATTERNS,
|
|
11
|
+
} from "../../../utils/constants/index.mjs";
|
|
12
|
+
import { toRelativePath } from "../../../utils/utils.mjs";
|
|
13
|
+
|
|
14
|
+
export default async function generateSubStructure(
|
|
15
|
+
{
|
|
16
|
+
parentDocument,
|
|
17
|
+
subSourcePaths,
|
|
18
|
+
includePatterns,
|
|
19
|
+
excludePatterns,
|
|
20
|
+
useDefaultPatterns = true,
|
|
21
|
+
...rest
|
|
22
|
+
},
|
|
23
|
+
options,
|
|
24
|
+
) {
|
|
25
|
+
const sourcePaths = subSourcePaths?.map((item) => item.path);
|
|
26
|
+
if (!sourcePaths || sourcePaths.length === 0) {
|
|
27
|
+
return {
|
|
28
|
+
subStructure: [],
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
let files = await loadFilesFromPaths(sourcePaths, {
|
|
33
|
+
includePatterns,
|
|
34
|
+
excludePatterns,
|
|
35
|
+
useDefaultPatterns,
|
|
36
|
+
defaultIncludePatterns: DEFAULT_INCLUDE_PATTERNS,
|
|
37
|
+
defaultExcludePatterns: DEFAULT_EXCLUDE_PATTERNS,
|
|
38
|
+
});
|
|
39
|
+
files = [...new Set(files)];
|
|
40
|
+
|
|
41
|
+
// all files path
|
|
42
|
+
const allFilesPaths = files.map((file) => `- ${toRelativePath(file)}`).join("\n");
|
|
43
|
+
|
|
44
|
+
// Read all source files using the utility function
|
|
45
|
+
const sourceFiles = await readFileContents(files, process.cwd());
|
|
46
|
+
|
|
47
|
+
// Count tokens and lines using utility function
|
|
48
|
+
const { totalTokens } = calculateFileStats(sourceFiles);
|
|
49
|
+
|
|
50
|
+
// check if totalTokens is too large
|
|
51
|
+
let isLargeContext = false;
|
|
52
|
+
if (totalTokens > INTELLIGENT_SUGGESTION_TOKEN_THRESHOLD) {
|
|
53
|
+
isLargeContext = true;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Build allSources string using utility function
|
|
57
|
+
const allSources = buildSourcesContent(sourceFiles, isLargeContext);
|
|
58
|
+
|
|
59
|
+
// Performance optimization:
|
|
60
|
+
// Using both structured output and Tool with Gemini model causes redundant calls
|
|
61
|
+
// Only use Tool when context is very large
|
|
62
|
+
const generateStructureAgent = isLargeContext
|
|
63
|
+
? options.context.agents["generateStructure"]
|
|
64
|
+
: options.context.agents["generateStructureWithoutTools"];
|
|
65
|
+
const result = await options.context.invoke(generateStructureAgent, {
|
|
66
|
+
...rest,
|
|
67
|
+
isSubStructure: true,
|
|
68
|
+
parentDocument,
|
|
69
|
+
datasources: allSources,
|
|
70
|
+
allFilesPaths,
|
|
71
|
+
isLargeContext,
|
|
72
|
+
files,
|
|
73
|
+
totalTokens,
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
return {
|
|
77
|
+
subStructure: result.documentStructure || [],
|
|
78
|
+
message: `Generated a sub structure for '${parentDocument.path}' successfully. Please merge all sub-structures to output the complete document structure.`,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
generateSubStructure.description = `
|
|
83
|
+
Generates a sub-structure.
|
|
84
|
+
Handles large file sets by splitting them into smaller sub-document structures when the context size exceeds limits. This approach ensures more focused and complete documentation generation.
|
|
85
|
+
`;
|
|
86
|
+
|
|
87
|
+
generateSubStructure.inputSchema = {
|
|
88
|
+
type: "object",
|
|
89
|
+
properties: {
|
|
90
|
+
parentDocument: {
|
|
91
|
+
type: "object",
|
|
92
|
+
description: "The parent node to generate a sub structure for",
|
|
93
|
+
properties: {
|
|
94
|
+
title: { type: "string", description: "The title of the parent node" },
|
|
95
|
+
description: { type: "string", description: "The description of the parent node" },
|
|
96
|
+
path: {
|
|
97
|
+
type: "string",
|
|
98
|
+
description:
|
|
99
|
+
"The path of the parent node, Path in URL format, cannot be empty, cannot contain spaces or special characters, must start with /, no need to include language level, e.g., /zh/about should return /about ",
|
|
100
|
+
},
|
|
101
|
+
parentId: { type: "string", description: "The parent ID of the parent node" },
|
|
102
|
+
sourceIds: { type: "array", description: "The source IDs of the parent node" },
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
subSourcePaths: {
|
|
106
|
+
type: "array",
|
|
107
|
+
description: "The source paths of the sub structure",
|
|
108
|
+
items: {
|
|
109
|
+
type: "object",
|
|
110
|
+
properties: {
|
|
111
|
+
path: { type: "string", description: "The source path of the sub structure" },
|
|
112
|
+
reason: { type: "string", description: "The reason for selecting the source path" },
|
|
113
|
+
},
|
|
114
|
+
required: ["path", "reason"],
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
generateSubStructure.outputSchema = {
|
|
121
|
+
type: "object",
|
|
122
|
+
properties: {
|
|
123
|
+
subStructure: {
|
|
124
|
+
type: "array",
|
|
125
|
+
description:
|
|
126
|
+
"The sub structure of the parent node, need merge all sub-structures and output the complete document structure.",
|
|
127
|
+
},
|
|
128
|
+
message: { type: "string", description: "The message of the sub structure" },
|
|
129
|
+
},
|
|
130
|
+
required: ["subStructure"],
|
|
131
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
name: generateStructureWithoutTools
|
|
2
|
+
description: Generate the structure and organization of your documentation
|
|
3
|
+
instructions:
|
|
4
|
+
- role: system
|
|
5
|
+
url: ../../prompts/structure/generate/system-prompt.md
|
|
6
|
+
- role: user
|
|
7
|
+
url: ../../prompts/structure/generate/user-prompt.md
|
|
8
|
+
task_render_mode: collapse
|
|
9
|
+
task_title: Generate the structure of the documentation
|
|
10
|
+
input_schema:
|
|
11
|
+
type: object
|
|
12
|
+
properties:
|
|
13
|
+
rules:
|
|
14
|
+
type: string
|
|
15
|
+
description: Your specific requirements for documentation structure
|
|
16
|
+
locale:
|
|
17
|
+
type: string
|
|
18
|
+
description: Primary language for documentation (e.g., zh, en, ja)
|
|
19
|
+
datasources:
|
|
20
|
+
type: string
|
|
21
|
+
description: Project content and context to help generate documentation structure
|
|
22
|
+
targetAudience:
|
|
23
|
+
type: string
|
|
24
|
+
description: Target audience for the documentation
|
|
25
|
+
nodeName:
|
|
26
|
+
type: string
|
|
27
|
+
description: Specific section or page name to focus on
|
|
28
|
+
glossary:
|
|
29
|
+
type: string
|
|
30
|
+
description: Glossary for consistent terminology
|
|
31
|
+
feedback:
|
|
32
|
+
type: string
|
|
33
|
+
description: Tell us how to improve the documentation structure
|
|
34
|
+
userPreferences:
|
|
35
|
+
type: string
|
|
36
|
+
description: Your saved preferences for structure and documentation style
|
|
37
|
+
docsType:
|
|
38
|
+
type: string
|
|
39
|
+
description: "Documentation type (options: general, getting-started, reference, faq)"
|
|
40
|
+
default: general
|
|
41
|
+
required:
|
|
42
|
+
- rules
|
|
43
|
+
- datasources
|
|
44
|
+
output_schema:
|
|
45
|
+
type: object
|
|
46
|
+
properties:
|
|
47
|
+
projectName:
|
|
48
|
+
type: string
|
|
49
|
+
description: Project name identified from your content sources
|
|
50
|
+
projectDesc:
|
|
51
|
+
type: string
|
|
52
|
+
description: Brief project description generated from content analysis (under 50 words)
|
|
53
|
+
documentStructure: ../schema/document-structure.yaml
|
|
54
|
+
documentStructureTree:
|
|
55
|
+
type: string
|
|
56
|
+
description: |
|
|
57
|
+
Visual tree structure showing documentation hierarchy with indented levels for easy review:
|
|
58
|
+
```
|
|
59
|
+
- Home
|
|
60
|
+
- Getting Started
|
|
61
|
+
- Installation
|
|
62
|
+
- Requirements
|
|
63
|
+
```
|
|
64
|
+
required:
|
|
65
|
+
- documentStructure
|
|
@@ -5,7 +5,11 @@ instructions:
|
|
|
5
5
|
url: ../../prompts/structure/generate/system-prompt.md
|
|
6
6
|
- role: user
|
|
7
7
|
url: ../../prompts/structure/generate/user-prompt.md
|
|
8
|
-
|
|
8
|
+
skills:
|
|
9
|
+
- ./document-structure-tools/generate-sub-structure.mjs
|
|
10
|
+
task_render_mode: collapse
|
|
11
|
+
task_title: Generate the structure of the documentation
|
|
12
|
+
tool_calls_concurrency: 5
|
|
9
13
|
input_schema:
|
|
10
14
|
type: object
|
|
11
15
|
properties:
|
|
@@ -60,3 +64,5 @@ output_schema:
|
|
|
60
64
|
- Installation
|
|
61
65
|
- Requirements
|
|
62
66
|
```
|
|
67
|
+
required:
|
|
68
|
+
- documentStructure
|
|
@@ -54,9 +54,6 @@ input_schema:
|
|
|
54
54
|
glossary:
|
|
55
55
|
type: string
|
|
56
56
|
description: Glossary file for consistent terminology (use @filename.md)
|
|
57
|
-
feedback:
|
|
58
|
-
type: string
|
|
59
|
-
description: Tell us how to improve the documentation structure
|
|
60
57
|
forceRegenerate:
|
|
61
58
|
type: boolean
|
|
62
59
|
description: Rebuild all documentation from scratch
|
|
@@ -76,15 +76,14 @@ export default async function userReviewDocumentStructure({ documentStructure, .
|
|
|
76
76
|
|
|
77
77
|
// Ask user if they want to review the documentation structure
|
|
78
78
|
const needReview = await options.prompts.select({
|
|
79
|
-
message:
|
|
80
|
-
"Would you like to optimize the documentation structure?\n You can edit titles, reorganize sections.",
|
|
79
|
+
message: "Would you like to optimize the documentation structure?",
|
|
81
80
|
choices: [
|
|
82
81
|
{
|
|
83
|
-
name: "
|
|
82
|
+
name: "No, looks good",
|
|
84
83
|
value: "no",
|
|
85
84
|
},
|
|
86
85
|
{
|
|
87
|
-
name: "Yes, optimize the structure",
|
|
86
|
+
name: "Yes, optimize the structure (e.g. rename 'Getting Started' to 'Quick Start', move 'API Reference' before 'Configuration')",
|
|
88
87
|
value: "yes",
|
|
89
88
|
},
|
|
90
89
|
],
|
|
@@ -108,7 +107,10 @@ export default async function userReviewDocumentStructure({ documentStructure, .
|
|
|
108
107
|
const feedback = await options.prompts.input({
|
|
109
108
|
message:
|
|
110
109
|
"How would you like to improve the structure?\n" +
|
|
111
|
-
"
|
|
110
|
+
"Examples:\n" +
|
|
111
|
+
" • Add a new document 'Troubleshooting'\n" +
|
|
112
|
+
" • Remove the 'Legacy Features' document\n" +
|
|
113
|
+
" • Move 'Installation' to the top of the structure\n\n" +
|
|
112
114
|
" Press Enter to finish reviewing:",
|
|
113
115
|
});
|
|
114
116
|
|
package/agents/init/index.mjs
CHANGED
|
@@ -143,15 +143,7 @@ export default async function init(
|
|
|
143
143
|
// Save target audience choices as keys
|
|
144
144
|
input.targetAudienceTypes = audienceChoices;
|
|
145
145
|
|
|
146
|
-
// 3.
|
|
147
|
-
const rulesInput = await options.prompts.input({
|
|
148
|
-
message:
|
|
149
|
-
"📋 [3/9]: Any custom rules or requirements for your documentation? (Optional, press Enter to skip)",
|
|
150
|
-
default: "",
|
|
151
|
-
});
|
|
152
|
-
input.rules = rulesInput.trim();
|
|
153
|
-
|
|
154
|
-
// 4. Reader knowledge level - what do readers typically know when they arrive?
|
|
146
|
+
// 3. Reader knowledge level - what do readers typically know when they arrive?
|
|
155
147
|
// Determine default based on selected purposes using mapping
|
|
156
148
|
const mappedPurpose = prioritizedPurposes.find(
|
|
157
149
|
(purpose) => PURPOSE_TO_KNOWLEDGE_MAPPING[purpose],
|
|
@@ -166,7 +158,7 @@ export default async function init(
|
|
|
166
158
|
);
|
|
167
159
|
|
|
168
160
|
const knowledgeChoice = await options.prompts.select({
|
|
169
|
-
message: "🧠 [
|
|
161
|
+
message: "🧠 [3/9]: How much do readers already know about your project?",
|
|
170
162
|
choices: Object.entries(filteredKnowledgeOptions).map(([key, level]) => ({
|
|
171
163
|
name: `${level.name}`,
|
|
172
164
|
description: level.description,
|
|
@@ -211,7 +203,7 @@ export default async function init(
|
|
|
211
203
|
);
|
|
212
204
|
|
|
213
205
|
const depthChoice = await options.prompts.select({
|
|
214
|
-
message: "📊 [
|
|
206
|
+
message: "📊 [4/9]: How detailed should your documentation be?",
|
|
215
207
|
choices: Object.entries(filteredDepthOptions).map(([key, depth]) => ({
|
|
216
208
|
name: `${depth.name}`,
|
|
217
209
|
description: depth.description,
|
|
@@ -229,7 +221,7 @@ export default async function init(
|
|
|
229
221
|
|
|
230
222
|
// Let user select primary language from supported list
|
|
231
223
|
const primaryLanguageChoice = await options.prompts.select({
|
|
232
|
-
message: "🌐 [
|
|
224
|
+
message: "🌐 [5/9]: What's your main documentation language?",
|
|
233
225
|
choices: SUPPORTED_LANGUAGES.map((lang) => ({
|
|
234
226
|
name: `${lang.label} - ${lang.sample}`,
|
|
235
227
|
value: lang.code,
|
|
@@ -246,7 +238,7 @@ export default async function init(
|
|
|
246
238
|
);
|
|
247
239
|
|
|
248
240
|
const translateLanguageChoices = await options.prompts.checkbox({
|
|
249
|
-
message: "🔄 [
|
|
241
|
+
message: "🔄 [6/9]: Which languages should we translate to?",
|
|
250
242
|
choices: availableTranslationLanguages.map((lang) => ({
|
|
251
243
|
name: `${lang.label} - ${lang.sample}`,
|
|
252
244
|
value: lang.code,
|
|
@@ -257,13 +249,13 @@ export default async function init(
|
|
|
257
249
|
|
|
258
250
|
// 7. Documentation directory
|
|
259
251
|
const docsDirInput = await options.prompts.input({
|
|
260
|
-
message: `📁 [
|
|
252
|
+
message: `📁 [7/9]: Where should we save your documentation?`,
|
|
261
253
|
default: `${outputPath}/docs`,
|
|
262
254
|
});
|
|
263
255
|
input.docsDir = docsDirInput.trim() || `${outputPath}/docs`;
|
|
264
256
|
|
|
265
257
|
// 8. Content sources
|
|
266
|
-
console.log("\n🔍 [
|
|
258
|
+
console.log("\n🔍 [8/9]: Content Sources");
|
|
267
259
|
console.log(
|
|
268
260
|
"What folders/files should we analyze for documentation? (e.g., ./src, ./docs, ./README.md)",
|
|
269
261
|
);
|
|
@@ -347,6 +339,14 @@ export default async function init(
|
|
|
347
339
|
// If no paths entered, use default
|
|
348
340
|
input.sourcesPath = sourcePaths.length > 0 ? sourcePaths : ["./"];
|
|
349
341
|
|
|
342
|
+
// 9. Custom rules - any specific requirements for the documentation?
|
|
343
|
+
const rulesInput = await options.prompts.input({
|
|
344
|
+
message:
|
|
345
|
+
"📋 [9/9]: Any custom rules or requirements for your documentation? (Optional, press Enter to skip)",
|
|
346
|
+
default: "",
|
|
347
|
+
});
|
|
348
|
+
input.rules = rulesInput.trim();
|
|
349
|
+
|
|
350
350
|
// Save project info to config
|
|
351
351
|
const projectInfo = await getProjectInfo();
|
|
352
352
|
input.projectName = projectInfo.name;
|