@aigne/doc-smith 0.8.15-beta.9 → 0.8.16-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.
Files changed (72) hide show
  1. package/CHANGELOG.md +78 -0
  2. package/agents/chat/chat-system.md +32 -0
  3. package/agents/chat/index.yaml +14 -22
  4. package/agents/chat/skills/generate-document.yaml +15 -0
  5. package/agents/chat/skills/update-document.yaml +24 -0
  6. package/agents/evaluate/document-structure.yaml +3 -1
  7. package/agents/evaluate/document.yaml +3 -1
  8. package/agents/generate/check-need-generate-structure.mjs +4 -0
  9. package/agents/generate/document-structure-tools/add-document.mjs +5 -1
  10. package/agents/generate/document-structure-tools/update-document.mjs +7 -0
  11. package/agents/generate/generate-structure.yaml +1 -5
  12. package/agents/generate/merge-diagram.yaml +4 -4
  13. package/agents/generate/update-document-structure.yaml +51 -45
  14. package/agents/generate/user-review-document-structure.mjs +47 -55
  15. package/agents/generate/utils/merge-document-structures.mjs +4 -4
  16. package/agents/init/check.mjs +1 -1
  17. package/agents/init/index.mjs +52 -2
  18. package/agents/init/validate.mjs +16 -0
  19. package/agents/publish/publish-docs.mjs +16 -10
  20. package/agents/schema/document-execution-structure.yaml +1 -1
  21. package/agents/schema/document-structure-item.yaml +1 -1
  22. package/agents/schema/document-structure.yaml +4 -2
  23. package/agents/update/check-generate-diagram.mjs +74 -16
  24. package/agents/update/generate-document.yaml +1 -13
  25. package/agents/update/handle-document-update.yaml +1 -1
  26. package/agents/update/pre-check-generate-diagram.yaml +44 -0
  27. package/agents/update/update-document-detail.yaml +64 -58
  28. package/agents/update/update-single-document.yaml +1 -1
  29. package/agents/update/user-review-document.mjs +58 -43
  30. package/agents/utils/analyze-feedback-intent.yaml +29 -0
  31. package/agents/utils/choose-docs.mjs +16 -6
  32. package/agents/utils/document-title-streamline.yaml +48 -0
  33. package/agents/utils/find-item-by-path.mjs +4 -2
  34. package/agents/utils/list-docs.mjs +15 -0
  35. package/agents/utils/load-sources.mjs +4 -4
  36. package/agents/utils/map-reasoning-effort-level.mjs +15 -0
  37. package/agents/utils/save-sidebar.mjs +12 -33
  38. package/agents/utils/streamline-document-titles-if-needed.mjs +88 -0
  39. package/agents/utils/{transform-detail-datasources.mjs → transform-detail-data-sources.mjs} +2 -2
  40. package/aigne.yaml +12 -4
  41. package/package.json +11 -9
  42. package/prompts/common/document/content-rules-core.md +5 -5
  43. package/prompts/common/document-structure/conflict-resolution-guidance.md +2 -2
  44. package/prompts/common/document-structure/document-structure-rules.md +8 -8
  45. package/prompts/common/document-structure/document-title-streamline.md +86 -0
  46. package/prompts/common/document-structure/output-constraints.md +3 -3
  47. package/prompts/detail/custom/custom-code-block.md +36 -1
  48. package/prompts/detail/custom/{custom-components.md → custom-components-usage-rules.md} +29 -7
  49. package/prompts/detail/d2-diagram/pre-check.md +23 -0
  50. package/prompts/detail/d2-diagram/rules.md +42 -24
  51. package/prompts/detail/d2-diagram/user-prompt.md +0 -20
  52. package/prompts/detail/generate/document-rules.md +2 -2
  53. package/prompts/detail/generate/system-prompt.md +3 -3
  54. package/prompts/detail/generate/user-prompt.md +5 -5
  55. package/prompts/detail/update/system-prompt.md +4 -3
  56. package/prompts/detail/update/user-prompt.md +8 -4
  57. package/prompts/evaluate/document.md +0 -4
  58. package/prompts/structure/check-document-structure.md +4 -4
  59. package/prompts/structure/generate/system-prompt.md +0 -1
  60. package/prompts/structure/generate/user-prompt.md +14 -9
  61. package/prompts/structure/review/structure-review-system.md +5 -2
  62. package/prompts/structure/update/system-prompt.md +0 -13
  63. package/prompts/structure/update/user-prompt.md +6 -5
  64. package/prompts/translate/translate-document.md +3 -3
  65. package/prompts/utils/analyze-feedback-intent.md +55 -0
  66. package/utils/constants/index.mjs +38 -0
  67. package/utils/deploy.mjs +3 -1
  68. package/utils/docs-finder-utils.mjs +37 -3
  69. package/utils/file-utils.mjs +97 -0
  70. package/utils/load-config.mjs +19 -0
  71. package/agents/utils/docs-fs-actor.yaml +0 -27
  72. package/agents/utils/fs.mjs +0 -60
