@aigne/doc-smith 0.8.11-beta.6 → 0.8.11

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 (116) hide show
  1. package/.aigne/doc-smith/config.yaml +2 -0
  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 +20 -0
  7. package/README.md +1 -1
  8. package/agents/generate/document-structure-tools/add-document.mjs +35 -10
  9. package/agents/generate/document-structure-tools/delete-document.mjs +35 -12
  10. package/agents/generate/document-structure-tools/move-document.mjs +43 -17
  11. package/agents/generate/document-structure-tools/update-document.mjs +37 -10
  12. package/agents/generate/update-document-structure.yaml +1 -7
  13. package/agents/generate/user-review-document-structure.mjs +5 -4
  14. package/agents/translate/translate-document.yaml +1 -9
  15. package/agents/update/check-update-is-single.mjs +2 -1
  16. package/agents/update/document-tools/update-document-content.mjs +24 -14
  17. package/agents/update/fs-tools/glob.mjs +184 -0
  18. package/agents/update/fs-tools/grep.mjs +317 -0
  19. package/agents/update/fs-tools/read-file.mjs +307 -0
  20. package/agents/update/generate-document.yaml +4 -7
  21. package/agents/update/update-document-detail.yaml +6 -10
  22. package/agents/update/user-review-document.mjs +13 -13
  23. package/assets/screenshots/doc-complete-setup.png +0 -0
  24. package/assets/screenshots/doc-generate-docs.png +0 -0
  25. package/assets/screenshots/doc-generate.png +0 -0
  26. package/assets/screenshots/doc-generated-successfully.png +0 -0
  27. package/assets/screenshots/doc-publish.png +0 -0
  28. package/assets/screenshots/doc-regenerate.png +0 -0
  29. package/assets/screenshots/doc-translate-langs.png +0 -0
  30. package/assets/screenshots/doc-translate.png +0 -0
  31. package/assets/screenshots/doc-update.png +0 -0
  32. package/docs/advanced-how-it-works.ja.md +31 -31
  33. package/docs/advanced-how-it-works.md +9 -9
  34. package/docs/advanced-how-it-works.zh-TW.md +24 -24
  35. package/docs/advanced-how-it-works.zh.md +20 -20
  36. package/docs/advanced-quality-assurance.ja.md +57 -61
  37. package/docs/advanced-quality-assurance.md +57 -61
  38. package/docs/advanced-quality-assurance.zh-TW.md +57 -61
  39. package/docs/advanced-quality-assurance.zh.md +57 -61
  40. package/docs/advanced.ja.md +8 -4
  41. package/docs/advanced.md +7 -3
  42. package/docs/advanced.zh-TW.md +9 -5
  43. package/docs/advanced.zh.md +9 -5
  44. package/docs/changelog.ja.md +206 -29
  45. package/docs/changelog.md +177 -0
  46. package/docs/changelog.zh-TW.md +229 -52
  47. package/docs/changelog.zh.md +204 -27
  48. package/docs/cli-reference.ja.md +82 -52
  49. package/docs/cli-reference.md +56 -26
  50. package/docs/cli-reference.zh-TW.md +82 -52
  51. package/docs/cli-reference.zh.md +70 -40
  52. package/docs/configuration-interactive-setup.ja.md +45 -42
  53. package/docs/configuration-interactive-setup.md +8 -5
  54. package/docs/configuration-interactive-setup.zh-TW.md +26 -23
  55. package/docs/configuration-interactive-setup.zh.md +25 -22
  56. package/docs/configuration-language-support.ja.md +33 -63
  57. package/docs/configuration-language-support.md +32 -62
  58. package/docs/configuration-language-support.zh-TW.md +35 -65
  59. package/docs/configuration-language-support.zh.md +32 -62
  60. package/docs/configuration-llm-setup.ja.md +25 -23
  61. package/docs/configuration-llm-setup.md +20 -18
  62. package/docs/configuration-llm-setup.zh-TW.md +21 -19
  63. package/docs/configuration-llm-setup.zh.md +20 -18
  64. package/docs/configuration-preferences.ja.md +67 -52
  65. package/docs/configuration-preferences.md +56 -41
  66. package/docs/configuration-preferences.zh-TW.md +69 -54
  67. package/docs/configuration-preferences.zh.md +68 -53
  68. package/docs/configuration.ja.md +65 -81
  69. package/docs/configuration.md +19 -35
  70. package/docs/configuration.zh-TW.md +62 -79
  71. package/docs/configuration.zh.md +50 -67
  72. package/docs/features-generate-documentation.ja.md +44 -69
  73. package/docs/features-generate-documentation.md +36 -61
  74. package/docs/features-generate-documentation.zh-TW.md +42 -67
  75. package/docs/features-generate-documentation.zh.md +41 -67
  76. package/docs/features-publish-your-docs.ja.md +36 -36
  77. package/docs/features-publish-your-docs.md +2 -2
  78. package/docs/features-publish-your-docs.zh-TW.md +21 -21
  79. package/docs/features-publish-your-docs.zh.md +23 -23
  80. package/docs/features-translate-documentation.ja.md +40 -31
  81. package/docs/features-translate-documentation.md +15 -6
  82. package/docs/features-translate-documentation.zh-TW.md +37 -28
  83. package/docs/features-translate-documentation.zh.md +23 -14
  84. package/docs/features-update-and-refine.ja.md +68 -118
  85. package/docs/features-update-and-refine.md +58 -108
  86. package/docs/features-update-and-refine.zh-TW.md +67 -116
  87. package/docs/features-update-and-refine.zh.md +64 -114
  88. package/docs/features.ja.md +29 -19
  89. package/docs/features.md +25 -15
  90. package/docs/features.zh-TW.md +28 -18
  91. package/docs/features.zh.md +31 -21
  92. package/docs/getting-started.ja.md +40 -43
  93. package/docs/getting-started.md +36 -39
  94. package/docs/getting-started.zh-TW.md +38 -41
  95. package/docs/getting-started.zh.md +45 -48
  96. package/docs/overview.ja.md +63 -11
  97. package/docs/overview.md +60 -8
  98. package/docs/overview.zh-TW.md +67 -15
  99. package/docs/overview.zh.md +62 -10
  100. package/media.md +9 -9
  101. package/package.json +1 -1
  102. package/prompts/detail/custom/custom-components.md +304 -188
  103. package/prompts/detail/document-rules.md +4 -4
  104. package/prompts/detail/generate-document.md +21 -8
  105. package/prompts/detail/update-document.md +8 -12
  106. package/prompts/structure/update-document-structure.md +12 -8
  107. package/prompts/utils/feedback-refiner.md +3 -3
  108. package/tests/agents/generate/document-structure-tools/move-document.test.mjs +9 -9
  109. package/tests/agents/generate/user-review-document-structure.test.mjs +29 -8
  110. package/tests/agents/update/document-tools/update-document-content.test.mjs +115 -112
  111. package/tests/agents/update/fs-tools/glob.test.mjs +438 -0
  112. package/tests/agents/update/fs-tools/grep.test.mjs +279 -0
  113. package/tests/agents/update/fs-tools/read-file.test.mjs +553 -0
  114. package/tests/agents/update/user-review-document.test.mjs +48 -27
  115. package/types/document-schema.mjs +5 -6
  116. package/types/document-structure-schema.mjs +20 -8
