@aigne/doc-smith 0.8.15-beta → 0.8.15-beta.10

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.
Files changed (89) hide show
  1. package/CHANGELOG.md +83 -0
  2. package/agents/clear/choose-contents.mjs +4 -4
  3. package/agents/clear/clear-auth-tokens.mjs +8 -8
  4. package/agents/clear/clear-deployment-config.mjs +2 -2
  5. package/agents/clear/clear-document-config.mjs +3 -3
  6. package/agents/clear/clear-document-structure.mjs +10 -10
  7. package/agents/clear/clear-generated-docs.mjs +103 -14
  8. package/agents/clear/clear-media-description.mjs +7 -7
  9. package/agents/evaluate/document-structure.yaml +3 -1
  10. package/agents/evaluate/document.yaml +3 -1
  11. package/agents/evaluate/index.yaml +1 -3
  12. package/agents/generate/check-diagram.mjs +1 -1
  13. package/agents/generate/check-need-generate-structure.mjs +2 -7
  14. package/agents/generate/draw-diagram.yaml +4 -0
  15. package/agents/generate/generate-structure.yaml +117 -65
  16. package/agents/generate/index.yaml +3 -3
  17. package/agents/generate/{merge-d2-diagram.yaml → merge-diagram.yaml} +7 -6
  18. package/agents/generate/update-document-structure.yaml +1 -1
  19. package/agents/generate/user-review-document-structure.mjs +1 -0
  20. package/agents/generate/utils/merge-document-structures.mjs +30 -0
  21. package/agents/init/check.mjs +3 -1
  22. package/agents/init/index.mjs +37 -7
  23. package/agents/media/load-media-description.mjs +12 -24
  24. package/agents/publish/publish-docs.mjs +3 -8
  25. package/agents/schema/document-execution-structure.yaml +1 -1
  26. package/agents/schema/document-structure-item.yaml +23 -0
  27. package/agents/schema/document-structure-refine-item.yaml +20 -0
  28. package/agents/schema/document-structure.yaml +1 -1
  29. package/agents/translate/index.yaml +1 -4
  30. package/agents/translate/record-translation-history.mjs +6 -2
  31. package/agents/translate/translate-multilingual.yaml +1 -1
  32. package/agents/update/batch-generate-document.yaml +1 -1
  33. package/agents/update/batch-update-document.yaml +1 -1
  34. package/agents/update/check-document.mjs +50 -13
  35. package/agents/update/check-generate-diagram.mjs +26 -0
  36. package/agents/update/generate-diagram.yaml +29 -0
  37. package/agents/update/generate-document.yaml +17 -30
  38. package/agents/update/handle-document-update.yaml +10 -1
  39. package/agents/update/save-and-translate-document.mjs +18 -47
  40. package/agents/update/update-document-detail.yaml +2 -1
  41. package/agents/update/update-single-document.yaml +1 -1
  42. package/agents/update/user-review-document.mjs +6 -5
  43. package/agents/utils/choose-docs.mjs +8 -2
  44. package/agents/utils/load-sources.mjs +132 -57
  45. package/agents/utils/{save-docs.mjs → post-generate.mjs} +2 -51
  46. package/agents/utils/save-doc-translation.mjs +27 -0
  47. package/agents/utils/{save-single-doc.mjs → save-doc.mjs} +17 -12
  48. package/agents/utils/save-sidebar.mjs +59 -0
  49. package/agents/utils/transform-detail-data-sources.mjs +45 -0
  50. package/aigne.yaml +16 -8
  51. package/package.json +2 -1
  52. package/prompts/common/document/content-rules-core.md +6 -6
  53. package/prompts/common/document/media-file-list-usage-rules.md +12 -0
  54. package/prompts/common/document/openapi-usage-rules.md +36 -0
  55. package/prompts/common/document/role-and-personality.md +1 -2
  56. package/prompts/common/document-structure/conflict-resolution-guidance.md +2 -2
  57. package/prompts/common/document-structure/document-structure-rules.md +8 -8
  58. package/prompts/common/document-structure/output-constraints.md +3 -3
  59. package/prompts/detail/custom/custom-components.md +38 -3
  60. package/prompts/detail/d2-diagram/rules.md +11 -14
  61. package/prompts/detail/d2-diagram/system-prompt.md +33 -21
  62. package/prompts/detail/d2-diagram/user-prompt.md +39 -0
  63. package/prompts/detail/generate/document-rules.md +3 -3
  64. package/prompts/detail/generate/system-prompt.md +2 -6
  65. package/prompts/detail/generate/user-prompt.md +20 -24
  66. package/prompts/detail/update/system-prompt.md +2 -6
  67. package/prompts/detail/update/user-prompt.md +7 -6
  68. package/prompts/evaluate/document.md +0 -4
  69. package/prompts/structure/check-document-structure.md +4 -4
  70. package/prompts/structure/generate/system-prompt.md +0 -31
  71. package/prompts/structure/generate/user-prompt.md +99 -26
  72. package/prompts/structure/review/structure-review-system.md +79 -0
  73. package/prompts/structure/update/system-prompt.md +1 -1
  74. package/prompts/structure/update/user-prompt.md +4 -4
  75. package/prompts/translate/code-block.md +13 -3
  76. package/prompts/translate/translate-document.md +1 -1
  77. package/types/document-structure-schema.mjs +3 -3
  78. package/utils/docs-finder-utils.mjs +48 -0
  79. package/utils/extract-api.mjs +32 -0
  80. package/utils/file-utils.mjs +124 -93
  81. package/utils/history-utils.mjs +20 -8
  82. package/utils/load-config.mjs +1 -1
  83. package/utils/markdown-checker.mjs +35 -1
  84. package/utils/openapi/index.mjs +24 -0
  85. package/utils/utils.mjs +67 -65
  86. package/agents/generate/document-structure-tools/generate-sub-structure.mjs +0 -131
  87. package/agents/generate/generate-structure-without-tools.yaml +0 -65
  88. package/agents/utils/transform-detail-datasources.mjs +0 -23
  89. package/prompts/common/document/media-handling-rules.md +0 -9
@@ -1,131 +0,0 @@
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
- };
@@ -1,65 +0,0 @@
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
@@ -1,23 +0,0 @@
1
- import fs from "node:fs";
2
- import { normalizePath, toRelativePath } from "../../utils/utils.mjs";
3
-
4
- export default function transformDetailDatasources({ sourceIds }) {
5
- // Read file content for each sourceId, ignoring failures
6
- const contents = (sourceIds || [])
7
- .map((id) => {
8
- try {
9
- const normalizedId = normalizePath(id);
10
- const content = fs.readFileSync(normalizedId, "utf8");
11
- const relativeId = toRelativePath(id);
12
- return `// sourceId: ${relativeId}\n${content}\n`;
13
- } catch {
14
- // Ignore files that cannot be read
15
- return null;
16
- }
17
- })
18
- .filter(Boolean);
19
-
20
- return { detailDataSources: contents.join("") };
21
- }
22
-
23
- transformDetailDatasources.task_render_mode = "hide";
@@ -1,9 +0,0 @@
1
- <media_handling_rules>
2
- Media resource usage rules:
3
-
4
- - When DataSources contain media resource files, incorporate them appropriately in the generated content
5
- - Media resources are provided in markdown format, example: ![Resource description](https://xxxx)
6
- - Display images in markdown format within generated results
7
- - Based on resource descriptions, place images strategically in contextually relevant positions to enhance the presentation
8
- - To ensure correct media resource paths, **only use media resources provided in media_list or remote URL media resources**
9
- </media_handling_rules>