@aigne/doc-smith 0.8.12-beta → 0.8.12-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +20 -0
- package/agents/generate/check-diagram.mjs +40 -0
- package/agents/generate/draw-diagram.yaml +23 -0
- package/agents/generate/generate-structure.yaml +5 -1
- package/agents/generate/merge-d2-diagram.yaml +3 -3
- package/agents/generate/update-document-structure.yaml +5 -2
- package/agents/generate/user-review-document-structure.mjs +7 -0
- package/agents/generate/wrap-diagram-code.mjs +35 -0
- package/agents/history/index.yaml +6 -0
- package/agents/history/view.mjs +75 -0
- package/agents/translate/index.yaml +3 -2
- package/agents/translate/record-translation-history.mjs +19 -0
- package/agents/translate/translate-multilingual.yaml +2 -1
- package/agents/update/batch-update-document.yaml +1 -1
- package/agents/update/check-document.mjs +5 -1
- package/agents/update/generate-document.yaml +31 -25
- package/agents/update/{generate-and-translate-document.yaml → handle-document-update.yaml} +2 -11
- package/agents/update/index.yaml +1 -0
- package/agents/update/save-and-translate-document.mjs +106 -0
- package/agents/update/update-document-detail.yaml +5 -1
- package/agents/update/update-single-document.yaml +1 -10
- package/agents/update/user-review-document.mjs +10 -1
- package/aigne.yaml +8 -1
- package/package.json +1 -1
- package/prompts/detail/d2-diagram/guide.md +19 -0
- package/prompts/detail/d2-diagram/role-and-personality.md +2 -0
- package/prompts/detail/d2-diagram/rules.md +24 -0
- package/prompts/detail/d2-diagram/{rules-system.md → system-prompt.md} +3 -9
- package/prompts/detail/{document-rules.md → generate/document-rules.md} +1 -1
- package/prompts/detail/generate/system-prompt.md +72 -0
- package/prompts/detail/generate/user-prompt.md +54 -0
- package/prompts/detail/{update-document.md → update/system-prompt.md} +43 -67
- package/prompts/detail/update/user-prompt.md +33 -0
- package/prompts/structure/{generate-structure-system.md → generate/system-prompt.md} +7 -40
- package/prompts/structure/{generate-structure-user.md → generate/user-prompt.md} +17 -13
- package/prompts/structure/{update-document-structure.md → update/system-prompt.md} +16 -27
- package/prompts/structure/update/user-prompt.md +19 -0
- package/tests/agents/generate/user-review-document-structure.test.mjs +2 -0
- package/tests/agents/update/check-document.test.mjs +1 -1
- package/tests/agents/update/save-and-translate-document.test.mjs +369 -0
- package/tests/agents/utils/check-detail-result.test.mjs +13 -0
- package/tests/utils/d2-utils.test.mjs +14 -0
- package/tests/utils/docs-finder-utils.test.mjs +13 -0
- package/tests/utils/history-utils.test.mjs +178 -0
- package/utils/d2-utils.mjs +9 -0
- package/utils/docs-finder-utils.mjs +10 -1
- package/utils/history-utils.mjs +191 -0
- package/utils/markdown-checker.mjs +20 -0
- package/agents/generate/check-d2-diagram-valid.mjs +0 -26
- package/agents/generate/generate-d2-diagram.yaml +0 -23
- package/prompts/detail/generate-document.md +0 -125
- /package/prompts/detail/d2-diagram/{rules-user.md → user-prompt.md} +0 -0
- /package/prompts/detail/{detail-example.md → generate/detail-example.md} +0 -0
package/package.json
CHANGED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<diagram_generation_guide>
|
|
2
|
+
1. Diagram Triggers and Types: Use the following guidelines to determine when to generate a diagram and which type to use.
|
|
3
|
+
- Architecture Diagram (High-Level)
|
|
4
|
+
- Trigger: When generating a document that serves as a high-level overview of a system, project, or the entire documentation set.
|
|
5
|
+
- Action: Create a system architecture diagram.
|
|
6
|
+
- Content: The diagram should illustrate the main components, their relationships, and the overall structure.
|
|
7
|
+
- Structural Diagram (Module-Level)
|
|
8
|
+
- Trigger: When generating the introductory document for a major section or module.
|
|
9
|
+
- Action: Create a structural diagram (e.g., a block diagram or mind map).
|
|
10
|
+
- Content: The diagram should show the key sub-components, files, or concepts within that specific module.
|
|
11
|
+
- Process and Interaction Diagrams (Detailed)
|
|
12
|
+
- Trigger: When the document describes a workflow, a sequence of events, user interactions, or data flow.
|
|
13
|
+
- Action: Create the most appropriate diagram type:
|
|
14
|
+
- Flowchart: Use for step-by-step processes, algorithms, or decision-making logic.
|
|
15
|
+
- Sequence Diagram: Use for time-ordered interactions between different components or actors (e.g., API calls).
|
|
16
|
+
2. Constraints and Best Practices
|
|
17
|
+
- Quantity: Generate a maximum of three (3) diagrams per document to ensure the content remains focused and readable.
|
|
18
|
+
- Relevance: Ensure every diagram directly illustrates a concept explained in the surrounding text. Avoid generating diagrams for simple concepts that are easily understood through text alone.
|
|
19
|
+
</diagram_generation_guide>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<diagram_generation_guide>
|
|
2
|
+
1. Core Principle: Tool Use is Mandatory
|
|
3
|
+
- You MUST use the drawDiagram tool to generate and embed all diagrams.
|
|
4
|
+
- NEVER write raw diagram code (e.g., Mermaid syntax) directly into the document.
|
|
5
|
+
- If a drawDiagram tool call fails, omit the diagram entirely and proceed with generating the text. Do not attempt to describe the diagram in words as a replacement.
|
|
6
|
+
|
|
7
|
+
2. Diagram Triggers and Types: Use the following guidelines to determine when to generate a diagram and which type to use.
|
|
8
|
+
- Architecture Diagram (High-Level)
|
|
9
|
+
- Trigger: When generating a document that serves as a high-level overview of a system, project, or the entire documentation set.
|
|
10
|
+
- Action: Call drawDiagram to create a system architecture diagram.
|
|
11
|
+
- Content: The diagram should illustrate the main components, their relationships, and the overall structure.
|
|
12
|
+
- Structural Diagram (Module-Level)
|
|
13
|
+
- Trigger: When generating the introductory document for a major section or module.
|
|
14
|
+
- Action: Call drawDiagram to create a structural diagram (e.g., a block diagram or mind map).
|
|
15
|
+
- Content: The diagram should show the key sub-components, files, or concepts within that specific module.
|
|
16
|
+
- Process and Interaction Diagrams (Detailed)
|
|
17
|
+
- Trigger: When the document describes a workflow, a sequence of events, user interactions, or data flow.
|
|
18
|
+
- Action: Call drawDiagram to create the most appropriate diagram type:
|
|
19
|
+
- Flowchart: Use for step-by-step processes, algorithms, or decision-making logic.
|
|
20
|
+
- Sequence Diagram: Use for time-ordered interactions between different components or actors (e.g., API calls).
|
|
21
|
+
3. Constraints and Best Practices
|
|
22
|
+
- Quantity: Generate a maximum of three (3) diagrams per document to ensure the content remains focused and readable.
|
|
23
|
+
- Relevance: Ensure every diagram directly illustrates a concept explained in the surrounding text. Avoid generating diagrams for simple concepts that are easily understood through text alone.
|
|
24
|
+
</diagram_generation_guide>
|
|
@@ -2,15 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
## Preamble: LLM Role and Core Objective
|
|
4
4
|
|
|
5
|
-
You are an
|
|
6
|
-
You are reliable, rule-abiding, and methodical. Your goal is to produce **clear, precise, and logically structured d2-diagram code** that accurately represents the given description.
|
|
5
|
+
You are an expert software architect and a master of the D2 (Declarative Diagramming) language. Your primary function is to translate abstract descriptions of software systems, components, and processes into precise, readable, and visually effective D2 diagram code.
|
|
7
6
|
|
|
8
7
|
Your core directive is to produce D2 code that is not only syntactically correct but also semantically meaningful and adheres to the highest standards of technical diagramming. The generated output must follow all instructions, constraints, and best practices detailed in this document. You will operate in a zero-tolerance mode for syntactical errors, especially concerning predefined keyword values. The fundamental principle is the separation of concerns: the logical structure of the diagram must be defined independently of its visual styling. The following chapters are structured to enforce this principle.
|
|
9
8
|
|
|
10
9
|
You value **order, consistency, and factual accuracy** over abstract or decorative styles.
|
|
11
10
|
Your diagrams should focus on **readability, structural correctness, and practical use in technical documentation**.
|
|
12
11
|
|
|
13
|
-
**
|
|
12
|
+
**Guiding principles for diagram generation:**
|
|
14
13
|
|
|
15
14
|
1. **Fact-Driven and Accurate:**
|
|
16
15
|
- Adhere strictly to the provided description and rules.
|
|
@@ -38,12 +37,7 @@ Your diagrams should focus on **readability, structural correctness, and practic
|
|
|
38
37
|
**Output Requirements:**
|
|
39
38
|
- Output only valid d2-diagram code.
|
|
40
39
|
- Do not include explanatory text outside of the code block.
|
|
41
|
-
- Ensure the diagram reflects a clean, professional,
|
|
42
|
-
- output must be wrap with
|
|
43
|
-
```md
|
|
44
|
-
\`\`\`d2\n...\n\`\`\`
|
|
45
|
-
```
|
|
46
|
-
|
|
40
|
+
- Ensure the diagram reflects a clean, professional, technical drawing.
|
|
47
41
|
|
|
48
42
|
|
|
49
43
|
## Chapter 1: Core Instructions for D2 Diagram Generation
|
|
@@ -25,7 +25,7 @@ Documentation Generation Rules:
|
|
|
25
25
|
- Use README files for reference only—extract the most current and comprehensive information directly from source code
|
|
26
26
|
- Omit tag information from document headers as it's processed programmatically
|
|
27
27
|
- Parse `jsx` syntax correctly when present in code samples
|
|
28
|
-
{% include "jsx/rules.md" %}
|
|
28
|
+
{% include "../jsx/rules.md" %}
|
|
29
29
|
|
|
30
30
|
</document_rules>
|
|
31
31
|
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
<role_and_goal>
|
|
2
|
+
{% include "../../common/document/role-and-personality.md" %}
|
|
3
|
+
|
|
4
|
+
Your task is to generate detailed document for the current {{nodeName}} based on user-provided information: current {{nodeName}} details (including title, description, path), DataSources, documentStructure (overall structural planning), and other relevant information.
|
|
5
|
+
</role_and_goal>
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
<current_document>
|
|
9
|
+
Current {{nodeName}} information:
|
|
10
|
+
title: {{title}}
|
|
11
|
+
description: {{description}}
|
|
12
|
+
path: {{path}}
|
|
13
|
+
parentId: {{parentId}}
|
|
14
|
+
</current_document>
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
<document_structure>
|
|
18
|
+
{{ documentStructureYaml }}
|
|
19
|
+
</document_structure>
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
{% if glossary %}
|
|
23
|
+
<terms>
|
|
24
|
+
Glossary of specialized terms. Please ensure correct spelling when using these terms.
|
|
25
|
+
|
|
26
|
+
{{glossary}}
|
|
27
|
+
</terms>
|
|
28
|
+
{% endif %}
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
<content_generation_rules>
|
|
32
|
+
|
|
33
|
+
{% include "../../common/document/content-rules-core.md" %}
|
|
34
|
+
|
|
35
|
+
Documentation content generation rules:
|
|
36
|
+
{% include "./document-rules.md" %}
|
|
37
|
+
|
|
38
|
+
Custom component generation rules:
|
|
39
|
+
{% include "../custom/custom-components.md" %}
|
|
40
|
+
|
|
41
|
+
Custom code block generation rules:
|
|
42
|
+
{% include "../custom/custom-code-block.md" %}
|
|
43
|
+
|
|
44
|
+
Diagram generation rules:
|
|
45
|
+
{% include "../d2-diagram/guide.md" %}
|
|
46
|
+
<diagram_generation_rules>
|
|
47
|
+
{% include "../d2-diagram/system-prompt.md" %}
|
|
48
|
+
</diagram_generation_rules>
|
|
49
|
+
|
|
50
|
+
</content_generation_rules>
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
<tool-usage>
|
|
54
|
+
1. glob: Find files matching specific patterns with advanced filtering and sorting.
|
|
55
|
+
|
|
56
|
+
2. grep: Search file contents using regular expressions with multiple strategies (git grep → system grep → JavaScript fallback).
|
|
57
|
+
|
|
58
|
+
3. readFile: Read file contents with intelligent binary detection, pagination, and metadata extraction.
|
|
59
|
+
|
|
60
|
+
When to use Tools:
|
|
61
|
+
- During document generation, if the given context is missing or lacks referenced content, use glob/grep/readFile to obtain more context
|
|
62
|
+
- Code examples in generated documents must use APIs and packages defined in the input data sources. Do not generate non-existent code out of thin air. Use glob/grep/readFile to query related code or references
|
|
63
|
+
</tool-usage>
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
<output_constraints>
|
|
67
|
+
|
|
68
|
+
1. Output detailed text content for {{nodeName}}.
|
|
69
|
+
2. Output {{nodeName}} content directly without including other information.
|
|
70
|
+
3. Reference the style from examples only, **output content in {{locale}} language**
|
|
71
|
+
|
|
72
|
+
</output_constraints>
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
<user_locale>
|
|
2
|
+
{{ locale }}
|
|
3
|
+
</user_locale>
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
<user_rules>
|
|
7
|
+
{{ rules }}
|
|
8
|
+
|
|
9
|
+
** Output content in {{ locale }} language **
|
|
10
|
+
</user_rules>
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
{% set operation_type = "generating" %}
|
|
14
|
+
{% include "../../common/document/user-preferences.md" %}
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
<datasources>
|
|
18
|
+
{{ detailDataSources }}
|
|
19
|
+
|
|
20
|
+
{{ additionalInformation }}
|
|
21
|
+
|
|
22
|
+
<media_list>
|
|
23
|
+
{{ assetsContent }}
|
|
24
|
+
</media_list>
|
|
25
|
+
|
|
26
|
+
{% include "../../common/document/media-handling-rules.md" %}
|
|
27
|
+
|
|
28
|
+
</datasources>
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
{% include "./detail-example.md" %}
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
{% if content %}
|
|
35
|
+
Content from previous generation:
|
|
36
|
+
<last_content>
|
|
37
|
+
{{content}}
|
|
38
|
+
</last_content>
|
|
39
|
+
{% endif %}
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
{% if detailFeedback %}
|
|
43
|
+
<content_review_feedback>
|
|
44
|
+
{{ detailFeedback }}
|
|
45
|
+
</content_review_feedback>
|
|
46
|
+
{% endif %}
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
{% if feedback %}
|
|
50
|
+
User feedback on previous generation:
|
|
51
|
+
<feedback>
|
|
52
|
+
{{feedback}}
|
|
53
|
+
</feedback>
|
|
54
|
+
{% endif %}
|
|
@@ -1,28 +1,53 @@
|
|
|
1
1
|
<role_and_goal>
|
|
2
|
-
{% include "
|
|
2
|
+
{% include "../../common/document/role-and-personality.md" %}
|
|
3
3
|
|
|
4
4
|
Your task is to analyze the original document content and user feedback, then use available tools to implement the requested improvements while maintaining the document's integrity and style.
|
|
5
5
|
</role_and_goal>
|
|
6
6
|
|
|
7
|
-
<user_locale>
|
|
8
|
-
{{ locale }}
|
|
9
|
-
</user_locale>
|
|
10
7
|
|
|
11
|
-
<
|
|
12
|
-
{{
|
|
8
|
+
<document_structure>
|
|
9
|
+
{{ documentStructureYaml }}
|
|
10
|
+
</document_structure>
|
|
11
|
+
|
|
12
|
+
<current_document>
|
|
13
|
+
Current {{nodeName}} information:
|
|
14
|
+
title: {{title}}
|
|
15
|
+
description: {{description}}
|
|
16
|
+
path: {{path}}
|
|
17
|
+
parentId: {{parentId}}
|
|
18
|
+
</current_document>
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
{% if glossary %}
|
|
22
|
+
<terms>
|
|
23
|
+
Glossary of specialized terms. Please ensure correct spelling when using these terms.
|
|
24
|
+
|
|
25
|
+
{{glossary}}
|
|
26
|
+
</terms>
|
|
27
|
+
{% endif %}
|
|
13
28
|
|
|
14
|
-
** Output content in {{ locale }} language **
|
|
15
|
-
</user_rules>
|
|
16
29
|
|
|
17
|
-
|
|
18
|
-
{% include "../common/document/user-preferences.md" %}
|
|
30
|
+
<content_optimization_rules>
|
|
19
31
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
32
|
+
{% include "../../common/document/content-rules-core.md" %}
|
|
33
|
+
|
|
34
|
+
Documentation content optimization rules:
|
|
35
|
+
{% include "../generate/document-rules.md" %}
|
|
36
|
+
|
|
37
|
+
Custom component optimization rules:
|
|
38
|
+
{% include "../custom/custom-components.md" %}
|
|
39
|
+
|
|
40
|
+
Custom code block optimization rules:
|
|
41
|
+
{% include "../custom/custom-code-block.md" %}
|
|
42
|
+
|
|
43
|
+
Diagram generation rules:
|
|
44
|
+
{% include "../d2-diagram/guide.md" %}
|
|
45
|
+
<diagram_generation_rules>
|
|
46
|
+
{% include "../d2-diagram/system-prompt.md" %}
|
|
47
|
+
</diagram_generation_rules>
|
|
48
|
+
|
|
49
|
+
</content_optimization_rules>
|
|
23
50
|
|
|
24
|
-
<user_feedback>
|
|
25
|
-
{{feedback}}
|
|
26
51
|
|
|
27
52
|
<feedback_analysis_guidelines>
|
|
28
53
|
|
|
@@ -55,57 +80,6 @@ Analyze the user feedback to determine the specific improvements needed:
|
|
|
55
80
|
|
|
56
81
|
</feedback_analysis_guidelines>
|
|
57
82
|
|
|
58
|
-
</user_feedback>
|
|
59
|
-
|
|
60
|
-
<content_optimization_rules>
|
|
61
|
-
|
|
62
|
-
{% include "../common/document/content-rules-core.md" %}
|
|
63
|
-
|
|
64
|
-
Documentation content optimization rules:
|
|
65
|
-
{% include "./document-rules.md" %}
|
|
66
|
-
|
|
67
|
-
Custom component optimization rules:
|
|
68
|
-
{% include "custom/custom-components.md" %}
|
|
69
|
-
|
|
70
|
-
Custom code block optimization rules:
|
|
71
|
-
{% include "custom/custom-code-block.md" %}
|
|
72
|
-
|
|
73
|
-
</content_optimization_rules>
|
|
74
|
-
|
|
75
|
-
{% if glossary %}
|
|
76
|
-
<terms>
|
|
77
|
-
Glossary of specialized terms. Please ensure correct spelling when using these terms.
|
|
78
|
-
|
|
79
|
-
{{glossary}}
|
|
80
|
-
</terms>
|
|
81
|
-
{% endif %}
|
|
82
|
-
|
|
83
|
-
<document_structure>
|
|
84
|
-
{{ documentStructureYaml }}
|
|
85
|
-
</document_structure>
|
|
86
|
-
|
|
87
|
-
<current_document>
|
|
88
|
-
Current {{nodeName}} information:
|
|
89
|
-
title: {{title}}
|
|
90
|
-
description: {{description}}
|
|
91
|
-
path: {{path}}
|
|
92
|
-
parentId: {{parentId}}
|
|
93
|
-
</current_document>
|
|
94
|
-
|
|
95
|
-
<datasources>
|
|
96
|
-
{{ detailDataSources }}
|
|
97
|
-
|
|
98
|
-
{{ additionalInformation }}
|
|
99
|
-
|
|
100
|
-
<media_list>
|
|
101
|
-
{{ assetsContent }}
|
|
102
|
-
</media_list>
|
|
103
|
-
|
|
104
|
-
{% include "../common/document/media-handling-rules.md" %}
|
|
105
|
-
</datasources>
|
|
106
|
-
|
|
107
|
-
{% include "./detail-example.md" %}
|
|
108
|
-
|
|
109
83
|
<task_instructions>
|
|
110
84
|
Your task is to:
|
|
111
85
|
|
|
@@ -132,8 +106,10 @@ Error handling:
|
|
|
132
106
|
- If the diff patch fails to apply, revise the approach and try again
|
|
133
107
|
</task_instructions>
|
|
134
108
|
|
|
109
|
+
{% include "../generate/detail-example.md" %}
|
|
110
|
+
|
|
135
111
|
<output_format>
|
|
136
112
|
** Only output operation execution status **:
|
|
137
113
|
- Only return 'success' if operation executed successfully
|
|
138
114
|
- Return brief error message if operation failed
|
|
139
|
-
</output_format>
|
|
115
|
+
</output_format>
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<user_locale>
|
|
2
|
+
{{ locale }}
|
|
3
|
+
</user_locale>
|
|
4
|
+
|
|
5
|
+
<user_rules>
|
|
6
|
+
{{ rules }}
|
|
7
|
+
|
|
8
|
+
** Output content in {{ locale }} language **
|
|
9
|
+
</user_rules>
|
|
10
|
+
|
|
11
|
+
{% set operation_type = "optimizing" %}
|
|
12
|
+
{% include "../../common/document/user-preferences.md" %}
|
|
13
|
+
|
|
14
|
+
<original_page_content>
|
|
15
|
+
{{originalContent}}
|
|
16
|
+
</original_page_content>
|
|
17
|
+
|
|
18
|
+
<datasources>
|
|
19
|
+
|
|
20
|
+
{{ detailDataSources }}
|
|
21
|
+
|
|
22
|
+
{{ additionalInformation }}
|
|
23
|
+
|
|
24
|
+
<media_list>
|
|
25
|
+
{{ assetsContent }}
|
|
26
|
+
</media_list>
|
|
27
|
+
|
|
28
|
+
{% include "../../common/document/media-handling-rules.md" %}
|
|
29
|
+
</datasources>
|
|
30
|
+
|
|
31
|
+
<user_feedback>
|
|
32
|
+
{{feedback}}
|
|
33
|
+
</user_feedback>
|
|
@@ -17,58 +17,25 @@ Objectives:
|
|
|
17
17
|
- Create a clear and logical structural plan that comprehensively presents information from the user-provided context while providing users with intuitive navigation paths.
|
|
18
18
|
- Each {{nodeName}} should include: a {{nodeName}} title, a one-sentence introduction describing its main content, with presentation and organization methods tailored to the target audience.
|
|
19
19
|
|
|
20
|
-
{% include "
|
|
20
|
+
{% include "../../common/document-structure/intj-traits.md" %}
|
|
21
21
|
|
|
22
22
|
Always follow one principle: You must ensure the final structural plan meets user requirements.
|
|
23
23
|
</role_and_goal>
|
|
24
24
|
|
|
25
|
-
{% include "../common/document-structure/user-locale-rules.md" %}
|
|
26
25
|
|
|
27
|
-
{% include "
|
|
26
|
+
{% include "../../common/document-structure/glossary.md" %}
|
|
28
27
|
|
|
29
|
-
{% if feedback %}
|
|
30
|
-
<document_structure_user_feedback>
|
|
31
|
-
{{ feedback }}
|
|
32
|
-
</document_structure_user_feedback>
|
|
33
|
-
{% endif %}
|
|
34
28
|
|
|
35
|
-
{% if originalDocumentStructure %}
|
|
36
|
-
<last_document_structure>
|
|
37
|
-
{{originalDocumentStructure}}
|
|
38
|
-
</last_document_structure>
|
|
39
|
-
|
|
40
|
-
<last_document_structure_rule>
|
|
41
|
-
If a previous structural plan (last_document_structure) is provided, follow these rules:
|
|
42
|
-
1. **Feedback Implementation**: The new structural plan **must** correctly implement all changes requested in user feedback.
|
|
43
|
-
2. **Unrelated Node Stability**: Nodes not mentioned in user feedback **must not have their path or sourcesIds attributes modified**. `path` and `sourcesIds` are critical identifiers linking existing content, and their stability is paramount.
|
|
44
|
-
Ideally, other attributes (such as `title`, `description`) should also remain stable, unless these changes are directly caused by a requested modification or result from DataSource updates.
|
|
45
|
-
</last_document_structure_rule>
|
|
46
|
-
{% endif %}
|
|
47
29
|
|
|
48
|
-
{%
|
|
49
|
-
<review_document_structure>
|
|
50
|
-
{{ documentStructure }}
|
|
51
|
-
</review_document_structure>
|
|
52
|
-
{% endif %}
|
|
30
|
+
{% include "../../common/document-structure/document-structure-rules.md" %}
|
|
53
31
|
|
|
54
|
-
{% if structureReviewFeedback %}
|
|
55
|
-
<document_structure_review_feedback>
|
|
56
|
-
{{ structureReviewFeedback }}
|
|
57
|
-
</document_structure_review_feedback>
|
|
58
|
-
{% endif %}
|
|
59
32
|
|
|
60
|
-
{% include "
|
|
33
|
+
{% include "../../common/document-structure/conflict-resolution-guidance.md" %}
|
|
61
34
|
|
|
62
|
-
{% include "../common/document-structure/conflict-resolution-guidance.md" %}
|
|
63
|
-
|
|
64
|
-
{% include "../common/document-structure/glossary.md" %}
|
|
65
|
-
|
|
66
|
-
<datasources>
|
|
67
|
-
{{ datasources }}
|
|
68
|
-
</datasources>
|
|
69
35
|
|
|
70
36
|
{% ifAsync docsType == 'general' %}
|
|
71
|
-
{% include "
|
|
37
|
+
{% include "../structure-example.md" %}
|
|
72
38
|
{% endif %}
|
|
73
39
|
|
|
74
|
-
|
|
40
|
+
|
|
41
|
+
{% include "../../common/document-structure/output-constraints.md" %}
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
|
|
2
|
-
{% include "
|
|
2
|
+
{% include "../../common/document-structure/user-locale-rules.md" %}
|
|
3
3
|
|
|
4
|
-
{% include "
|
|
4
|
+
{% include "../../common/document-structure/user-preferences.md" %}
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
<datasources>
|
|
8
|
+
{{ datasources }}
|
|
9
|
+
</datasources>
|
|
5
10
|
|
|
6
|
-
{% if feedback %}
|
|
7
|
-
<document_structure_user_feedback>
|
|
8
|
-
{{ feedback }}
|
|
9
|
-
</document_structure_user_feedback>
|
|
10
|
-
{% endif %}
|
|
11
11
|
|
|
12
12
|
{% if originalDocumentStructure %}
|
|
13
13
|
<last_document_structure>
|
|
14
14
|
{{originalDocumentStructure}}
|
|
15
15
|
</last_document_structure>
|
|
16
16
|
|
|
17
|
+
|
|
17
18
|
<last_document_structure_rule>
|
|
18
19
|
If a previous structural plan (last_document_structure) is provided, follow these rules:
|
|
19
20
|
1. **Feedback Implementation**: The new structural plan **must** correctly implement all changes requested in user feedback.
|
|
@@ -22,20 +23,23 @@ If a previous structural plan (last_document_structure) is provided, follow thes
|
|
|
22
23
|
</last_document_structure_rule>
|
|
23
24
|
{% endif %}
|
|
24
25
|
|
|
26
|
+
|
|
25
27
|
{% if documentStructure %}
|
|
26
28
|
<review_document_structure>
|
|
27
29
|
{{ documentStructure }}
|
|
28
30
|
</review_document_structure>
|
|
29
31
|
{% endif %}
|
|
30
32
|
|
|
33
|
+
|
|
34
|
+
{% if feedback %}
|
|
35
|
+
<document_structure_user_feedback>
|
|
36
|
+
{{ feedback }}
|
|
37
|
+
</document_structure_user_feedback>
|
|
38
|
+
{% endif %}
|
|
39
|
+
|
|
40
|
+
|
|
31
41
|
{% if structureReviewFeedback %}
|
|
32
42
|
<document_structure_review_feedback>
|
|
33
43
|
{{ structureReviewFeedback }}
|
|
34
44
|
</document_structure_review_feedback>
|
|
35
45
|
{% endif %}
|
|
36
|
-
|
|
37
|
-
{% include "../common/document-structure/glossary.md" %}
|
|
38
|
-
|
|
39
|
-
<datasources>
|
|
40
|
-
{{ datasources }}
|
|
41
|
-
</datasources>
|
|
@@ -4,7 +4,7 @@ You are a documentation structure update specialist with the strategic mindset o
|
|
|
4
4
|
You analyze user feedback and intentions to modify existing documentation structures using specific operations.
|
|
5
5
|
Your task is to understand user requirements and execute the appropriate structure modifications efficiently and accurately.
|
|
6
6
|
|
|
7
|
-
{% include "
|
|
7
|
+
{% include "../../common/document-structure/intj-traits.md" %}
|
|
8
8
|
|
|
9
9
|
Processing workflow:
|
|
10
10
|
|
|
@@ -25,31 +25,20 @@ Objectives:
|
|
|
25
25
|
|
|
26
26
|
</role_and_goal>
|
|
27
27
|
|
|
28
|
-
{% include "../common/document-structure/user-locale-rules.md" %}
|
|
29
28
|
|
|
30
|
-
{% include "
|
|
29
|
+
{% include "../../common/document-structure/glossary.md" %}
|
|
31
30
|
|
|
32
|
-
Initial Documentation Structure:
|
|
33
|
-
<initial_document_structure>
|
|
34
|
-
{{documentStructure}}
|
|
35
|
-
</initial_document_structure>
|
|
36
31
|
|
|
37
|
-
{% include "
|
|
32
|
+
{% include "../../common/document-structure/document-structure-rules.md" %}
|
|
38
33
|
|
|
39
|
-
{% include "../common/document-structure/conflict-resolution-guidance.md" %}
|
|
40
34
|
|
|
41
|
-
{% include "
|
|
35
|
+
{% include "../../common/document-structure/conflict-resolution-guidance.md" %}
|
|
42
36
|
|
|
43
|
-
<datasources>
|
|
44
|
-
{{ datasources }}
|
|
45
|
-
</datasources>
|
|
46
37
|
|
|
47
38
|
{% ifAsync docsType == 'general' %}
|
|
48
|
-
{% include "
|
|
39
|
+
{% include "../structure-example.md" %}
|
|
49
40
|
{% endif %}
|
|
50
41
|
|
|
51
|
-
<user_feedback>
|
|
52
|
-
{{ feedback }}
|
|
53
42
|
|
|
54
43
|
<feedback_analysis_guidelines>
|
|
55
44
|
|
|
@@ -77,12 +66,9 @@ Analyze the user feedback to determine the intended operation:
|
|
|
77
66
|
|
|
78
67
|
</feedback_analysis_guidelines>
|
|
79
68
|
|
|
80
|
-
</user_feedback>
|
|
81
69
|
|
|
82
70
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
Operation execution rules:
|
|
71
|
+
<operation_execution_rules>
|
|
86
72
|
|
|
87
73
|
- Always analyze the user feedback first to understand the exact intent
|
|
88
74
|
- Use only the appropriate tools based on the determined operation type
|
|
@@ -91,8 +77,7 @@ Operation execution rules:
|
|
|
91
77
|
- Maintain data integrity by ensuring all constraints are met
|
|
92
78
|
- Only use Tools to update data Use provided Tools to modify documentation structure, use the documentation structure returned by Tools as the latest version
|
|
93
79
|
|
|
94
|
-
|
|
95
|
-
|
|
80
|
+
<tool_usage_guidelines>
|
|
96
81
|
1. **addDocument**: Use when user wants to create new document
|
|
97
82
|
- Ensure path starts with '/' and is unique
|
|
98
83
|
- Validate parent exists if parentId is provided
|
|
@@ -109,14 +94,18 @@ Tool usage guidelines:
|
|
|
109
94
|
4. **moveDocument**: Use when user wants to change document hierarchy
|
|
110
95
|
- Validate new parent exists
|
|
111
96
|
- Check for circular dependencies
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
97
|
+
</tool_usage_guidelines>
|
|
98
|
+
<operation_error_handling>
|
|
115
99
|
- If user intent is unclear, ask for clarification
|
|
116
100
|
- If required information is missing, request the needed details
|
|
117
101
|
- If operation would break constraints, explain the issue and suggest alternatives
|
|
118
|
-
|
|
102
|
+
</operation_error_handling>
|
|
103
|
+
<operation_output_constraints>
|
|
119
104
|
** Only output operation execution status **:
|
|
120
105
|
- Only return 'success' if operation executed successfully
|
|
121
106
|
- Return brief error message if operation failed
|
|
122
|
-
</
|
|
107
|
+
</operation_output_constraints>
|
|
108
|
+
</operation_execution_rules>
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
{% include "../../common/document-structure/output-constraints.md" %}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{% include "../../common/document-structure/user-locale-rules.md" %}
|
|
2
|
+
|
|
3
|
+
{% include "../../common/document-structure/user-preferences.md" %}
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
<datasources>
|
|
7
|
+
{{ datasources }}
|
|
8
|
+
</datasources>
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
Initial Documentation Structure:
|
|
12
|
+
<initial_document_structure>
|
|
13
|
+
{{documentStructure}}
|
|
14
|
+
</initial_document_structure>
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
<user_feedback>
|
|
18
|
+
{{ feedback }}
|
|
19
|
+
</user_feedback>
|
|
@@ -2,6 +2,7 @@ import { afterEach, beforeEach, describe, expect, mock, spyOn, test } from "bun:
|
|
|
2
2
|
import userReviewDocumentStructure from "../../../agents/generate/user-review-document-structure.mjs";
|
|
3
3
|
|
|
4
4
|
import * as preferencesUtils from "../../../utils/preferences-utils.mjs";
|
|
5
|
+
import * as historyUtils from "../../../utils/history-utils.mjs";
|
|
5
6
|
|
|
6
7
|
describe("user-review-document-structure", () => {
|
|
7
8
|
let mockOptions;
|
|
@@ -61,6 +62,7 @@ describe("user-review-document-structure", () => {
|
|
|
61
62
|
);
|
|
62
63
|
|
|
63
64
|
consoleSpy = spyOn(console, "log").mockImplementation(() => {});
|
|
65
|
+
spyOn(historyUtils, "recordUpdate").mockImplementation(() => {});
|
|
64
66
|
|
|
65
67
|
// Clear prompts mock call history
|
|
66
68
|
mockOptions.prompts.select.mockClear();
|