@@ -17,9 +17,9 @@ Your task is to analyze the original document content and user feedback, then us
17
17
  {% set operation_type = "optimizing" %}
18
18
  {% include "../common/document/user-preferences.md" %}
19
19
 
20
- <original_content>
20
+ <page_content>
21
21
  {{originalContent}}
22
- </original_content>
22
+ </page_content>
23
23
 
24
24
  <user_feedback>
25
25
  {{feedback}}
@@ -114,17 +114,17 @@ Processing workflow:
114
114
  - Analyze user feedback to understand the exact intent and scope of changes
115
115
  - Generate a unified diff patch that implements the requested improvements
116
116
  - Use the available tool to apply the changes and get the final content
117
+ - Tool calls only need to return toolCalls information
117
118
  - Ensure all modifications maintain document quality and consistency
118
- - Provide clear feedback about what changes were made
119
+ - Return 'success' when the latest version of content meets user feedback
119
120
 
120
121
  Tool usage guidelines:
121
122
 
122
123
  **updateDocumentContent**: Use this tool to apply changes to the document content
123
124
  - Generate a precise unified diff patch based on the user feedback
124
125
  - The diff should include context lines for accurate application
125
- - Only consider content within <original_content> tag when calculating line numbers, ensure line number calculation is accurate
126
+ - Only consider content within <page_content> tag when calculating line numbers, ensure line number calculation is accurate
126
127
  - Test the patch application to ensure it works correctly
