@aigne/doc-smith 0.8.11-beta.6 → 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 (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 +13 -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
@@ -1,3 +1,3 @@
1
1
  {
2
- ".": "0.8.11-beta.6"
2
+ ".": "0.8.11-beta.7"
3
3
  }
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
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
+
3
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)
4
17
 
5
18
 
package/README.md CHANGED
@@ -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
 
@@ -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
@@ -44,8 +59,18 @@ export default async function addDocument(input) {
44
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
  }
@@ -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,17 +39,29 @@ 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
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
  }
@@ -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
 
@@ -69,10 +84,21 @@ export default async function moveDocument(input) {
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
 
@@ -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];
@@ -37,10 +48,26 @@ export default async function updateDocument(input) {
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
 
@@ -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 documentation structure
31
+ output_key: message
38
32
  skills:
39
33
  - ./document-structure-tools/add-document.mjs
40
34
  - ./document-structure-tools/delete-document.mjs
@@ -97,6 +97,9 @@ export default async function userReviewDocumentStructure({ documentStructure, .
97
97
 
98
98
  const MAX_ITERATIONS = 100;
99
99
  let iterationCount = 0;
100
+
101
+ // share current structure with updateDocumentStructure agent
102
+ options.context.userContext.currentStructure = currentStructure;
100
103
  while (iterationCount < MAX_ITERATIONS) {
101
104
  iterationCount++;
102
105
 
@@ -132,16 +135,14 @@ export default async function userReviewDocumentStructure({ documentStructure, .
132
135
 
133
136
  try {
134
137
  // Call refineDocumentStructure agent with feedback
135
- const result = await options.context.invoke(refineAgent, {
138
+ await options.context.invoke(refineAgent, {
136
139
  ...rest,
137
140
  feedback: feedback.trim(),
138
141
  documentStructure: currentStructure,
139
142
  userPreferences,
140
143
  });
141
144
 
142
- if (result.documentStructure) {
143
- currentStructure = result.documentStructure;
144
- }
145
+ currentStructure = options.context.userContext.currentStructure;
145
146
 
146
147
  // Check if feedback should be saved as user preference
147
148
  const feedbackRefinerAgent = options.context.agents["checkFeedbackRefiner"];
@@ -21,12 +21,4 @@ input_schema:
21
21
  required:
22
22
  - language
23
23
  - content
24
- output_schema:
25
- type: object
26
- properties:
27
- translation:
28
- type: string
29
- description: Translated text
30
- language:
31
- type: string
32
- description: Language code of the translation
24
+ output_key: translation
@@ -10,7 +10,8 @@ export default async function checkUpdateIsSingle({ selectedDocs, ...rest }, opt
10
10
  let targetAgent;
11
11
  let agentName;
12
12
 
13
- if (selectedDocs.length === 1) {
13
+ if (selectedDocs.length === 1 && !rest.reset) {
14
+ // Single doc update without reset
14
15
  agentName = "updateSingleDocument";
15
16
  targetAgent = options.context.agents["updateSingleDocument"];
16
17
  } else {
@@ -5,18 +5,24 @@ import {
5
5
  validateUpdateDocumentContentInput,
6
6
  } from "../../../types/document-schema.mjs";
7
7
 
8
- export default async function updateDocumentContent(input) {
8
+ export default async function updateDocumentContent(input, options) {
9
+ // Get originalContent from shared context, fallback to input
10
+ let originalContent = options?.context?.userContext?.currentContent;
11
+
12
+ if (!originalContent) {
13
+ originalContent = input.originalContent;
14
+ }
15
+
9
16
  // Validate input using Zod schema
10
17
  const validation = validateUpdateDocumentContentInput(input);
11
18
  if (!validation.success) {
12
19
  return {
13
20
  success: false,
14
- error: validation.error,
15
- message: "Invalid input parameters",
21
+ error: { message: validation.error },
16
22
  };
17
23
  }
18
24
 
19
- const { originalContent, diffPatch } = validation.data;
25
+ const { diffPatch } = validation.data;
20
26
 
21
27
  try {
22
28
  // Parse and validate diff patch
@@ -24,8 +30,7 @@ export default async function updateDocumentContent(input) {
24
30
  if (!parsedDiff.success) {
25
31
  return {
26
32
  success: false,
27
- error: parsedDiff.error,
28
- message: "Invalid diff format: No valid hunks found or parsing failed",
33
+ error: { message: parsedDiff.error },
29
34
  };
30
35
  }
31
36
 
@@ -34,8 +39,7 @@ export default async function updateDocumentContent(input) {
34
39
  if (!fixedDiff.success) {
35
40
  return {
36
41
  success: false,
37
- error: fixedDiff.error,
38
- message: "Cannot fix diff line number issues",
42
+ error: { message: fixedDiff.error },
39
43
  };
40
44
  }
41
45
 
@@ -48,21 +52,27 @@ export default async function updateDocumentContent(input) {
48
52
  if (result === false) {
49
53
  return {
50
54
  success: false,
51
- error: "Failed to apply patch",
52
- message: "Diff patch could not be applied",
55
+ error: { message: "Failed to apply patch" },
53
56
  };
54
57
  }
55
58
 
59
+ // Update shared context with new content if options is provided
60
+ if (options?.context?.userContext) {
61
+ options.context.userContext.currentContent = result;
62
+ }
63
+
56
64
  return {
57
65
  success: true,
58
- updatedContent: result,
59
- message: "Document content updated successfully",
66
+ updatedContent: `<page_content>
67
+ ${result}
68
+ </page_content>`,
69
+ message:
70
+ "Document content updated successfully.\nCheck if updatedContent meets user feedback, if so, just return 'success'.",
60
71
  };
61
72
  } catch (error) {
62
73
  return {
63
74
  success: false,
64
- error: error.message,
65
- message: "Failed to update document content",
75
+ error: { message: error.message },
66
76
  };
67
77
  }
68
78
  }