@aigne/doc-smith 0.8.11-beta.5 → 0.8.11-beta.7

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 (159) hide show
  1. package/.aigne/doc-smith/config.yaml +3 -1
  2. package/.aigne/doc-smith/output/structure-plan.json +2 -2
  3. package/.aigne/doc-smith/preferences.yml +28 -20
  4. package/.aigne/doc-smith/upload-cache.yaml +702 -0
  5. package/.release-please-manifest.json +1 -1
  6. package/CHANGELOG.md +22 -2
  7. package/README.md +2 -2
  8. package/agents/clear/choose-contents.mjs +2 -2
  9. package/agents/clear/clear-document-structure.mjs +8 -8
  10. package/agents/clear/index.yaml +1 -1
  11. package/agents/evaluate/document-structure.yaml +1 -1
  12. package/agents/generate/check-document-structure.yaml +3 -3
  13. package/agents/generate/check-need-generate-structure.mjs +8 -8
  14. package/agents/generate/document-structure-tools/add-document.mjs +38 -13
  15. package/agents/generate/document-structure-tools/delete-document.mjs +37 -14
  16. package/agents/generate/document-structure-tools/move-document.mjs +46 -19
  17. package/agents/generate/document-structure-tools/update-document.mjs +39 -12
  18. package/agents/generate/generate-structure.yaml +1 -1
  19. package/agents/generate/update-document-structure.yaml +3 -9
  20. package/agents/generate/user-review-document-structure.mjs +15 -14
  21. package/agents/translate/translate-document.yaml +1 -9
  22. package/agents/update/batch-generate-document.yaml +1 -1
  23. package/agents/update/check-document.mjs +2 -2
  24. package/agents/update/check-update-is-single.mjs +2 -1
  25. package/agents/update/document-tools/update-document-content.mjs +24 -14
  26. package/agents/update/fs-tools/glob.mjs +184 -0
  27. package/agents/update/fs-tools/grep.mjs +317 -0
  28. package/agents/update/fs-tools/read-file.mjs +307 -0
  29. package/agents/update/generate-document.yaml +4 -7
  30. package/agents/update/update-document-detail.yaml +6 -10
  31. package/agents/update/user-review-document.mjs +13 -13
  32. package/agents/utils/check-feedback-refiner.mjs +1 -1
  33. package/agents/utils/choose-docs.mjs +1 -1
  34. package/agents/utils/load-document-all-content.mjs +3 -3
  35. package/agents/utils/load-sources.mjs +1 -1
  36. package/agents/utils/save-docs.mjs +7 -28
  37. package/aigne.yaml +2 -2
  38. package/assets/screenshots/doc-complete-setup.png +0 -0
  39. package/assets/screenshots/doc-generate-docs.png +0 -0
  40. package/assets/screenshots/doc-generate.png +0 -0
  41. package/assets/screenshots/doc-generated-successfully.png +0 -0
  42. package/assets/screenshots/doc-publish.png +0 -0
  43. package/assets/screenshots/doc-regenerate.png +0 -0
  44. package/assets/screenshots/doc-translate-langs.png +0 -0
  45. package/assets/screenshots/doc-translate.png +0 -0
  46. package/assets/screenshots/doc-update.png +0 -0
  47. package/docs/_sidebar.md +1 -1
  48. package/docs/advanced-how-it-works.ja.md +31 -31
  49. package/docs/advanced-how-it-works.md +10 -10
  50. package/docs/advanced-how-it-works.zh-TW.md +24 -24
  51. package/docs/advanced-how-it-works.zh.md +20 -20
  52. package/docs/advanced-quality-assurance.ja.md +57 -61
  53. package/docs/advanced-quality-assurance.md +57 -61
  54. package/docs/advanced-quality-assurance.zh-TW.md +57 -61
  55. package/docs/advanced-quality-assurance.zh.md +57 -61
  56. package/docs/advanced.ja.md +8 -4
  57. package/docs/advanced.md +7 -3
  58. package/docs/advanced.zh-TW.md +9 -5
  59. package/docs/advanced.zh.md +9 -5
  60. package/docs/changelog.ja.md +206 -29
  61. package/docs/changelog.md +177 -0
  62. package/docs/changelog.zh-TW.md +229 -52
  63. package/docs/changelog.zh.md +204 -27
  64. package/docs/cli-reference.ja.md +181 -80
  65. package/docs/cli-reference.md +168 -67
  66. package/docs/cli-reference.zh-TW.md +177 -76
  67. package/docs/cli-reference.zh.md +172 -71
  68. package/docs/configuration-interactive-setup.ja.md +45 -42
  69. package/docs/configuration-interactive-setup.md +9 -6
  70. package/docs/configuration-interactive-setup.zh-TW.md +26 -23
  71. package/docs/configuration-interactive-setup.zh.md +25 -22
  72. package/docs/configuration-language-support.ja.md +33 -63
  73. package/docs/configuration-language-support.md +32 -62
  74. package/docs/configuration-language-support.zh-TW.md +35 -65
  75. package/docs/configuration-language-support.zh.md +32 -62
  76. package/docs/configuration-llm-setup.ja.md +25 -23
  77. package/docs/configuration-llm-setup.md +20 -18
  78. package/docs/configuration-llm-setup.zh-TW.md +21 -19
  79. package/docs/configuration-llm-setup.zh.md +20 -18
  80. package/docs/configuration-preferences.ja.md +67 -52
  81. package/docs/configuration-preferences.md +55 -40
  82. package/docs/configuration-preferences.zh-TW.md +69 -54
  83. package/docs/configuration-preferences.zh.md +68 -53
  84. package/docs/configuration.ja.md +98 -58
  85. package/docs/configuration.md +42 -2
  86. package/docs/configuration.zh-TW.md +86 -46
  87. package/docs/configuration.zh.md +76 -36
  88. package/docs/features-generate-documentation.ja.md +49 -55
  89. package/docs/features-generate-documentation.md +49 -55
  90. package/docs/features-generate-documentation.zh-TW.md +54 -60
  91. package/docs/features-generate-documentation.zh.md +48 -54
  92. package/docs/features-publish-your-docs.ja.md +68 -45
  93. package/docs/features-publish-your-docs.md +65 -42
  94. package/docs/features-publish-your-docs.zh-TW.md +74 -51
  95. package/docs/features-publish-your-docs.zh.md +67 -44
  96. package/docs/features-translate-documentation.ja.md +46 -35
  97. package/docs/features-translate-documentation.md +39 -28
  98. package/docs/features-translate-documentation.zh-TW.md +45 -34
  99. package/docs/features-translate-documentation.zh.md +39 -28
  100. package/docs/features-update-and-refine.ja.md +75 -71
  101. package/docs/features-update-and-refine.md +67 -63
  102. package/docs/features-update-and-refine.zh-TW.md +72 -67
  103. package/docs/features-update-and-refine.zh.md +71 -67
  104. package/docs/features.ja.md +29 -19
  105. package/docs/features.md +25 -15
  106. package/docs/features.zh-TW.md +28 -18
  107. package/docs/features.zh.md +31 -21
  108. package/docs/getting-started.ja.md +43 -46
  109. package/docs/getting-started.md +36 -39
  110. package/docs/getting-started.zh-TW.md +41 -44
  111. package/docs/getting-started.zh.md +39 -42
  112. package/docs/overview.ja.md +63 -11
  113. package/docs/overview.md +62 -10
  114. package/docs/overview.zh-TW.md +67 -15
  115. package/docs/overview.zh.md +62 -10
  116. package/docs-mcp/analyze-docs-relevance.yaml +6 -6
  117. package/docs-mcp/docs-search.yaml +1 -1
  118. package/media.md +9 -9
  119. package/package.json +2 -2
  120. package/prompts/common/document-structure/conflict-resolution-guidance.md +3 -3
  121. package/prompts/common/document-structure/document-structure-rules.md +2 -2
  122. package/prompts/detail/custom/custom-components.md +304 -188
  123. package/prompts/detail/document-rules.md +5 -5
  124. package/prompts/detail/generate-document.md +21 -8
  125. package/prompts/detail/update-document.md +8 -12
  126. package/prompts/evaluate/document-structure.md +6 -6
  127. package/prompts/structure/check-document-structure.md +10 -10
  128. package/prompts/structure/document-rules.md +2 -2
  129. package/prompts/structure/generate-structure-system.md +3 -3
  130. package/prompts/structure/structure-example.md +1 -1
  131. package/prompts/structure/structure-getting-started.md +1 -1
  132. package/prompts/structure/update-document-structure.md +18 -14
  133. package/prompts/utils/feedback-refiner.md +3 -3
  134. package/tests/agents/clear/choose-contents.test.mjs +1 -1
  135. package/tests/agents/clear/clear-document-structure.test.mjs +36 -30
  136. package/tests/agents/evaluate/generate-report.test.mjs +1 -1
  137. package/tests/agents/generate/check-need-generate-structure.test.mjs +1 -1
  138. package/tests/agents/generate/document-structure-tools/add-document.test.mjs +2 -2
  139. package/tests/agents/generate/document-structure-tools/delete-document.test.mjs +4 -4
  140. package/tests/agents/generate/document-structure-tools/move-document.test.mjs +12 -12
  141. package/tests/agents/generate/document-structure-tools/update-document.test.mjs +3 -3
  142. package/tests/agents/generate/user-review-document-structure.test.mjs +36 -13
  143. package/tests/agents/update/check-document.test.mjs +1 -1
  144. package/tests/agents/update/document-tools/update-document-content.test.mjs +115 -112
  145. package/tests/agents/update/fs-tools/glob.test.mjs +438 -0
  146. package/tests/agents/update/fs-tools/grep.test.mjs +279 -0
  147. package/tests/agents/update/fs-tools/read-file.test.mjs +553 -0
  148. package/tests/agents/update/user-review-document.test.mjs +48 -27
  149. package/tests/agents/utils/format-document-structure.test.mjs +5 -5
  150. package/tests/agents/utils/load-sources.test.mjs +4 -4
  151. package/tests/agents/utils/save-docs.test.mjs +1 -1
  152. package/tests/utils/conflict-detector.test.mjs +1 -1
  153. package/tests/utils/docs-finder-utils.test.mjs +8 -8
  154. package/types/document-schema.mjs +5 -6
  155. package/types/document-structure-schema.mjs +25 -13
  156. package/utils/conflict-detector.mjs +1 -1
  157. package/utils/constants/index.mjs +4 -4
  158. package/utils/docs-finder-utils.mjs +11 -11
  159. package/utils/markdown-checker.mjs +1 -1