package/CHANGELOG.md CHANGED
@@ -1,5 +1,83 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.8.16-beta](https://github.com/AIGNE-io/aigne-doc-smith/compare/v0.8.15...v0.8.16-beta) (2025-11-10)
4
+
5
+
6
+ ### Features
7
+
8
+ * enable AFS for chat agent & improve chat skills ([#281](https://github.com/AIGNE-io/aigne-doc-smith/issues/281)) ([b1c770e](https://github.com/AIGNE-io/aigne-doc-smith/commit/b1c770e60c8866dd08d41ebdd52817c14dd3dd41))
9
+ * implement document title streamlining functionality ([#276](https://github.com/AIGNE-io/aigne-doc-smith/issues/276)) ([918edb8](https://github.com/AIGNE-io/aigne-doc-smith/commit/918edb8f1b2dc03572c4125971092ef0023cd7b3))
10
+
11
+
12
+ ### Bug Fixes
13
+
14
+ * update chat model from aignehub/gemini-2.5-pro to google/gemini-2.5-pro ([#283](https://github.com/AIGNE-io/aigne-doc-smith/issues/283)) ([3559a56](https://github.com/AIGNE-io/aigne-doc-smith/commit/3559a56e49ca3105fd800110b67b3cb3346e3096))
15
+
16
+ ## [0.8.15](https://github.com/AIGNE-io/aigne-doc-smith/compare/v0.8.15-beta.16...v0.8.15) (2025-11-07)
17
+
18
+ ## [0.8.15-beta.16](https://github.com/AIGNE-io/aigne-doc-smith/compare/v0.8.15-beta.15...v0.8.15-beta.16) (2025-11-07)
19
+
20
+
21
+ ### Features
22
+
23
+ * support customize diagramming quantity ([#277](https://github.com/AIGNE-io/aigne-doc-smith/issues/277)) ([9d9fa6a](https://github.com/AIGNE-io/aigne-doc-smith/commit/9d9fa6a1f344c93df187f2dc502c5479e304e0f4))
24
+
25
+ ## [0.8.15-beta.15](https://github.com/AIGNE-io/aigne-doc-smith/compare/v0.8.15-beta.14...v0.8.15-beta.15) (2025-11-07)
26
+
27
+
28
+ ### Bug Fixes
29
+
30
+ * add two-tier thinking effort configuration system ([#273](https://github.com/AIGNE-io/aigne-doc-smith/issues/273)) ([b72d066](https://github.com/AIGNE-io/aigne-doc-smith/commit/b72d066698bae253a9ee2dfa231bf73cd59d7529))
31
+
32
+ ## [0.8.15-beta.14](https://github.com/AIGNE-io/aigne-doc-smith/compare/v0.8.15-beta.13...v0.8.15-beta.14) (2025-11-06)
33
+
34
+
35
+ ### Features
36
+
37
+ * add reasoning effort configuration for customizable AI model settings ([#270](https://github.com/AIGNE-io/aigne-doc-smith/issues/270)) ([9f15638](https://github.com/AIGNE-io/aigne-doc-smith/commit/9f156387120e8705bf16cf611d7f8f39995c36b3))
38
+ * **cli:** enhance auth with short link responses and detailed error reporting for publishing ([#269](https://github.com/AIGNE-io/aigne-doc-smith/issues/269)) ([31cc252](https://github.com/AIGNE-io/aigne-doc-smith/commit/31cc25236667236dfe91543acdd7e8cccff659c5))
39
+
40
+
41
+ ### Bug Fixes
42
+
43
+ * use default reasoning effort for existing config ([#272](https://github.com/AIGNE-io/aigne-doc-smith/issues/272)) ([2fc9c89](https://github.com/AIGNE-io/aigne-doc-smith/commit/2fc9c89e383c1c5446f2109a2846e831d1e1e871))
44
+
45
+ ## [0.8.15-beta.13](https://github.com/AIGNE-io/aigne-doc-smith/compare/v0.8.15-beta.12...v0.8.15-beta.13) (2025-11-05)
46
+
47
+
48
+ ### Bug Fixes
49
+
50
+ * make paid deployment more smooth stable ([#266](https://github.com/AIGNE-io/aigne-doc-smith/issues/266)) ([ce8c00a](https://github.com/AIGNE-io/aigne-doc-smith/commit/ce8c00ab3eb045c482e07dc3c4e3bd149e754a06))
51
+ * validate docsDir on init and ensure latest doc on view after publish ([#267](https://github.com/AIGNE-io/aigne-doc-smith/issues/267)) ([e45864d](https://github.com/AIGNE-io/aigne-doc-smith/commit/e45864da4a7fb5b09af2bbffdb7ca93abd74397c))
52
+
53
+ ## [0.8.15-beta.12](https://github.com/AIGNE-io/aigne-doc-smith/compare/v0.8.15-beta.11...v0.8.15-beta.12) (2025-11-05)
54
+
55
+
56
+ ### Features
57
+
58
+ * tune token consumption for update ops with intent analysis ([#264](https://github.com/AIGNE-io/aigne-doc-smith/issues/264)) ([8c53d28](https://github.com/AIGNE-io/aigne-doc-smith/commit/8c53d288346ae622e8841866db1b6fbed9d5023d))
59
+
60
+ ## [0.8.15-beta.11](https://github.com/AIGNE-io/aigne-doc-smith/compare/v0.8.15-beta.10...v0.8.15-beta.11) (2025-11-04)
61
+
62
+
63
+ ### Features
64
+
65
+ * warn on invalid sources and tuning translate messages ([#241](https://github.com/AIGNE-io/aigne-doc-smith/issues/241)) ([bd786ca](https://github.com/AIGNE-io/aigne-doc-smith/commit/bd786cad8b0c6fa837511fdc2982c83b7f0095dd))
66
+
67
+
68
+ ### Bug Fixes
69
+
70
+ * avoid useless diagram generate ([#245](https://github.com/AIGNE-io/aigne-doc-smith/issues/245)) ([de7600f](https://github.com/AIGNE-io/aigne-doc-smith/commit/de7600fb5839be9d1f0743adc34fd08c4c11729d))
71
+ * iterate on chunk of datasource to generate structure ([#242](https://github.com/AIGNE-io/aigne-doc-smith/issues/242)) ([0b4db2a](https://github.com/AIGNE-io/aigne-doc-smith/commit/0b4db2a8cac77d6f4a1c197374b9dadbe078346b))
72
+
73
+ ## [0.8.15-beta.10](https://github.com/AIGNE-io/aigne-doc-smith/compare/v0.8.15-beta.9...v0.8.15-beta.10) (2025-11-03)
74
+
75
+
76
+ ### Bug Fixes
77
+
78
+ * remove empty xml tag in prompt ([#239](https://github.com/AIGNE-io/aigne-doc-smith/issues/239)) ([1ec771e](https://github.com/AIGNE-io/aigne-doc-smith/commit/1ec771eb8855bca3730f732a1b68404275633787))
79
+ * standardized variable names and xml tag usage ([#237](https://github.com/AIGNE-io/aigne-doc-smith/pull/237))([00f18b9](https://github.com/AIGNE-io/aigne-doc-smith/commit/00f18b95ba21cd376e369eefb102d2d258e95529))
80
+
3
81
  ## [0.8.15-beta.9](https://github.com/AIGNE-io/aigne-doc-smith/compare/v0.8.15-beta.8...v0.8.15-beta.9) (2025-11-03)
4
82
 
5
83
 
@@ -0,0 +1,32 @@
1
+ You are a professional document generation assistant that helps users create, modify, and manage documentation through interactive chat. Your primary role is to understand user requirements and intelligently call upon various specialized skills to complete documentation tasks efficiently.
2
+
3
+ Core Capabilities:
4
+ - Generate comprehensive documentation from user inputs and specifications
5
+ - Regenerate and refine document details based on feedback
6
+ - Translate and localize documentation content
7
+ - Publish and manage team documentation workflows
8
+ - Provide interactive guidance throughout the document creation process
9
+
10
+ Interaction Guidelines:
11
+ - Engage users in a professional yet friendly manner
12
+ - Ask clarifying questions to understand specific documentation needs
13
+ - Suggest appropriate skills and workflows based on user requests
14
+ - Provide clear explanations of available capabilities and processes
15
+ - Maintain context throughout multi-step documentation tasks
16
+ - Offer proactive suggestions for improving document quality and structure
17
+
18
+ <skill_usage>
19
+ - afs_xxx skills: AFS(AIGNE File System) skills provide capabilities to explore, read, write and manage files and virtual modules within the AIGNE environment.
20
+ You can use these skills to access source files and other resources needed for documentation tasks.
21
+ - listDocs: This skill lists all available documentation files in the system.
22
+ You can use this skill to get an overview of existing documents before creating or modifying documentation. for documentation tasks,
23
+ you should use this skill rather than afs_read to list documentation files.
24
+ - generateDocument: This skill generates new documentation or updates existing documents structure based on user inputs and specifications,
25
+ You can use this skill to create comprehensive documents from scratch or based on existing templates or update document structure as per user requirements.
26
+ - updateDocument: This skill updates existing documentation content with new information or revisions provided by the user.
27
+ You can use this skill to refine and enhance documents content based on feedback or additional details.
28
+ - publish: This skill publishes completed documentation to an online website to make it accessible to the intended audience.
29
+ You can use this skill to manage the publication process and ensure documents are properly formatted and available.
30
+ - translate: This skill translates documentation content into different languages for localization purposes.
31
+ You can use this skill to adapt documents for diverse audiences by providing translations in the required languages.
32
+ </skill_usage>
@@ -1,30 +1,22 @@
1
1
  type: ai
2
2
  name: chat
3
3
  description: Start interactive document generation assistant
4
- instructions: |
5
- You are a professional document generation assistant that helps users create, modify, and manage documentation through interactive chat. Your primary role is to understand user requirements and intelligently call upon various specialized skills to complete documentation tasks efficiently.
6
-
7
- Core Capabilities:
8
- - Generate comprehensive documentation from user inputs and specifications
9
- - Regenerate and refine document details based on feedback
10
- - Translate and localize documentation content
11
- - Publish and manage team documentation workflows
12
- - Provide interactive guidance throughout the document creation process
13
-
14
- Interaction Guidelines:
15
- - Engage users in a professional yet friendly manner
16
- - Ask clarifying questions to understand specific documentation needs
17
- - Suggest appropriate skills and workflows based on user requests
18
- - Provide clear explanations of available capabilities and processes
19
- - Maintain context throughout multi-step documentation tasks
20
- - Offer proactive suggestions for improving document quality and structure
4
+ instructions:
5
+ url: ./chat-system.md
21
6
  input_key: message
22
- memory: true
7
+ afs:
8
+ modules:
9
+ - module: system-fs
10
+ options:
11
+ path: .
12
+ mount: /source
13
+ description: Project root directory for document generation
14
+ afs_config:
15
+ inject_History: true
23
16
  skills:
24
- - ../init/index.mjs
25
- - ../generate/index.yaml
26
- - ../update/index.yaml
17
+ - ./skills/generate-document.yaml
18
+ - ./skills/update-document.yaml
27
19
  - ../publish/index.yaml
28
20
  - ../translate/index.yaml
29
- - ../utils/docs-fs-actor.yaml
30
21
  - ../utils/exit.mjs
22
+ - ../utils/list-docs.mjs
@@ -0,0 +1,15 @@
1
+ type: team
2
+ name: generateDocument
3
+ description: Generate complete documentation for your project, or update/delete existing documents or structure based on user feedback
4
+ input_schema:
5
+ type: object
6
+ properties:
7
+ feedback:
8
+ type: string
9
+ description: How to generate or update the document content
10
+ required:
11
+ - feedback
12
+ skills:
13
+ - url: ../../generate/index.yaml
14
+ default_input:
15
+ isChat: true
@@ -0,0 +1,24 @@
1
+ type: team
2
+ name: updateDocument
3
+ description: Update a existing document based on user feedback
4
+ input_schema:
5
+ type: object
6
+ properties:
7
+ docs:
8
+ type: array
9
+ items:
10
+ type: string
11
+ description: Documents to update, must from listDocs output
12
+ feedback:
13
+ type: string
14
+ description: Tell us what to change in this content
15
+ reset:
16
+ type: boolean
17
+ description: Regenerate the document from scratch, ignoring previous versions
18
+ required:
19
+ - docs
20
+ - feedback
21
+ skills:
22
+ - url: ../../update/index.yaml
23
+ default_input:
24
+ isChat: true
@@ -2,7 +2,9 @@ name: evaluateDocumentStructure
2
2
  description: Evaluates the results generated by the document-structure agent to ensure they meet expectations, especially in scenarios with previous generation results and user feedback.
3
3
  instructions:
4
4
  url: ../../prompts/evaluate/document-structure.md
5
- model: openai/gpt-5
5
+ model:
6
+ model: openai/gpt-5
7
+ temperature: 1
6
8
  # model: anthropic/claude-opus-4-0
7
9
  task_render_mode: collapse
8
10
  task_title: Evaluate the structure of the documentation
@@ -2,7 +2,9 @@ name: evaluateDocument
2
2
  description: Evaluates the quality of generated document content, ensuring compliance with user-configured goals, audiences, and knowledge level requirements.
3
3
  instructions:
4
4
  url: ../../prompts/evaluate/document.md
5
- model: openai/gpt-5
5
+ model:
6
+ model: openai/gpt-5
7
+ temperature: 1
6
8
  # model: anthropic/claude-opus-4-0
7
9
  task_render_mode: collapse
8
10
  task_title: Evaluate document for '{{ title }}'
@@ -1,6 +1,7 @@
1
1
  import chalk from "chalk";
2
2
  import { getActiveRulesForScope } from "../../utils/preferences-utils.mjs";
3
3
  import { getProjectInfo, loadConfigFromFile, saveValueToConfig } from "../../utils/utils.mjs";
4
+ import streamlineDocumentTitlesIfNeeded from "../utils/streamline-document-titles-if-needed.mjs";
4
5
 
5
6
  export default async function checkNeedGenerateStructure(
6
7
  { originalDocumentStructure, forceRegenerate, ...rest },
@@ -70,6 +71,9 @@ export default async function checkNeedGenerateStructure(
70
71
  feedback: finalFeedback || "",
71
72
  });
72
73
 
74
+ await streamlineDocumentTitlesIfNeeded({ documentStructure: result.documentStructure }, options);
75
+ options.context.userContext.streamlinedDocumentTitles = true;
76
+
73
77
  let message = "";
74
78
 
75
79
  // Check and save project information
@@ -3,6 +3,7 @@ import {
3
3
  getAddDocumentOutputJsonSchema,
4
4
  validateAddDocumentInput,
5
5
  } from "../../../types/document-structure-schema.mjs";
6
+ import streamlineDocumentTitlesIfNeeded from "../../utils/streamline-document-titles-if-needed.mjs";
6
7
 
7
8
  export default async function addDocument(input, options) {
8
9
  // Validate input using Zod schema
@@ -56,7 +57,10 @@ export default async function addDocument(input, options) {
56
57
  sourceIds: [...sourceIds], // Create a copy of the array
57
58
  };
58
59
 
59
- // Add the document to the structure
60
+ // Streamline document titles if needed (will streamline the new document if title > 18 characters)
61
+ await streamlineDocumentTitlesIfNeeded({ documentStructure: [newDocument] }, options);
62
+
63
+ // Add the document to the structure first
60
64
  const updatedStructure = [...documentStructure, newDocument];
61
65
 
62
66
  const successMessage = `addDocument executed successfully.
@@ -3,6 +3,7 @@ import {
3
3
  getUpdateDocumentOutputJsonSchema,
4
4
  validateUpdateDocumentInput,
5
5
  } from "../../../types/document-structure-schema.mjs";
6
+ import streamlineDocumentTitlesIfNeeded from "../../utils/streamline-document-titles-if-needed.mjs";
6
7
 
7
8
  export default async function updateDocument(input, options) {
8
9
  // Validate input using Zod schema
@@ -44,6 +45,12 @@ export default async function updateDocument(input, options) {
44
45
  ...(sourceIds !== undefined && { sourceIds: [...sourceIds] }), // Create a copy of the array
45
46
  };
46
47
 
48
+ if (!options.context.userContext.streamlinedDocumentTitles) {
49
+ // Streamline document titles if needed (will streamline the updated document if title > 18 characters)
50
+ await streamlineDocumentTitlesIfNeeded({ documentStructure: [updatedDocument] }, options);
51
+ options.context.userContext.streamlinedDocumentTitles = true;
52
+ }
53
+
47
54
  // Update the document in the structure
48
55
  const updatedStructure = [...documentStructure];
49
56
  updatedStructure[documentIndex] = updatedDocument;
@@ -4,11 +4,9 @@ description: Generate the structure and organization of your documentation
4
4
  skills:
5
5
  - type: team
6
6
  name: generateStructureWorker
7
- iterate_on: datasources
7
+ iterate_on: dataSources
8
8
  skills:
9
9
  - type: ai
10
- model:
11
- reasoning_effort: 500
12
10
  instructions:
13
11
  - role: system
14
12
  url: ../../prompts/structure/generate/system-prompt.md
@@ -82,8 +80,6 @@ skills:
82
80
 
83
81
  - type: ai
84
82
  name: refineStructure
85
- model:
86
- reasoning_effort: 500
87
83
  instructions:
88
84
  - role: system
89
85
  url: ../../prompts/structure/review/structure-review-system.md
@@ -3,13 +3,13 @@ description: Merge Diagram source code into document
3
3
  instructions: |
4
4
  You are an AI assistant that helps to merge d2 diagram into document.
5
5
 
6
- <detail_dataSource>
6
+ <detail_data_source>
7
7
  {{ content }}
8
- </detail_dataSource>
8
+ </detail_data_source>
9
9
 
10
- <diagramSourceCode>
10
+ <diagram_source_code>
11
11
  {{ diagramSourceCode }}
12
- </diagramSourceCode>
12
+ </diagram_source_code>
13
13
 
14
14
  Given the source content of a document and the D2 diagram source code, your task is to:
15
15
  - **Keep the original content as soon as possible.**
@@ -1,48 +1,54 @@
1
- type: ai
1
+ type: team
2
2
  name: updateDocumentStructure
3
3
  description: Update documentation structure based on user feedback and intentions using structure modification tools
4
- instructions:
5
- - role: system
6
- url: ../../prompts/structure/update/system-prompt.md
7
- - role: user
8
- url: ../../prompts/structure/update/user-prompt.md
9
- input_schema:
10
- type: object
11
- properties:
12
- documentStructure: ../schema/document-structure.yaml
13
- rules:
14
- type: string
15
- description: User configuration rules
16
- locale:
17
- type: string
18
- description: User language, e.g. zh, en
19
- dataSourceChunk:
20
- type: string
21
- description: Context for documentation structure
22
- glossary:
23
- type: string
24
- description: Glossary of terms
25
- feedback:
26
- type: string
27
- description: User feedback for structure modifications
28
- userPreferences:
29
- type: string
30
- description: Your saved preferences for structure and documentation style
31
- required:
32
- - documentStructure
33
- - feedback
34
- output_key: message
35
- afs:
36
- modules:
37
- - module: system-fs
38
- options:
39
- mount: /sources
40
- path: .
41
- description: |
42
- Codebase of the project to be documented used as context for document generation,
43
- should search and read as needed while generating document content
44
4
  skills:
45
- - ./document-structure-tools/add-document.mjs
46
- - ./document-structure-tools/delete-document.mjs
47
- - ./document-structure-tools/update-document.mjs
48
- - ./document-structure-tools/move-document.mjs
5
+ - url: ../utils/analyze-feedback-intent.yaml
6
+ - type: ai
7
+ instructions:
8
+ - role: system
9
+ url: ../../prompts/structure/update/system-prompt.md
10
+ - role: user
11
+ url: ../../prompts/structure/update/user-prompt.md
12
+ input_schema:
13
+ type: object
14
+ properties:
15
+ documentStructure: ../schema/document-structure.yaml
16
+ rules:
17
+ type: string
18
+ description: User configuration rules
19
+ locale:
20
+ type: string
21
+ description: User language, e.g. zh, en
22
+ dataSourceChunk:
23
+ type: string
24
+ description: Context for documentation structure
25
+ glossary:
26
+ type: string
27
+ description: Glossary of terms
28
+ feedback:
29
+ type: string
30
+ description: User feedback for structure modifications
31
+ userPreferences:
32
+ type: string
33
+ description: Your saved preferences for structure and documentation style
34
+ needDataSources:
35
+ type: boolean
36
+ description: Whether data sources are needed for content modifications
37
+ required:
38
+ - documentStructure
39
+ - feedback
40
+ output_key: message
41
+ afs:
42
+ modules:
43
+ - module: system-fs
44
+ options:
45
+ mount: /sources
46
+ path: .
47
+ description: |
48
+ Codebase of the project to be documented used as context for document generation,
49
+ should search and read as needed while generating document content
50
+ skills:
51
+ - ./document-structure-tools/add-document.mjs
52
+ - ./document-structure-tools/delete-document.mjs
53
+ - ./document-structure-tools/update-document.mjs
54
+ - ./document-structure-tools/move-document.mjs
@@ -1,32 +1,10 @@
1
1
  import { getActiveRulesForScope } from "../../utils/preferences-utils.mjs";
2
2
  import { recordUpdate } from "../../utils/history-utils.mjs";
3
+ import { buildDocumentTree } from "../../utils/docs-finder-utils.mjs";
4
+ import equal from "fast-deep-equal";
3
5
 
4
6
  function formatDocumentStructure(structure) {
5
- // Create a map of nodes for easy lookup
6
- const nodeMap = new Map();
7
- const rootNodes = [];
8
-
9
- // First pass: create node map
10
- structure.forEach((node) => {
11
- nodeMap.set(node.path, {
12
- ...node,
13
- children: [],
14
- });
15
- });
16
-
17
- // Build the tree structure
18
- structure.forEach((node) => {
19
- if (node.parentId) {
20
- const parent = nodeMap.get(node.parentId);
21
- if (parent) {
22
- parent.children.push(nodeMap.get(node.path));
23
- } else {
24
- rootNodes.push(nodeMap.get(node.path));
25
- }
26
- } else {
27
- rootNodes.push(nodeMap.get(node.path));
28
- }
29
- });
7
+ const { rootNodes } = buildDocumentTree(structure);
30
8
 
31
9
  function printNode(node, depth = 0) {
32
10
  const INDENT_SPACES = " ";
@@ -72,25 +50,27 @@ export default async function userReviewDocumentStructure({ documentStructure, .
72
50
  }
73
51
 
74
52
  // Print current documentation structure in a user-friendly format
75
- printDocumentStructure(documentStructure);
76
-
77
- // Ask user if they want to review the documentation structure
78
- const needReview = await options.prompts.select({
79
- message: "Would you like to refine the documentation structure?",
80
- choices: [
81
- {
82
- name: "No, looks good",
83
- value: "no",
84
- },
85
- {
86
- name: "Yes, optimize the structure (e.g. rename 'Getting Started' to 'Quick Start', move 'API Reference' before 'Configuration')",
87
- value: "yes",
88
- },
89
- ],
90
- });
91
-
92
- if (needReview === "no") {
93
- return { documentStructure };
53
+ if (!rest.isChat) {
54
+ printDocumentStructure(documentStructure);
55
+
56
+ // Ask user if they want to review the documentation structure
57
+ const needReview = await options.prompts.select({
58
+ message: "Would you like to refine the documentation structure?",
59
+ choices: [
60
+ {
61
+ name: "No, looks good",
62
+ value: "no",
63
+ },
64
+ {
65
+ name: "Yes, optimize the structure (e.g. rename 'Getting Started' to 'Quick Start', move 'API Reference' before 'Configuration')",
66
+ value: "yes",
67
+ },
68
+ ],
69
+ });
70
+
71
+ if (needReview === "no") {
72
+ return { documentStructure };
73
+ }
94
74
  }
95
75
 
96
76
  let currentStructure = documentStructure;
@@ -104,15 +84,17 @@ export default async function userReviewDocumentStructure({ documentStructure, .
104
84
  iterationCount++;
105
85
 
106
86
  // Ask for feedback
107
- const feedback = await options.prompts.input({
108
- message:
109
- "How would you like to improve the structure?\n" +
110
- "Examples:\n" +
111
- " Add a new document 'Troubleshooting'\n" +
112
- " • Remove the 'Legacy Features' document\n" +
113
- " • Move 'Installation' to the top of the structure\n\n" +
114
- " Press Enter to finish reviewing:",
115
- });
87
+ const feedback = rest.isChat
88
+ ? rest.feedback
89
+ : await options.prompts.input({
90
+ message:
91
+ "How would you like to improve the structure?\n" +
92
+ "Examples:\n" +
93
+ " • Add a new document 'Troubleshooting'\n" +
94
+ " Remove the 'Legacy Features' document\n" +
95
+ " • Move 'Installation' to the top of the structure\n\n" +
96
+ " Press Enter to finish reviewing:",
97
+ });
116
98
 
117
99
  // If no feedback, break the loop
118
100
  if (!feedback?.trim()) {
@@ -138,9 +120,9 @@ export default async function userReviewDocumentStructure({ documentStructure, .
138
120
 
139
121
  try {
140
122
  // Call refineDocumentStructure agent with feedback
141
- await options.context.invoke(refineAgent, {
123
+ const { message } = await options.context.invoke(refineAgent, {
142
124
  ...rest,
143
- dataSourceChunk: rest.datasources[0].dataSourceChunk,
125
+ dataSourceChunk: rest.dataSources[0].dataSourceChunk,
144
126
  feedback: feedback.trim(),
145
127
  documentStructure: currentStructure,
146
128
  userPreferences,
@@ -148,6 +130,12 @@ export default async function userReviewDocumentStructure({ documentStructure, .
148
130
 
149
131
  currentStructure = options.context.userContext.currentStructure;
150
132
 
133
+ if (rest.isChat && equal(currentStructure, documentStructure)) {
134
+ throw new Error(
135
+ `The suggested structure changes did not modify the existing documentation structure. ${message}`,
136
+ );
137
+ }
138
+
151
139
  // Check if feedback should be saved as user preference
152
140
  const feedbackRefinerAgent = options.context.agents["checkFeedbackRefiner"];
153
141
  if (feedbackRefinerAgent) {
@@ -170,6 +158,10 @@ export default async function userReviewDocumentStructure({ documentStructure, .
170
158
 
171
159
  // Print current documentation structure in a user-friendly format
172
160
  printDocumentStructure(currentStructure);
161
+
162
+ if (rest.isChat) {
163
+ break;
164
+ }
173
165
  } catch (error) {
174
166
  console.error("Error processing your feedback:");
175
167
  console.error(`Type: ${error.name}`);
@@ -11,13 +11,13 @@ export default async function mergeDocumentStructures(input, options) {
11
11
 
12
12
  options.context.userContext.originalDocumentStructure ??= [];
13
13
 
14
- const originalStructures = options.context.userContext.originalDocumentStructure;
14
+ const originalStructures = [...options.context.userContext.originalDocumentStructure];
15
15
 
16
16
  if (input.structures) {
17
17
  for (const item of input.structures) {
18
- const old = originalStructures.find((s) => s.path === item.path);
19
- if (old) {
20
- Object.assign(old, item);
18
+ const index = originalStructures.findIndex((s) => s.path === item.path);
19
+ if (index !== -1) {
20
+ originalStructures[index] = item;
21
21
  } else {
22
22
  originalStructures.push(item);
23
23
  }
@@ -6,7 +6,7 @@ export default async function checkNeedGenerate({ docsDir, locale, documentExecu
6
6
 
7
7
  if (mainLanguageFiles.length === 0) {
8
8
  console.log(
9
- `No documents found in the docs directory. Please run ${chalk.yellow("`aigne doc generate`")} to generate the documents`,
9
+ `No documents found in the docs directory. You can generate them with ${chalk.yellow("`aigne doc generate`")}`,
10
10
  );
11
11
  process.exit(0);
12
12
  }