127
- - Return the final updated content
128
128
 
129
129
  Error handling:
130
130
  - If user intent is unclear, ask for clarification
@@ -133,11 +133,7 @@ Error handling:
133
133
  </task_instructions>
134
134
 
135
135
  <output_format>
136
- Your response should:
137
-
138
- The final output should include:
139
- - `updatedContent`: The final updated markdown content after applying all modifications
140
- - `operationSummary`: A clear explanation of the modifications made based on the user feedback
141
-
142
- **Always use tool return results** - When all tool calls are complete, directly use the result from the updateDocumentContent tool as your final updatedContent.
136
+ ** Only output operation execution status **:
137
+ - Only return 'success' if operation executed successfully
138
+ - Return brief error message if operation failed
143
139
  </output_format>
@@ -13,10 +13,11 @@ Processing workflow:
13
13
  - Determine which tools to use based on the user's requirements
14
14
  - Execute the appropriate operations using available tools
15
15
  - Ensure all modifications maintain documentation structure integrity
16
+ - Return 'success' when the latest version of websiteStructure meets user feedback
16
17
 
17
18
  Rules:
18
- ** Never generate new documentation structures directly. All changes must be made using Tools. **
19
- ** Use the documentation structure returned by Tools as the latest version, check if it satisfies the user's feedback, and if so, return the latest version directly. **
19
+ ** All changes must be made using Tools. **
20
+ ** Carefully check if the latest version of documentStructure data meets user requirements, must avoid duplicate Tool calls. **
20
21
 
21
22
  Objectives:
22
23
  - Create a clear and logical structural plan that comprehensively presents information from the user-provided context while providing users with intuitive navigation paths.
@@ -83,12 +84,12 @@ Analyze the user feedback to determine the intended operation:
83
84
 
84
85
  Operation execution rules:
85
86
 
86
- - **Always analyze the user feedback first** to understand the exact intent
87
- - **Use only the appropriate tools** based on the determined operation type
88
- - **Validate all required parameters** before calling tools
89
- - **Maintain data integrity** by ensuring all constraints are met
90
- - **Only use Tools to update data** Use provided Tools to modify documentation structure, use the documentation structure returned by Tools as the latest version
91
- - **Use Tool return results** When all Tool calls are complete, directly use the result from the last Tool
87
+ - Always analyze the user feedback first to understand the exact intent
88
+ - Use only the appropriate tools based on the determined operation type
89
+ - Tool calls only need to return toolCalls information
90
+ - Validate all required parameters before calling tools
91
+ - Maintain data integrity by ensuring all constraints are met
92
+ - Only use Tools to update data Use provided Tools to modify documentation structure, use the documentation structure returned by Tools as the latest version
92
93
 
93
94
  Tool usage guidelines:
94
95
 
@@ -115,4 +116,7 @@ Error handling:
115
116
  - If required information is missing, request the needed details
116
117
  - If operation would break constraints, explain the issue and suggest alternatives
117
118
 
119
+ ** Only output operation execution status **:
120
+ - Only return 'success' if operation executed successfully
121
+ - Return brief error message if operation failed
118
122
  </output_constraints>
@@ -33,10 +33,10 @@ Save determination rules:
33
33
  **One-time operations (do not save)**:
34
34
  - Only corrects current version/typos/individual phrasing/local factual errors with no stable reusable value → `save=false`
35
35
  - Fixes that are highly specific to a single line or data point and unlikely to recur (e.g., "change the year from 2020 to 2021") → `save=false`
36
- - Documentation Structure adjustments, adding new documents, and moving document positions are always one-time operations → `save=false`
36
+ - Documentation Structure adjustments, adding new documents, update document, delete document, and moving document positions are always one-time operations → `save=false`
37
37
 
38
38
  **Reusable policies (save)**:
39
- - Writing styles, structural conventions, inclusion/exclusion items, translation conventions that are broadly applicable and should be consistently executed in the future → `save=true`
39
+ - Writing styles, structural conventions, translation conventions that are broadly applicable and should be consistently executed in the future → `save=true`
40
40
 
41
41
  **Duplication check (do not save)**:
42
42
  - If `existingPreferences` already contains **similar or covering** rules for current feedback intent, then `save=false`
@@ -71,7 +71,7 @@ Example 1 (Keyword Preservation):
71
71
  Example 2:
