@aigne/doc-smith 0.9.6-beta.2 → 0.9.7-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 CHANGED
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.9.7-beta](https://github.com/AIGNE-io/aigne-doc-smith/compare/v0.9.6...v0.9.7-beta) (2025-11-25)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * documentExecutionStructure might be an object ([#332](https://github.com/AIGNE-io/aigne-doc-smith/issues/332)) ([337b350](https://github.com/AIGNE-io/aigne-doc-smith/commit/337b350d5fa045edb7b2db84f0892151aa8518ab))
9
+ * update default exclusion patterns, keeping only the necessary items ([#334](https://github.com/AIGNE-io/aigne-doc-smith/issues/334)) ([f1431cf](https://github.com/AIGNE-io/aigne-doc-smith/commit/f1431cf3d600c77c05c8e346712f79aa689ffe27))
10
+
11
+ ## [0.9.6](https://github.com/AIGNE-io/aigne-doc-smith/compare/v0.9.6-beta.2...v0.9.6) (2025-11-21)
12
+
3
13
  ## [0.9.6-beta.2](https://github.com/AIGNE-io/aigne-doc-smith/compare/v0.9.6-beta.1...v0.9.6-beta.2) (2025-11-20)
4
14
 
5
15
 
@@ -29,12 +29,12 @@ export default async function clearGeneratedDocs(input = {}, options = {}) {
29
29
  };
30
30
  }
31
31
 
32
- const documentExecutionStructure = (await loadDocumentStructure(outputDir)) || [];
32
+ const documentStructure = (await loadDocumentStructure(outputDir)) || [];
33
33
  // select documents interactively
34
34
  const chooseResult = await chooseDocs(
35
35
  {
36
36
  docs: [], // Empty to trigger interactive selection
37
- documentExecutionStructure,
37
+ documentStructure,
38
38
  docsDir: generatedDocsPath,
39
39
  locale: locale || "en",
40
40
  isTranslate: false,
@@ -25,23 +25,6 @@ skills:
25
25
  fileName: structure-plan.json
26
26
  - ../utils/save-sidebar.mjs
27
27
  - ../utils/ensure-document-icons.mjs
28
- - type: transform
29
- name: transformData
30
- task_render_mode: hide
31
- jsonata: |
32
- $merge([
33
- $,
34
- {
35
- 'documentExecutionStructure': $map(documentStructure, function($item) {
36
- $merge([
37
- $item,
38
- {
39
- 'translates': [$map(translateLanguages, function($lang) { {"language": $lang} })]
40
- }
41
- ])
42
- })
43
- }
44
- ])
45
28
  - ../utils/format-document-structure.mjs
46
29
  - ../media/load-media-description.mjs
47
30
  - ../update/batch-generate-document.yaml
@@ -1,9 +1,8 @@
1
1
  import { getActiveRulesForScope } from "../../../utils/preferences-utils.mjs";
2
2
  import { printDocumentStructure } from "../../../utils/docs-finder-utils.mjs";
3
- import addTranslatesToStructure from "../../utils/add-translates-to-structure.mjs";
4
3
 
5
4
  export default async function addDocumentsToStructure(input = {}, options = {}) {
6
- const { originalDocumentStructure = [], translateLanguages = [] } = input;
5
+ const { originalDocumentStructure = [] } = input;
7
6
  const analyzeIntent = options.context?.agents?.["analyzeStructureFeedbackIntent"];
8
7
  const updateDocumentStructure = options.context?.agents?.["updateDocumentStructure"];
9
8
  const allFeedback = [];
@@ -76,16 +75,11 @@ export default async function addDocumentsToStructure(input = {}, options = {})
76
75
 
77
76
  if (currentStructure.length > originalDocumentStructure.length) {
78
77
  const originalPaths = new Set(originalDocumentStructure.map((doc) => doc.path));
79
- const { documentExecutionStructure } = addTranslatesToStructure({
80
- originalDocumentStructure: currentStructure,
81
- translateLanguages,
82
- });
83
- const newDocuments = documentExecutionStructure.filter((doc) => !originalPaths.has(doc.path));
78
+ const newDocuments = currentStructure.filter((doc) => !originalPaths.has(doc.path));
84
79
 
85
80
  return {
86
81
  originalDocumentStructure: currentStructure,
87
82
  documentStructure: JSON.parse(JSON.stringify(currentStructure)),
88
- documentExecutionStructure,
89
83
  newDocuments,
90
84
  allFeedback,
91
85
  };
@@ -8,7 +8,7 @@ import { pathExists } from "../../../utils/file-utils.mjs";
8
8
  * Review documentsWithNewLinks and let user select which documents should be updated
9
9
  */
10
10
  export default async function reviewDocumentsWithNewLinks(
11
- { documentsWithNewLinks = [], documentExecutionStructure = [], locale = "en", docsDir },
11
+ { documentsWithNewLinks = [], documentStructure = [], locale = "en", docsDir },
12
12
  options,
13
13
  ) {
14
14
  // If no documents to review, return empty array
@@ -22,7 +22,7 @@ export default async function reviewDocumentsWithNewLinks(
22
22
  documentsWithNewLinks.map((document, index) =>
23
23
  limit(async () => {
24
24
  // Find corresponding document in documentStructure to get title
25
- const structureDoc = documentExecutionStructure.find((item) => item.path === document.path);
25
+ const structureDoc = documentStructure.find((item) => item.path === document.path);
26
26
  const title = structureDoc?.title || document.path;
27
27
 
28
28
  // Generate filename from document path
@@ -86,7 +86,7 @@ export default async function reviewDocumentsWithNewLinks(
86
86
  if (!doc.path) continue;
87
87
 
88
88
  // Find corresponding document in documentStructure to get additional fields
89
- const structureDoc = documentExecutionStructure.find((item) => item.path === doc.path);
89
+ const structureDoc = documentStructure.find((item) => item.path === doc.path);
90
90
 
91
91
  // Generate feedback message for adding new links
92
92
  const newLinksList = doc.newLinks.join(", ");
@@ -15,7 +15,6 @@ skills:
15
15
  fileName: structure-plan.json
16
16
  - ../../utils/save-sidebar.mjs
17
17
  - ./find-documents-with-invalid-links.mjs
18
- - ../../utils/add-translates-to-structure.mjs
19
18
  - ./review-documents-with-invalid-links.mjs
20
19
  - ../../utils/format-document-structure.mjs
21
20
  - ../../media/load-media-description.mjs
@@ -7,11 +7,11 @@ import {
7
7
  /**
8
8
  * Generate feedback message for fixing invalid links in a document
9
9
  */
10
- function generateInvalidLinksFeedback(invalidLinks, documentPath, documentExecutionStructure) {
10
+ function generateInvalidLinksFeedback(invalidLinks, documentPath, documentStructure) {
11
11
  const invalidLinksList = invalidLinks.map((link) => `- ${link}`).join("\n");
12
12
 
13
13
  // Build allowed links from document structure for replacement suggestions
14
- const allowedLinks = buildAllowedLinksFromStructure(documentExecutionStructure);
14
+ const allowedLinks = buildAllowedLinksFromStructure(documentStructure);
15
15
  const allowedLinksArray = Array.from(allowedLinks)
16
16
  .filter((link) => link !== documentPath) // Exclude current document path
17
17
  .sort();
@@ -48,7 +48,7 @@ ${allowedLinksList}
48
48
  }
49
49
 
50
50
  export default async function reviewDocumentsWithInvalidLinks(input = {}, options = {}) {
51
- const { documentsWithInvalidLinks = [], documentExecutionStructure = [], locale = "en" } = input;
51
+ const { documentsWithInvalidLinks = [], documentStructure = [], locale = "en" } = input;
52
52
 
53
53
  // If no documents with invalid links, return empty array
54
54
  if (!Array.isArray(documentsWithInvalidLinks) || documentsWithInvalidLinks.length === 0) {
@@ -96,14 +96,10 @@ export default async function reviewDocumentsWithInvalidLinks(input = {}, option
96
96
  if (!doc.path) continue;
97
97
 
98
98
  // Find corresponding document in documentStructure to get additional fields
99
- const structureDoc = documentExecutionStructure.find((item) => item.path === doc.path);
99
+ const structureDoc = documentStructure.find((item) => item.path === doc.path);
100
100
 
101
101
  // Generate feedback message for fixing invalid links
102
- const feedback = generateInvalidLinksFeedback(
103
- doc.invalidLinks,
104
- doc.path,
105
- documentExecutionStructure,
106
- );
102
+ const feedback = generateInvalidLinksFeedback(doc.invalidLinks, doc.path, documentStructure);
107
103
 
108
104
  preparedDocs.push({
109
105
  ...structureDoc,
@@ -1,8 +1,8 @@
1
1
  import chalk from "chalk";
2
2
  import { getMainLanguageFiles } from "../../utils/docs-finder-utils.mjs";
3
3
 
4
- export default async function checkNeedGenerate({ docsDir, locale, documentExecutionStructure }) {
5
- const mainLanguageFiles = await getMainLanguageFiles(docsDir, locale, documentExecutionStructure);
4
+ export default async function checkNeedGenerate({ docsDir, locale, documentStructure }) {
5
+ const mainLanguageFiles = await getMainLanguageFiles(docsDir, locale, documentStructure);
6
6
 
7
7
  if (mainLanguageFiles.length === 0) {
8
8
  console.log(
@@ -48,7 +48,14 @@ export default async function init(input, options) {
48
48
  options,
49
49
  )?.reasoningEffort;
50
50
 
51
- return config;
51
+ // for translation agent
52
+ if (config.translateLanguages) {
53
+ config.translates = config.translateLanguages.map((lang) => ({ language: lang }));
54
+ }
55
+
56
+ return {
57
+ ...config,
58
+ };
52
59
  }
53
60
 
54
61
  async function _init(
@@ -284,7 +291,9 @@ async function _init(
284
291
  ` 1. Use paths like ${chalk.green("./src")}, ${chalk.green("./README.md")} or ${chalk.green("!./src/private")}.`,
285
292
  );
286
293
  console.log(
287
- ` 2. Use globs like ${chalk.green("src/**/*.js")} or ${chalk.green("!private/**/*.js")} for more specific file matching.`,
294
+ ` 2. Use globs like ${chalk.green("src/**/*.js")} or ${chalk.green(
295
+ "!private/**/*.js",
296
+ )} for more specific file matching.`,
288
297
  );
289
298
  console.log(` 3. Use URLs like ${chalk.green("https://example.com/openapi.yaml")}.`);
290
299
  console.log("💡 If you leave this empty, we will scan the entire directory.");
@@ -601,7 +610,7 @@ ${modelSection}
601
610
 
602
611
  // Directory and source path configurations - safely serialize
603
612
  const docsDirSection = yamlStringify({ docsDir: config.docsDir }).trim();
604
- yaml += `${docsDirSection.replace(/^docsDir:/, "docsDir:")} # The directory where the generated documentation will be saved.\n`;
613
+ yaml += `${docsDirSection} # The directory where the generated documentation will be saved.\n`;
605
614
 
606
615
  const sourcesPathSection = yamlStringify({ sourcesPath: config.sourcesPath }).trim();
607
616
  yaml += `${sourcesPathSection.replace(/^sourcesPath:/, "sourcesPath: # The source code paths to analyze.")}\n`;
@@ -76,16 +76,13 @@ export default async function chooseLanguage({ langs, locale, selectedDocs }, op
76
76
  await saveValueToConfig("translateLanguages", updatedTranslateLanguages);
77
77
  }
78
78
 
79
- const newSelectedDocs = selectedDocs.map((doc) => {
80
- return {
81
- ...doc,
82
- translates: selectedLanguages.map((lang) => ({ language: lang })),
83
- };
84
- });
79
+ // Convert selectedLanguages to translates format
80
+ const translates = selectedLanguages.map((lang) => ({ language: lang }));
85
81
 
86
82
  return {
87
83
  selectedLanguages,
88
- selectedDocs: newSelectedDocs,
84
+ selectedDocs,
85
+ translates,
89
86
  };
90
87
  }
91
88
 
@@ -16,15 +16,7 @@ skills:
16
16
  $merge([
17
17
  $,
18
18
  {
19
- 'documentStructure': originalDocumentStructure,
20
- 'documentExecutionStructure': $map(originalDocumentStructure, function($item) {
21
- $merge([
22
- $item,
23
- {
24
- 'translates': [$map(translateLanguages, function($lang) { {"language": $lang} })]
25
- }
26
- ])
27
- })
19
+ 'documentStructure': originalDocumentStructure
28
20
  }
29
21
  ])
30
22
  - url: ../utils/choose-docs.mjs
@@ -9,11 +9,19 @@ input_schema:
9
9
  detailDataSource:
10
10
  type: string
11
11
  description: Context for documentation structure generation, used to assist generate documentation structure
12
- documentExecutionStructure: ../schema/document-execution-structure.yaml
12
+ documentStructure: ../schema/document-structure.yaml
13
+ translates:
14
+ type: array
15
+ items:
16
+ type: object
17
+ properties:
18
+ language:
19
+ type: string
20
+ description: List of languages to translate documents to
13
21
  modifiedFiles:
14
22
  type: array
15
23
  items: { type: string }
16
24
  description: Array of modified files since last generation
17
- iterate_on: documentExecutionStructure
25
+ iterate_on: documentStructure
18
26
  concurrency: 5
19
27
  mode: sequential
@@ -21,7 +21,7 @@ export default async function checkDocument(
21
21
  modifiedFiles,
22
22
  forceRegenerate,
23
23
  locale,
24
- translates,
24
+ translates = [],
25
25
  ...rest
26
26
  },
27
27
  options,
@@ -16,15 +16,7 @@ skills:
16
16
  $merge([
17
17
  $,
18
18
  {
19
- 'documentStructure': originalDocumentStructure,
20
- 'documentExecutionStructure': $map(originalDocumentStructure, function($item) {
21
- $merge([
22
- $item,
23
- {
24
- 'translates': [$map(translateLanguages, function($lang) { {"language": $lang} })]
25
- }
26
- ])
27
- })
19
+ 'documentStructure': originalDocumentStructure
28
20
  }
29
21
  ])
30
22
  - url: ../utils/choose-docs.mjs
@@ -61,7 +61,6 @@ export default async function saveAndTranslateDocument(input, options) {
61
61
  await options.context.invoke(translateAgent, {
62
62
  ...input, // context is required
63
63
  content: doc.content,
64
- translates: doc.translates,
65
64
  title: doc.title,
66
65
  path: doc.path,
67
66
  docsDir,
@@ -18,7 +18,7 @@ function getFeedbackMessage(action) {
18
18
  export default async function chooseDocs(
19
19
  {
20
20
  docs,
21
- documentExecutionStructure,
21
+ documentStructure,
22
22
  boardId,
23
23
  docsDir,
24
24
  isTranslate,
@@ -38,11 +38,7 @@ export default async function chooseDocs(
38
38
  if (!docs || docs.length === 0) {
39
39
  try {
40
40
  // Get all main language .md files in docsDir
41
- const mainLanguageFiles = await getMainLanguageFiles(
42
- docsDir,
43
- locale,
44
- documentExecutionStructure,
45
- );
41
+ const mainLanguageFiles = await getMainLanguageFiles(docsDir, locale, documentStructure);
46
42
 
47
43
  if (mainLanguageFiles.length === 0) {
48
44
  throw new Error(
@@ -56,7 +52,7 @@ export default async function chooseDocs(
56
52
  const choices = mainLanguageFiles.map((file) => {
57
53
  // Convert filename to flat path to find corresponding documentation structure item
58
54
  const flatName = file.replace(/\.md$/, "").replace(/\.\w+(-\w+)?$/, "");
59
- const docItem = documentExecutionStructure.find((item) => {
55
+ const docItem = documentStructure.find((item) => {
60
56
  const itemFlattenedPath = item.path.replace(/^\//, "").replace(/\//g, "-");
61
57
  return itemFlattenedPath === flatName;
62
58
  });
@@ -96,7 +92,7 @@ export default async function chooseDocs(
96
92
  }
97
93
 
98
94
  // Process selected files and convert to found items
99
- foundItems = await processSelectedFiles(selectedFiles, documentExecutionStructure, docsDir);
95
+ foundItems = await processSelectedFiles(selectedFiles, documentStructure, docsDir);
100
96
  } catch (error) {
101
97
  console.log(
102
98
  getActionText(`\nFailed to select documents to {action}: ${error.message}`, docAction),
@@ -106,16 +102,10 @@ export default async function chooseDocs(
106
102
  } else {
107
103
  // Process the provided docs array
108
104
  for (const docPath of docs) {
109
- const foundItem = await findItemByPath(
110
- documentExecutionStructure,
111
- docPath,
112
- boardId,
113
- docsDir,
114
- locale,
115
- );
105
+ const foundItem = await findItemByPath(documentStructure, docPath, boardId, docsDir, locale);
116
106
 
117
107
  if (!foundItem) {
118
- console.warn(`⚠️ Item with path "${docPath}" not found in documentExecutionStructure`);
108
+ console.warn(`⚠️ Item with path "${docPath}" not found in documentStructure`);
119
109
  continue;
120
110
  }
121
111
 
@@ -125,9 +115,7 @@ export default async function chooseDocs(
125
115
  }
126
116
 
127
117
  if (foundItems.length === 0) {
128
- throw new Error(
129
- "None of the specified document paths were found in documentExecutionStructure",
130
- );
118
+ throw new Error("None of the specified document paths were found in documentStructure");
131
119
  }
132
120
  }
133
121
 
@@ -9,7 +9,7 @@ import {
9
9
  } from "../../utils/docs-finder-utils.mjs";
10
10
 
11
11
  export default async function findItemByPath(
12
- { doc, documentExecutionStructure, boardId, docsDir, isTranslate, feedback, locale },
12
+ { doc, documentStructure, boardId, docsDir, isTranslate, feedback, locale },
13
13
  options,
14
14
  ) {
15
15
  let foundItem = null;
@@ -21,11 +21,7 @@ export default async function findItemByPath(
21
21
  if (!docPath) {
22
22
  try {
23
23
  // Get all main language .md files in docsDir
24
- const mainLanguageFiles = await getMainLanguageFiles(
25
- docsDir,
26
- locale,
27
- documentExecutionStructure,
28
- );
24
+ const mainLanguageFiles = await getMainLanguageFiles(docsDir, locale, documentStructure);
29
25
 
30
26
  if (mainLanguageFiles.length === 0) {
31
27
  throw new Error("No documents found in the docs directory");
@@ -65,7 +61,7 @@ export default async function findItemByPath(
65
61
  const flatName = fileNameToFlatPath(selectedFile);
66
62
 
67
63
  // Try to find matching item by comparing flattened paths
68
- const foundItemByFile = findItemByFlatName(documentExecutionStructure, flatName);
64
+ const foundItemByFile = findItemByFlatName(documentStructure, flatName);
69
65
 
70
66
  if (!foundItemByFile) {
71
67
  throw new Error("No document found");
@@ -84,16 +80,10 @@ export default async function findItemByPath(
84
80
  }
85
81
 
86
82
  // Use the utility function to find item and read content
87
- foundItem = await findItemByPathUtil(
88
- documentExecutionStructure,
89
- docPath,
90
- boardId,
91
- docsDir,
92
- locale,
93
- );
83
+ foundItem = await findItemByPathUtil(documentStructure, docPath, boardId, docsDir, locale);
94
84
 
95
85
  if (!foundItem) {
96
- throw new Error(`Item with path "${docPath}" not found in documentExecutionStructure`);
86
+ throw new Error(`Item with path "${docPath}" not found in documentStructure`);
97
87
  }
98
88
 
99
89
  // Prompt for feedback if not provided
@@ -11,7 +11,7 @@ import { getCurrentGitHead, saveGitHeadToConfig } from "../../utils/utils.mjs";
11
11
  * @returns {Promise<Array<{ path: string, success: boolean, error?: string }>>}
12
12
  */
13
13
  export default async function postGenerate({
14
- documentExecutionStructure: documentStructure,
14
+ documentStructure,
15
15
  docsDir,
16
16
  translateLanguages = [],
17
17
  locale,
package/aigne.yaml CHANGED
@@ -68,7 +68,6 @@ agents:
68
68
  - ./agents/clear/clear-media-description.mjs
69
69
 
70
70
  # Utilities
71
- - ./agents/utils/add-translates-to-structure.mjs
72
71
  - ./agents/utils/load-sources.mjs
73
72
  - ./agents/utils/post-generate.mjs
74
73
  - ./agents/utils/save-sidebar.mjs
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aigne/doc-smith",
3
- "version": "0.9.6-beta.2",
3
+ "version": "0.9.7-beta",
4
4
  "description": "AI-driven documentation generation tool built on the AIGNE Framework",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -103,39 +103,26 @@ export const DEFAULT_INCLUDE_PATTERNS = [
103
103
  ];
104
104
 
105
105
  export const DEFAULT_EXCLUDE_PATTERNS = [
106
- "**/aigne-docs/**",
107
106
  "**/doc-smith/**",
108
107
  "**/.aigne/**",
109
- "**/data/**",
110
- "**/public/**",
111
- "**/static/**",
112
108
  "**/vendor/**",
113
109
  "**/temp/**",
114
- "**/*docs/**",
115
- "**/*doc/**",
116
110
  "**/*venv/**",
117
111
  "*.venv/**",
118
- "*test*",
119
- "**/*test/**",
120
- "**/*tests/**",
121
- "**/*examples/**",
122
- "**/playgrounds/**",
123
- "v1/**",
124
112
  "**/dist/**",
125
113
  "**/*build/**",
126
114
  "**/*experimental/**",
127
115
  "**/*deprecated/**",
128
- "**/*misc/**",
129
- "**/*legacy/**",
116
+ "**/misc/**",
117
+ "**/legacy/**",
130
118
  ".git/**",
131
119
  ".github/**",
132
120
  ".next/**",
133
121
  ".vscode/**",
134
- "**/*obj/**",
135
- "**/*bin/**",
122
+ "**/obj/**",
123
+ "**/bin/**",
136
124
  "**/*node_modules/**",
137
125
  "*.log",
138
- "**/*test.*",
139
126
  "**/pnpm-lock.yaml",
140
127
  "**/yarn.lock",
141
128
  "**/package-lock.json",
@@ -36,20 +36,14 @@ export function generateFileName(flatName, locale) {
36
36
 
37
37
  /**
38
38
  * Find a single item by path in documentation structure result and read its content
39
- * @param {Array} documentExecutionStructure - Array of documentation structure items
39
+ * @param {Array} documentStructure - Array of documentation structure items
40
40
  * @param {string} docPath - Document path to find (supports .md filenames)
41
41
  * @param {string} boardId - Board ID for fallback matching
42
42
  * @param {string} docsDir - Docs directory path for reading content
43
43
  * @param {string} locale - Main language locale (e.g., 'en', 'zh', 'fr')
44
44
  * @returns {Promise<Object|null>} Found item with content or null
45
45
  */
46
- export async function findItemByPath(
47
- documentExecutionStructure,
48
- docPath,
49
- boardId,
50
- docsDir,
51
- locale = "en",
52
- ) {
46
+ export async function findItemByPath(documentStructure, docPath, boardId, docsDir, locale = "en") {
53
47
  let foundItem = null;
54
48
  let fileName = null;
55
49
 
@@ -57,10 +51,10 @@ export async function findItemByPath(
57
51
  if (docPath.endsWith(".md")) {
58
52
  fileName = docPath;
59
53
  const flatName = fileNameToFlatPath(docPath);
60
- foundItem = findItemByFlatName(documentExecutionStructure, flatName);
54
+ foundItem = findItemByFlatName(documentStructure, flatName);
61
55
  } else {
62
56
  // First try direct path matching
63
- foundItem = documentExecutionStructure.find((item) => item.path === docPath);
57
+ foundItem = documentStructure.find((item) => item.path === docPath);
64
58
 
65
59
  // If not found and boardId is provided, try boardId-flattenedPath format matching
66
60
  if (!foundItem && boardId) {
@@ -70,7 +64,7 @@ export async function findItemByPath(
70
64
  const flattenedPath = docPath.substring(boardId.length + 1);
71
65
 
72
66
  // Find item by comparing flattened paths
73
- foundItem = documentExecutionStructure.find((item) => {
67
+ foundItem = documentStructure.find((item) => {
74
68
  // Convert item.path to flattened format (replace / with -)
75
69
  const itemFlattenedPath = item.path.replace(/^\//, "").replace(/\//g, "-");
76
70
  return itemFlattenedPath === flattenedPath;
@@ -127,10 +121,10 @@ export async function readFileContent(docsDir, fileName) {
127
121
  * Get main language markdown files from docs directory
128
122
  * @param {string} docsDir - Docs directory path
129
123
  * @param {string} locale - Main language locale (e.g., 'en', 'zh', 'fr')
130
- * @param {Array} documentExecutionStructure - Array of documentation structure items to determine file order
131
- * @returns {Promise<string[]>} Array of main language .md files ordered by documentExecutionStructure
124
+ * @param {Array} documentStructure - Array of documentation structure items to determine file order
125
+ * @returns {Promise<string[]>} Array of main language .md files ordered by documentStructure
132
126
  */
133
- export async function getMainLanguageFiles(docsDir, locale, documentExecutionStructure = null) {
127
+ export async function getMainLanguageFiles(docsDir, locale, documentStructure = null) {
134
128
  // Check if docsDir exists
135
129
  try {
136
130
  await access(docsDir);
@@ -162,17 +156,17 @@ export async function getMainLanguageFiles(docsDir, locale, documentExecutionStr
162
156
  }
163
157
  });
164
158
 
165
- // If documentExecutionStructure is provided, sort files according to the order in documentExecutionStructure
166
- if (documentExecutionStructure && Array.isArray(documentExecutionStructure)) {
159
+ // If documentStructure is provided, sort files according to the order in documentStructure
160
+ if (documentStructure && Array.isArray(documentStructure)) {
167
161
  // Create a map from flat file name to documentation structure order
168
162
  const orderMap = new Map();
169
- documentExecutionStructure.forEach((item, index) => {
163
+ documentStructure.forEach((item, index) => {
170
164
  const itemFlattenedPath = item.path.replace(/^\//, "").replace(/\//g, "-");
171
165
  const expectedFileName = generateFileName(itemFlattenedPath, locale);
172
166
  orderMap.set(expectedFileName, index);
173
167
  });
174
168
 
175
- // Sort filtered files based on their order in documentExecutionStructure
169
+ // Sort filtered files based on their order in documentStructure
176
170
  return filteredFiles.sort((a, b) => {
177
171
  const orderA = orderMap.get(a);
178
172
  const orderB = orderMap.get(b);
@@ -191,7 +185,7 @@ export async function getMainLanguageFiles(docsDir, locale, documentExecutionStr
191
185
  });
192
186
  }
193
187
 
194
- // If no documentExecutionStructure provided, return files in alphabetical order
188
+ // If no documentStructure provided, return files in alphabetical order
195
189
  return filteredFiles.sort();
196
190
  }
197
191
 
@@ -212,12 +206,12 @@ export function fileNameToFlatPath(fileName) {
212
206
 
213
207
  /**
214
208
  * Find documentation structure item by flattened file name
215
- * @param {Array} documentExecutionStructure - Array of documentation structure items
209
+ * @param {Array} documentStructure - Array of documentation structure items
216
210
  * @param {string} flatName - Flattened file name
217
211
  * @returns {Object|null} Found item or null
218
212
  */
219
- export function findItemByFlatName(documentExecutionStructure, flatName) {
220
- return documentExecutionStructure.find((item) => {
213
+ export function findItemByFlatName(documentStructure, flatName) {
214
+ return documentStructure.find((item) => {
221
215
  const itemFlattenedPath = item.path.replace(/^\//, "").replace(/\//g, "-");
222
216
  return itemFlattenedPath === flatName;
223
217
  });
@@ -226,11 +220,11 @@ export function findItemByFlatName(documentExecutionStructure, flatName) {
226
220
  /**
227
221
  * Process selected files and convert to found items with content
228
222
  * @param {string[]} selectedFiles - Array of selected file names
229
- * @param {Array} documentExecutionStructure - Array of documentation structure items
223
+ * @param {Array} documentStructure - Array of documentation structure items
230
224
  * @param {string} docsDir - Docs directory path
231
225
  * @returns {Promise<Object[]>} Array of found items with content
232
226
  */
233
- export async function processSelectedFiles(selectedFiles, documentExecutionStructure, docsDir) {
227
+ export async function processSelectedFiles(selectedFiles, documentStructure, docsDir) {
234
228
  const foundItems = [];
235
229
 
236
230
  for (const selectedFile of selectedFiles) {
@@ -241,7 +235,7 @@ export async function processSelectedFiles(selectedFiles, documentExecutionStruc
241
235
  const flatName = fileNameToFlatPath(selectedFile);
242
236
 
243
237
  // Try to find matching item by comparing flattened paths
244
- const foundItemByFile = findItemByFlatName(documentExecutionStructure, flatName);
238
+ const foundItemByFile = findItemByFlatName(documentStructure, flatName);
245
239
 
246
240
  if (foundItemByFile) {
247
241
  const result = {
@@ -188,7 +188,7 @@ export async function getFilesWithGlob(dir, includePatterns, excludePatterns, gi
188
188
  }
189
189
 
190
190
  // Add default exclusions if not already present
191
- const defaultExclusions = ["node_modules/**", "test/**", "temp/**"];
191
+ const defaultExclusions = ["node_modules/**", "temp/**"];
192
192
  for (const exclusion of defaultExclusions) {
193
193
  if (!allIgnorePatterns.includes(exclusion)) {
194
194
  allIgnorePatterns.push(exclusion);
@@ -1,32 +0,0 @@
1
- type: array
2
- items:
3
- type: object
4
- properties:
5
- title:
6
- type: string
7
- description:
8
- type: string
9
- path:
10
- type: string
11
- description: Path in URL format, cannot be empty, must start with /, no need to include language level, e.g., /zh/about should return /about
12
- parentId:
13
- type:
14
- - string
15
- - "null"
16
- translates:
17
- type: array
18
- items:
19
- type: object
20
- properties:
21
- language:
22
- type: string
23
- description: Language code, such as zh, en, ja, etc.
24
- sourceIds:
25
- type: array
26
- items:
27
- type: string
28
- description: Associated sourceId from `<data_sources>` for subsequent translation and content generation, must come from sourceId in `<data_sources>`, cannot have fake ids, cannot be empty
29
- required:
30
- - title
31
- - description
32
- - path
@@ -1,29 +0,0 @@
1
- export default function addTranslatesToStructure({
2
- originalDocumentStructure = [],
3
- translateLanguages = [],
4
- }) {
5
- const documentExecutionStructure = (originalDocumentStructure || []).map((item) => ({
6
- ...item,
7
- translates: (translateLanguages || []).map((lang) => ({ language: lang })),
8
- }));
9
-
10
- return {
11
- documentExecutionStructure,
12
- };
13
- }
14
-
15
- addTranslatesToStructure.inputSchema = {
16
- type: "object",
17
- properties: {
18
- originalDocumentStructure: { type: "array", items: { type: "object" } },
19
- translateLanguages: { type: "array", items: { type: "string" } },
20
- },
21
- required: ["originalDocumentStructure", "translateLanguages"],
22
- };
23
- addTranslatesToStructure.outputSchema = {
24
- type: "object",
25
- properties: {
26
- documentExecutionStructure: { type: "array" },
27
- },
28
- };
29
- addTranslatesToStructure.task_render_mode = "hide";