@@ -1,3 +1,3 @@
1
1
  {
2
- ".": "0.8.11-beta.5"
2
+ ".": "0.8.11-beta.7"
3
3
  }
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.8.11-beta.7](https://github.com/AIGNE-io/aigne-doc-smith/compare/v0.8.11-beta.6...v0.8.11-beta.7) (2025-10-03)
4
+
5
+
6
+ ### Features
7
+
8
+ * enhance document generator and updater by fs tools ([#156](https://github.com/AIGNE-io/aigne-doc-smith/issues/156)) ([64ee91c](https://github.com/AIGNE-io/aigne-doc-smith/commit/64ee91c59498b4fd788e287cb81bbc640d042bcc))
9
+ * use shared context for faster structure and doc tuning ([#157](https://github.com/AIGNE-io/aigne-doc-smith/issues/157)) ([e5cb30e](https://github.com/AIGNE-io/aigne-doc-smith/commit/e5cb30ec114d51a19f0086b3e4aaf2ec70aea046))
10
+
11
+
12
+ ### Bug Fixes
13
+
14
+ * update docs and refine custom component prompts ([#160](https://github.com/AIGNE-io/aigne-doc-smith/issues/160)) ([233f3ca](https://github.com/AIGNE-io/aigne-doc-smith/commit/233f3ca449646b39a3e493d2bb1fe59e50376827))
15
+
16
+ ## [0.8.11-beta.6](https://github.com/AIGNE-io/aigne-doc-smith/compare/v0.8.11-beta.5...v0.8.11-beta.6) (2025-10-02)
17
+
18
+
19
+ ### Miscellaneous Chores
20
+
21
+ * release 0.8.11-beta.6 ([ecc8f5c](https://github.com/AIGNE-io/aigne-doc-smith/commit/ecc8f5c4ff9cc813e5cf7e35cbfdb915826cd183))
22
+
3
23
  ## [0.8.11-beta.5](https://github.com/AIGNE-io/aigne-doc-smith/compare/v0.8.11-beta.4...v0.8.11-beta.5) (2025-10-01)
4
24
 
5
25
 
@@ -79,7 +99,7 @@
79
99
  ### Bug Fixes
80
100
 
81
101
  * polish code test ([#122](https://github.com/AIGNE-io/aigne-doc-smith/issues/122)) ([0629705](https://github.com/AIGNE-io/aigne-doc-smith/commit/0629705ebd271282411d507421c1ba5dd01473b9))
82
- * update document structure review prompts and display ([#119](https://github.com/AIGNE-io/aigne-doc-smith/issues/119)) ([e2d99db](https://github.com/AIGNE-io/aigne-doc-smith/commit/e2d99db83ff3a6266b32dd450a79b6e000aff09e))
102
+ * update documentation structure review prompts and display ([#119](https://github.com/AIGNE-io/aigne-doc-smith/issues/119)) ([e2d99db](https://github.com/AIGNE-io/aigne-doc-smith/commit/e2d99db83ff3a6266b32dd450a79b6e000aff09e))
83
103
  * update usage rules for field elements ([#120](https://github.com/AIGNE-io/aigne-doc-smith/issues/120)) ([434f161](https://github.com/AIGNE-io/aigne-doc-smith/commit/434f161ab7dd989d57ca670f36d0828c09abe38a))
84
104
 
85
105
  ## [0.8.10-beta.1](https://github.com/AIGNE-io/aigne-doc-smith/compare/v0.8.10-beta...v0.8.10-beta.1) (2025-09-18)
@@ -87,7 +107,7 @@
87
107
 
88
108
  ### Features
89
109
 
90
- * support document structure review workflow ([#117](https://github.com/AIGNE-io/aigne-doc-smith/issues/117)) ([ec7ae80](https://github.com/AIGNE-io/aigne-doc-smith/commit/ec7ae80b26a1b66928bddef7ac401f633a0f5a2b))
110
+ * support documentation structure review workflow ([#117](https://github.com/AIGNE-io/aigne-doc-smith/issues/117)) ([ec7ae80](https://github.com/AIGNE-io/aigne-doc-smith/commit/ec7ae80b26a1b66928bddef7ac401f633a0f5a2b))
91
111
 
92
112
 
93
113
  ### Bug Fixes
package/README.md CHANGED
@@ -45,7 +45,7 @@ As shown in the diagram, DocSmith integrates seamlessly with other [AIGNE](https
45
45
 
46
46
  - **AIGNE Hub Integration**: Use [AIGNE Hub](https://www.aigne.io/en/hub) without API keys, switch between Google Gemini, OpenAI GPT, Claude, and more
47
47
  - **Multiple LLM Support**: Bring your own API keys for OpenAI, Anthropic, Google, and other providers
48
- - **Discuss Kit Publishing**: Deploy to [docsmith.aigne.io](https://docsmith.aigne.io/app/) or your own [Discuss Kit](https://www.web3kit.rocks/discuss-kit) instance
48
+ - **One-Click Publishing**: Make your docs live and generate shareable links for your team - publish to [docsmith.aigne.io](https://docsmith.aigne.io/app/) or your own [Discuss Kit](https://www.web3kit.rocks/discuss-kit) instance
49
49
 
50
50
  ### 🔄 Smart Updates
51
51
 
@@ -107,7 +107,7 @@ DocSmith supports multiple AI providers:
107
107
  ```bash
108
108
  # Switch models effortlessly
109
109
  aigne doc generate --model google:gemini-2.5-pro
110
- aigne doc generate --model claude:claude-3-5-sonnet
110
+ aigne doc generate --model anthropic:claude-sonnet-4-5
111
111
  aigne doc generate --model openai:gpt-4o
112
112
  ```
113
113
 
@@ -5,8 +5,8 @@ const TARGET_METADATA = {
5
5
  agent: "clearGeneratedDocs",
6
6
  },
7
7
  documentStructure: {
8
- label: "document structure",
9
- description: "Delete the document structure and all generated documents.",
8
+ label: "documentation structure",
9
+ description: "Delete the documentation structure and all generated documents.",
10
10
  agent: "clearDocumentStructure",
11
11
  },
12
12
  documentConfig: {
@@ -20,8 +20,8 @@ export default async function clearDocumentStructure(input = {}, _options = {})
20
20
 
21
21
  const structureDisplayPath = toDisplayPath(structurePlanPath);
22
22
  const structureMessage = structureExists
23
- ? `Cleared document structure plan (${structureDisplayPath})`
24
- : `Document structure plan already empty (${structureDisplayPath})`;
23
+ ? `Cleared documentation structure (${structureDisplayPath})`
24
+ : `Documentation structure already empty (${structureDisplayPath})`;
25
25
 
26
26
  results.push({
27
27
  type: "structure",
@@ -33,7 +33,7 @@ export default async function clearDocumentStructure(input = {}, _options = {})
33
33
  results.push({
34
34
  type: "structure",
35
35
  error: true,
36
- message: `Failed to clear document structure plan: ${error.message}`,
36
+ message: `Failed to clear documentation structure: ${error.message}`,
37
37
  });
38
38
  }
39
39
 
@@ -69,11 +69,11 @@ export default async function clearDocumentStructure(input = {}, _options = {})
69
69
 
70
70
  let header;
71
71
  if (errorItems > 0) {
72
- header = "Document structure cleanup finished with some issues.";
72
+ header = "Documentation Structure cleanup finished with some issues.";
73
73
  } else if (clearedItems > 0) {
74
- header = "Document structure cleared successfully!";
74
+ header = "Documentation Structure cleared successfully!";
75
75
  } else {
76
- header = "Document structure already empty.";
76
+ header = "Documentation Structure already empty.";
77
77
  }
78
78
 
79
79
  const detailLines = results.map((item) => `- ${item.message}`).join("\n");
@@ -101,6 +101,6 @@ clearDocumentStructure.input_schema = {
101
101
  },
102
102
  };
103
103
 
104
- clearDocumentStructure.taskTitle = "Clear document structure and all generated documents";
104
+ clearDocumentStructure.taskTitle = "Clear documentation structure and all generated documents";
105
105
  clearDocumentStructure.description =
106
- "Clear the document structure plan (structure-plan.json) and optionally the documents directory";
106
+ "Clear the documentation structure (structure-plan.json) and optionally the documents directory";
@@ -2,7 +2,7 @@ type: team
2
2
  name: clear
3
3
  alias:
4
4
  - clear
5
- description: Clear various types of data including document structure, generated documents, configuration, and authorization tokens
5
+ description: Clear various types of data including documentation structure, generated documents, configuration, and authorization tokens
6
6
  skills:
7
7
  - url: ../init/index.mjs
8
8
  default_input:
@@ -11,7 +11,7 @@ input_schema:
11
11
  properties:
12
12
  documentStructureYaml:
13
13
  type: string
14
- description: Document structure planning
14
+ description: Documentation structure data
15
15
  purposes:
16
16
  type: string
17
17
  description: User-selected document goals
@@ -1,5 +1,5 @@
1
1
  name: checkDocumentStructure
2
- description: Check the Document Structure to ensure it meets expectations, especially in scenarios with previous generation results and user feedback.
2
+ description: Check the Documentation Structure to ensure it meets expectations, especially in scenarios with previous generation results and user feedback.
3
3
  instructions:
4
4
  url: ../../prompts/structure/check-document-structure.md
5
5
  input_schema:
@@ -7,10 +7,10 @@ input_schema:
7
7
  properties:
8
8
  documentStructure:
9
9
  $ref: ../schema/document-structure.yaml
10
- description: Newly generated document structure.
10
+ description: Newly generated documentation structure.
11
11
  originalDocumentStructure:
12
12
  $ref: ../schema/document-structure.yaml
13
- description: Previous generation's document structure for comparison. If it doesn't exist, the check passes by default.
13
+ description: Previous generation's documentation structure for comparison. If it doesn't exist, the check passes by default.
14
14
  feedback:
15
15
  type: string
16
16
  description: User feedback provided for the previous generation's results.
@@ -18,10 +18,10 @@ export default async function checkNeedGenerateStructure(
18
18
  if (!originalDocumentStructure) {
19
19
  const choice = await options.prompts.select({
20
20
  message:
21
- "Your project configuration is complete. Would you like to generate the document structure now?",
21
+ "Your project configuration is complete. Would you like to generate the documentation structure now?",
22
22
  choices: [
23
23
  {
24
- name: "Generate now - Start generating the document structure",
24
+ name: "Generate now - Start generating the documentation structure",
25
25
  value: "generate",
26
26
  },
27
27
  {
@@ -49,7 +49,7 @@ export default async function checkNeedGenerateStructure(
49
49
  }
50
50
  }
51
51
 
52
- // Check if we need to regenerate document structure
52
+ // Check if we need to regenerate documentation structure
53
53
  let shouldRegenerate = false;
54
54
  let finalFeedback = feedback;
55
55
 
@@ -82,7 +82,7 @@ export default async function checkNeedGenerateStructure(
82
82
  finalFeedback = `
83
83
  ${finalFeedback || ""}
84
84
 
85
- Update document structure based on the latest DataSources:
85
+ Update documentation structure based on the latest DataSources:
86
86
  1. For new content, add new sections as needed or supplement existing section displays
87
87
  2. Be cautious when deleting sections, unless all associated sourceIds have been removed
88
88
  3. Do not modify the path of existing sections
@@ -97,11 +97,11 @@ export default async function checkNeedGenerateStructure(
97
97
  finalFeedback = `
98
98
  ${finalFeedback || ""}
99
99
 
100
- User requested forced regeneration of document structure. Please regenerate based on the latest Data Sources and user requirements, **allowing any modifications**.
100
+ User requested forced regeneration of documentation structure. Please regenerate based on the latest Data Sources and user requirements, **allowing any modifications**.
101
101
  `;
102
102
  }
103
103
 
104
- // If no regeneration needed, return original document structure
104
+ // If no regeneration needed, return original documentation structure
105
105
  if (originalDocumentStructure && !finalFeedback && !shouldRegenerate) {
106
106
  return {
107
107
  documentStructure: originalDocumentStructure,
@@ -110,7 +110,7 @@ export default async function checkNeedGenerateStructure(
110
110
 
111
111
  const planningAgent = options.context.agents["refineDocumentStructure"];
112
112
 
113
- // Get user preferences for document structure and global scope
113
+ // Get user preferences for documentation structure and global scope
114
114
  const structureRules = getActiveRulesForScope("structure", []);
115
115
  const globalRules = getActiveRulesForScope("global", []);
116
116
 
@@ -185,4 +185,4 @@ export default async function checkNeedGenerateStructure(
185
185
  };
186
186
  }
187
187
 
188
- checkNeedGenerateStructure.taskTitle = "Check if document structure needs generate or update";
188
+ checkNeedGenerateStructure.taskTitle = "Check if documentation structure needs generate or update";
@@ -4,32 +4,47 @@ import {
4
4
  validateAddDocumentInput,
5
5
  } from "../../../types/document-structure-schema.mjs";
6
6
 
7
- export default async function addDocument(input) {
7
+ export default async function addDocument(input, options) {
8
8
  // Validate input using Zod schema
9
9
  const validation = validateAddDocumentInput(input);
10
10
  if (!validation.success) {
11
- console.log(`⚠️ Cannot add document: ${validation.error}`);
12
- return { documentStructure: input.documentStructure };
11
+ const errorMessage = `Cannot add document: ${validation.error}`;
12
+ console.log(`⚠️ ${errorMessage}`);
13
+ return {
14
+ documentStructure: input.documentStructure,
15
+ error: { message: errorMessage },
16
+ };
13
17
  }
14
18
 
15
- const { documentStructure, title, description, path, parentId, sourceIds } = validation.data;
19
+ const { title, description, path, parentId, sourceIds } = validation.data;
20
+ let documentStructure = options?.context?.userContext?.currentStructure;
21
+
22
+ if (!documentStructure) {
23
+ documentStructure = input.documentStructure;
24
+ }
16
25
 
17
26
  // Validate parent exists if parentId is provided
18
27
  if (parentId && parentId !== "null") {
19
28
  const parentExists = documentStructure.some((item) => item.path === parentId);
20
29
  if (!parentExists) {
21
- console.log(`⚠️ Cannot add document: Parent document '${parentId}' not found.`);
22
- return { documentStructure };
30
+ const errorMessage = `Cannot add document: Parent document '${parentId}' not found.`;
31
+ console.log(`⚠️ ${errorMessage}`);
32
+ return {
33
+ documentStructure,
34
+ error: { message: errorMessage },
35
+ };
23
36
  }
24
37
  }
25
38
 
26
39
  // Check if document with same path already exists
27
40
  const existingDocument = documentStructure.find((item) => item.path === path);
28
41
  if (existingDocument) {
29
- console.log(
30
- `⚠️ Cannot add document: A document with path '${path}' already exists. Choose a different path.`,
31
- );
32
- return { documentStructure };
42
+ const errorMessage = `Cannot add document: A document with path '${path}' already exists. Choose a different path.`;
43
+ console.log(`⚠️ ${errorMessage}`);
44
+ return {
45
+ documentStructure,
46
+ error: { message: errorMessage },
47
+ };
33
48
  }
34
49
 
35
50
  // Create new document object
@@ -41,16 +56,26 @@ export default async function addDocument(input) {
41
56
  sourceIds: [...sourceIds], // Create a copy of the array
42
57
  };
43
58
 
44
- // Add the new document to the document structure
59
+ // Add the document to the structure
45
60
  const updatedStructure = [...documentStructure, newDocument];
46
61
 
62
+ const successMessage = `addDocument executed successfully.
63
+ Successfully added document '${title}' with path '${path}'.
64
+ Check if the latest version of documentStructure meets user feedback, if so, just return 'success'.`;
65
+
66
+ // update shared document structure
67
+ if (options?.context?.userContext) {
68
+ options.context.userContext.currentStructure = updatedStructure;
69
+ }
70
+
47
71
  return {
48
72
  documentStructure: updatedStructure,
73
+ message: successMessage,
49
74
  addedDocument: newDocument,
50
75
  };
51
76
  }
52
77
 
53
- addDocument.taskTitle = "Add new document";
54
- addDocument.description = "Add a new document to the document structure";
78
+ addDocument.taskTitle = "Add document";
79
+ addDocument.description = "Add a document to the documentation structure";
55
80
  addDocument.inputSchema = getAddDocumentInputJsonSchema();
56
81
  addDocument.outputSchema = getAddDocumentOutputJsonSchema();
@@ -4,23 +4,34 @@ import {
4
4
  validateDeleteDocumentInput,
5
5
  } from "../../../types/document-structure-schema.mjs";
6
6
 
7
- export default async function deleteDocument(input) {
7
+ export default async function deleteDocument(input, options) {
8
8
  // Validate input using Zod schema
9
9
  const validation = validateDeleteDocumentInput(input);
10
10
  if (!validation.success) {
11
- console.log(`⚠️ Cannot delete document: ${validation.error}`);
12
- return { documentStructure: input.documentStructure };
11
+ const errorMessage = `Cannot delete document: ${validation.error}`;
12
+ console.log(`⚠️ ${errorMessage}`);
13
+ return {
14
+ documentStructure: input.documentStructure,
15
+ error: { message: errorMessage },
16
+ };
13
17
  }
14
18
 
15
- const { documentStructure, path } = validation.data;
19
+ const { path } = validation.data;
20
+ let documentStructure = options?.context?.userContext?.currentStructure;
21
+
22
+ if (!documentStructure) {
23
+ documentStructure = input.documentStructure;
24
+ }
16
25
 
17
26
  // Find the document to delete
18
27
  const documentIndex = documentStructure.findIndex((item) => item.path === path);
19
28
  if (documentIndex === -1) {
20
- console.log(
21
- `⚠️ Cannot delete document: Document '${path}' does not exist. Please choose an existing document to delete.`,
22
- );
23
- return { documentStructure };
29
+ const errorMessage = `Cannot delete document: Document '${path}' does not exist. Please choose an existing document to delete.`;
30
+ console.log(`⚠️ ${errorMessage}`);
31
+ return {
32
+ documentStructure,
33
+ error: { message: errorMessage },
34
+ };
24
35
  }
25
36
 
26
37
  const documentToDelete = documentStructure[documentIndex];
@@ -28,22 +39,34 @@ export default async function deleteDocument(input) {
28
39
  // Check if any other documents have this document as parent
29
40
  const childDocuments = documentStructure.filter((item) => item.parentId === path);
30
41
  if (childDocuments.length > 0) {
31
- console.log(
32
- `⚠️ Cannot delete document: Document '${path}' has ${childDocuments.length} child document(s): ${childDocuments.map((p) => p.path).join(", ")}. Please first move or delete these child documents.`,
33
- );
34
- return { documentStructure };
42
+ const errorMessage = `Cannot delete document: Document '${path}' has ${childDocuments.length} child document(s): ${childDocuments.map((p) => p.path).join(", ")}. Please first move or delete these child documents.`;
43
+ console.log(`⚠️ ${errorMessage}`);
44
+ return {
45
+ documentStructure,
46
+ error: { message: errorMessage },
47
+ };
35
48
  }
36
49
 
37
- // Remove the document from the document structure
50
+ // Remove the document from the structure
38
51
  const updatedStructure = documentStructure.filter((_, index) => index !== documentIndex);
39
52
 
53
+ const successMessage = `deleteDocument executed successfully.
54
+ Successfully deleted document '${documentToDelete.title}' with path '${path}'.
55
+ Check if the latest version of documentStructure meets user feedback, if so, just return 'success'.`;
56
+
57
+ // update shared document structure
58
+ if (options?.context?.userContext) {
59
+ options.context.userContext.currentStructure = updatedStructure;
60
+ }
61
+
40
62
  return {
41
63
  documentStructure: updatedStructure,
64
+ message: successMessage,
42
65
  deletedDocument: documentToDelete,
43
66
  };
44
67
  }
45
68
 
46
69
  deleteDocument.taskTitle = "Delete document";
47
- deleteDocument.description = "Delete a document from the document structure";
70
+ deleteDocument.description = "Remove a document from the documentation structure";
48
71
  deleteDocument.inputSchema = getDeleteDocumentInputJsonSchema();
49
72
  deleteDocument.outputSchema = getDeleteDocumentOutputJsonSchema();
@@ -4,23 +4,34 @@ import {
4
4
  validateMoveDocumentInput,
5
5
  } from "../../../types/document-structure-schema.mjs";
6
6
 
7
- export default async function moveDocument(input) {
7
+ export default async function moveDocument(input, options) {
8
8
  // Validate input using Zod schema
9
9
  const validation = validateMoveDocumentInput(input);
10
10
  if (!validation.success) {
11
- console.log(`Error: Cannot move document - ${validation.error}`);
12
- return { documentStructure: input.documentStructure };
11
+ const errorMessage = `Cannot move document: ${validation.error}`;
12
+ console.log(`⚠️ ${errorMessage}`);
13
+ return {
14
+ documentStructure: input.documentStructure,
15
+ error: { message: errorMessage },
16
+ };
13
17
  }
14
18
 
15
- const { documentStructure, path, newParentId } = validation.data;
19
+ const { path, newParentId } = validation.data;
20
+ let documentStructure = options?.context?.userContext?.currentStructure;
21
+
22
+ if (!documentStructure) {
23
+ documentStructure = input.documentStructure;
24
+ }
16
25
 
17
26
  // Find the document to move
18
27
  const documentIndex = documentStructure.findIndex((item) => item.path === path);
19
28
  if (documentIndex === -1) {
20
- console.log(
21
- `Error: Cannot move document - Document '${path}' does not exist. Please select an existing document to move.`,
22
- );
23
- return { documentStructure };
29
+ const errorMessage = `Cannot move document: Document '${path}' does not exist. Please select an existing document to move.`;
30
+ console.log(`⚠️ ${errorMessage}`);
31
+ return {
32
+ documentStructure,
33
+ error: { message: errorMessage },
34
+ };
24
35
  }
25
36
 
26
37
  const documentToMove = documentStructure[documentIndex];
@@ -34,10 +45,12 @@ export default async function moveDocument(input) {
34
45
  ) {
35
46
  const newParentExists = documentStructure.some((item) => item.path === newParentId);
36
47
  if (!newParentExists) {
37
- console.log(
38
- `Error: Cannot move document - Target parent document '${newParentId}' does not exist. Please select an existing parent document.`,
39
- );
40
- return { documentStructure };
48
+ const errorMessage = `Cannot move document: Target parent document '${newParentId}' does not exist. Please select an existing parent document.`;
49
+ console.log(`⚠️ ${errorMessage}`);
50
+ return {
51
+ documentStructure,
52
+ error: { message: errorMessage },
53
+ };
41
54
  }
42
55
 
43
56
  // Check for circular dependency: the new parent cannot be a descendant of the document being moved
@@ -52,10 +65,12 @@ export default async function moveDocument(input) {
52
65
  };
53
66
 
54
67
  if (isDescendant(path, newParentId)) {
55
- console.log(
56
- `Error: Cannot move document - Moving '${path}' under '${newParentId}' would create an invalid hierarchy. Please select a parent that is not nested under the document being moved.`,
57
- );
58
- return { documentStructure };
68
+ const errorMessage = `Cannot move document: Moving '${path}' under '${newParentId}' would create an invalid hierarchy. Please select a parent that is not nested under the document being moved.`;
69
+ console.log(`⚠️ ${errorMessage}`);
70
+ return {
71
+ documentStructure,
72
+ error: { message: errorMessage },
73
+ };
59
74
  }
60
75
  }
61
76
 
@@ -65,18 +80,30 @@ export default async function moveDocument(input) {
65
80
  parentId: newParentId || null,
66
81
  };
67
82
 
68
- // Update the document structure
83
+ // Update the document's position in the structure
69
84
  const updatedStructure = [...documentStructure];
70
85
  updatedStructure[documentIndex] = updatedDocument;
71
86
 
87
+ const newParentText = newParentId ? `'${newParentId}'` : "root level";
88
+ const successMessage = `moveDocument executed successfully.
89
+ Successfully moved document '${documentToMove.title}' to ${newParentText}.
90
+ Check if the latest version of documentStructure meets user feedback, if so, just return 'success'.`;
91
+
92
+ // update shared document structure
93
+ if (options?.context?.userContext) {
94
+ options.context.userContext.currentStructure = updatedStructure;
95
+ }
96
+
72
97
  return {
73
98
  documentStructure: updatedStructure,
99
+ message: successMessage,
74
100
  originalDocument: documentToMove,
75
- updatedDocument,
101
+ updatedDocument: updatedDocument,
76
102
  };
77
103
  }
78
104
 
79
105
  moveDocument.taskTitle = "Move document";
80
- moveDocument.description = "Move a document to a different parent in the document structure";
106
+ moveDocument.description =
107
+ "Relocate a document to a different parent in the documentation structure";
81
108
  moveDocument.inputSchema = getMoveDocumentInputJsonSchema();
82
109
  moveDocument.outputSchema = getMoveDocumentOutputJsonSchema();
@@ -4,23 +4,34 @@ import {
4
4
  validateUpdateDocumentInput,
5
5
  } from "../../../types/document-structure-schema.mjs";
6
6
 
7
- export default async function updateDocument(input) {
7
+ export default async function updateDocument(input, options) {
8
8
  // Validate input using Zod schema
9
9
  const validation = validateUpdateDocumentInput(input);
10
10
  if (!validation.success) {
11
- console.log(`⚠️ Cannot update document: ${validation.error}`);
12
- return { documentStructure: input.documentStructure };
11
+ const errorMessage = `Cannot update document: ${validation.error}`;
12
+ console.log(`⚠️ ${errorMessage}`);
13
+ return {
14
+ documentStructure: input.documentStructure,
15
+ error: { message: errorMessage },
16
+ };
13
17
  }
14
18
 
15
- const { documentStructure, path, title, description, sourceIds } = validation.data;
19
+ const { path, title, description, sourceIds } = validation.data;
20
+ let documentStructure = options?.context?.userContext?.currentStructure;
21
+
22
+ if (!documentStructure) {
23
+ documentStructure = input.documentStructure;
24
+ }
16
25
 
17
26
  // Find the document to update
18
27
  const documentIndex = documentStructure.findIndex((item) => item.path === path);
19
28
  if (documentIndex === -1) {
20
- console.log(
21
- `⚠️ Cannot update document: Document '${path}' does not exist. Choose an existing document to update.`,
22
- );
23
- return { documentStructure };
29
+ const errorMessage = `Cannot update document: Document '${path}' does not exist. Choose an existing document to update.`;
30
+ console.log(`⚠️ ${errorMessage}`);
31
+ return {
32
+ documentStructure,
33
+ error: { message: errorMessage },
34
+ };
24
35
  }
25
36
 
26
37
  const originalDocument = documentStructure[documentIndex];
@@ -33,18 +44,34 @@ export default async function updateDocument(input) {
33
44
  ...(sourceIds !== undefined && { sourceIds: [...sourceIds] }), // Create a copy of the array
34
45
  };
35
46
 
36
- // Update the document structure
47
+ // Update the document in the structure
37
48
  const updatedStructure = [...documentStructure];
38
49
  updatedStructure[documentIndex] = updatedDocument;
39
50
 
51
+ const updates = [];
52
+ if (title !== undefined) updates.push(`title to '${title}'`);
53
+ if (description !== undefined) updates.push("description");
54
+ if (sourceIds !== undefined) updates.push("sourceIds");
55
+ const updatesText = updates.length > 0 ? updates.join(", ") : "properties";
56
+
57
+ const successMessage = `updateDocument executed successfully.
58
+ Successfully updated ${updatesText} for document '${path}'.
59
+ Check if the latest version of documentStructure meets user feedback, if so, just return 'success'.`;
60
+
61
+ // update shared document structure
62
+ if (options?.context?.userContext) {
63
+ options.context.userContext.currentStructure = updatedStructure;
64
+ }
65
+
40
66
  return {
41
67
  documentStructure: updatedStructure,
42
- originalDocument,
43
- updatedDocument,
68
+ message: successMessage,
69
+ originalDocument: originalDocument,
70
+ updatedDocument: updatedDocument,
44
71
  };
45
72
  }
46
73
 
47
74
  updateDocument.taskTitle = "Update document";
48
- updateDocument.description = "Update properties of an existing document in the document structure";
75
+ updateDocument.description = "Modify properties of a document in the documentation structure";
49
76
  updateDocument.inputSchema = getUpdateDocumentInputJsonSchema();
50
77
  updateDocument.outputSchema = getUpdateDocumentOutputJsonSchema();
@@ -13,7 +13,7 @@ input_schema:
13
13
  description: Primary language for documentation (e.g., zh, en, ja)
14
14
  datasources:
15
15
  type: string
16
- description: Project content and context to help generate document structure
16
+ description: Project content and context to help generate documentation structure
17
17
  targetAudience:
18
18
  type: string
19
19
  description: Target audience for the documentation
@@ -1,6 +1,6 @@
1
1
  type: ai
2
2
  name: updateDocumentStructure
3
- description: Update document structure based on user feedback and intentions using structure modification tools
3
+ description: Update documentation structure based on user feedback and intentions using structure modification tools
4
4
  instructions:
5
5
  url: ../../prompts/structure/update-document-structure.md
6
6
  input_schema:
@@ -15,7 +15,7 @@ input_schema:
15
15
  description: User language, e.g. zh, en
16
16
  datasources:
17
17
  type: string
18
- description: Context for document structure
18
+ description: Context for documentation structure
19
19
  glossary:
20
20
  type: string
21
21
  description: Glossary of terms
@@ -28,13 +28,7 @@ input_schema:
28
28
  required:
29
29
  - documentStructure
30
30
  - feedback
31
- output_schema:
32
- type: object
33
- properties:
34
- documentStructure: ../schema/document-structure.yaml
35
- operationSummary:
36
- type: string
37
- description: Summary of the operations performed on the document structure
31
+ output_key: message
38
32
  skills:
39
33
  - ./document-structure-tools/add-document.mjs
40
34
  - ./document-structure-tools/delete-document.mjs