72
72
  - Input: stage=document_structure, paths=[], feedback="Add 'Next Steps' at the end of overview and tutorials with 2-3 links."
73
73
  - Output:
74
- {"rule":"Add 'Next Steps' section at the end of overview and tutorial documents with 2-3 links within the repository.","scope":"structure","save":true,"limitToInputPaths":false,"reason":"This feedback suggests a new structural convention (adding a 'Next Steps' section). This is a classic reusable policy that should be applied to future documents of a certain type. Therefore, `save` is `true` and the scope is `structure`."}
74
+ {"rule":"Add 'Next Steps' section at the end of overview and tutorial documents with 2-3 links within the repository.","scope":"structure","save":false,"limitToInputPaths":false,"reason":"This feedback is about adjusting document structure by adding a new section. According to save rules, documentation structure adjustments are always one-time operations, so `save` should be `false`. The scope remains `structure` as it affects document organization."}
75
75
 
76
76
  Example 3:
77
77
  - Input: stage=translation_refine, paths=[], feedback="Don't translate variable names and code."
@@ -158,7 +158,7 @@ describe("move-document", () => {
158
158
  expect(result.documentStructure).toEqual(baseDocumentStructure);
159
159
  expect(result.originalDocument).toBeUndefined();
160
160
  expect(result.updatedDocument).toBeUndefined();
161
- expect(consoleSpy).toHaveBeenCalledWith("Error: Cannot move document - path: Required");
161
+ expect(consoleSpy).toHaveBeenCalledWith("⚠️ Cannot move document: path: Required");
162
162
  });
163
163
 
164
164
  test("should return error when path is empty string", async () => {
@@ -169,7 +169,7 @@ describe("move-document", () => {
169
169
  });
170
170
 
171
171
  expect(result.documentStructure).toEqual(baseDocumentStructure);
172
- expect(consoleSpy).toHaveBeenCalledWith("Error: Cannot move document - path: Path is required");
172
+ expect(consoleSpy).toHaveBeenCalledWith("⚠️ Cannot move document: path: Path is required");
173
173
  });
174
174
 
175
175
  test("should return error when document does not exist", async () => {
@@ -181,7 +181,7 @@ describe("move-document", () => {
181
181
 
182
182
  expect(result.documentStructure).toEqual(baseDocumentStructure);
183
183
  expect(consoleSpy).toHaveBeenCalledWith(
184
- "Error: Cannot move document - Document '/nonexistent-document' does not exist. Please select an existing document to move.",
184
+ "⚠️ Cannot move document: Document '/nonexistent-document' does not exist. Please select an existing document to move.",
185
185
  );
186
186
  });
187
187
 
@@ -194,7 +194,7 @@ describe("move-document", () => {
194
194
 
195
195
  expect(result.documentStructure).toEqual(baseDocumentStructure);
196
196
  expect(consoleSpy).toHaveBeenCalledWith(
197
- "Error: Cannot move document - Target parent document '/nonexistent-parent' does not exist. Please select an existing parent document.",
197
+ "⚠️ Cannot move document: Target parent document '/nonexistent-parent' does not exist. Please select an existing parent document.",
198
198
  );
199
199
  });
200
200
 
@@ -208,7 +208,7 @@ describe("move-document", () => {
208
208
 
209
209
  expect(result.documentStructure).toEqual(baseDocumentStructure);
210
210
  expect(consoleSpy).toHaveBeenCalledWith(
211
- "Error: Cannot move document - Moving '/api' under '/api/auth' would create an invalid hierarchy. Please select a parent that is not nested under the document being moved.",
211
+ "⚠️ Cannot move document: Moving '/api' under '/api/auth' would create an invalid hierarchy. Please select a parent that is not nested under the document being moved.",
212
212
  );
213
213
  });
214
214
 
@@ -221,7 +221,7 @@ describe("move-document", () => {
221
221
 
222
222
  expect(result.documentStructure).toEqual(baseDocumentStructure);
223
223
  expect(consoleSpy).toHaveBeenCalledWith(
224
- "Error: Cannot move document - Moving '/api' under '/api/auth/oauth' would create an invalid hierarchy. Please select a parent that is not nested under the document being moved.",
224
+ "⚠️ Cannot move document: Moving '/api' under '/api/auth/oauth' would create an invalid hierarchy. Please select a parent that is not nested under the document being moved.",
225
225
  );
226
226
  });
227
227
 
@@ -278,7 +278,7 @@ describe("move-document", () => {
278
278
 
279
279
  expect(result.documentStructure).toEqual(complexStructure);
280
280
  expect(consoleSpy).toHaveBeenCalledWith(
281
- "Error: Cannot move document - Moving '/api' under '/api/auth/oauth/scopes' would create an invalid hierarchy. Please select a parent that is not nested under the document being moved.",
281
+ "⚠️ Cannot move document: Moving '/api' under '/api/auth/oauth/scopes' would create an invalid hierarchy. Please select a parent that is not nested under the document being moved.",
282
282
  );
283
283
  });
284
284
 
@@ -335,7 +335,7 @@ describe("move-document", () => {
335
335
 
336
336
  expect(result.documentStructure).toEqual([]);
337
337
  expect(consoleSpy).toHaveBeenCalledWith(
338
- "Error: Cannot move document - Document '/any-path' does not exist. Please select an existing document to move.",
338
+ "⚠️ Cannot move document: Document '/any-path' does not exist. Please select an existing document to move.",
339
339
  );
340
340
  });
341
341
 
@@ -358,7 +358,7 @@ describe("move-document", () => {
358
358
 
359
359
  expect(result.documentStructure).toEqual(singleDocStructure);
360
360
  expect(consoleSpy).toHaveBeenCalledWith(
361
- "Error: Cannot move document - Target parent document '/nonexistent' does not exist. Please select an existing parent document.",
361
+ "⚠️ Cannot move document: Target parent document '/nonexistent' does not exist. Please select an existing parent document.",
362
362
  );
363
363
  });
364
364
 
@@ -49,6 +49,9 @@ describe("user-review-document-structure", () => {
49
49
  invoke: mock(async () => ({
50
50
  documentStructure: documentStructure,
51
51
  })),
52
+ userContext: {
53
+ currentStructure: [],
54
+ },
52
55
  },
53
56
  };
54
57
 
@@ -132,9 +135,13 @@ describe("user-review-document-structure", () => {
132
135
  .mockImplementationOnce(async () => feedback)
133
136
  .mockImplementationOnce(async () => ""); // Exit loop on second call
134
137
 
135
- mockOptions.context.invoke.mockImplementation(async () => ({
136
- documentStructure: refinedStructure,
137
- }));
138
+ mockOptions.context.invoke.mockImplementation(async () => {
139
+ // Simulate the agent updating the shared context
140
+ mockOptions.context.userContext.currentStructure = refinedStructure;
141
+ return {
142
+ documentStructure: refinedStructure,
143
+ };
144
+ });
138
145
 
139
146
  const result = await userReviewDocumentStructure({ documentStructure }, mockOptions);
140
147
 
@@ -242,11 +249,25 @@ describe("user-review-document-structure", () => {
242
249
  .mockImplementationOnce(async () => secondFeedback)
243
250
  .mockImplementationOnce(async () => ""); // Exit loop
244
251
 
245
- mockOptions.context.invoke
246
- .mockImplementationOnce(async () => ({ documentStructure: firstRefinedStructure })) // refineDocumentStructure 1st call
247
- .mockImplementationOnce(async () => ({})) // checkFeedbackRefiner 1st call
248
- .mockImplementationOnce(async () => ({ documentStructure: finalRefinedStructure })) // refineDocumentStructure 2nd call
249
- .mockImplementationOnce(async () => ({})); // checkFeedbackRefiner 2nd call
252
+ let invokeCount = 0;
253
+ mockOptions.context.invoke.mockImplementation(async () => {
254
+ invokeCount++;
255
+ if (invokeCount === 1) {
256
+ // refineDocumentStructure 1st call
257
+ mockOptions.context.userContext.currentStructure = firstRefinedStructure;
258
+ return { documentStructure: firstRefinedStructure };
259
+ } else if (invokeCount === 2) {
260
+ // checkFeedbackRefiner 1st call
261
+ return {};
262
+ } else if (invokeCount === 3) {
263
+ // refineDocumentStructure 2nd call
264
+ mockOptions.context.userContext.currentStructure = finalRefinedStructure;
265
+ return { documentStructure: finalRefinedStructure };
266
+ } else {
267
+ // checkFeedbackRefiner 2nd call
268
+ return {};
269
+ }
270
+ });
250
271
 
251
272
  const result = await userReviewDocumentStructure({ documentStructure }, mockOptions);
252
273