@aigne/doc-smith 0.8.6 → 0.8.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.
- package/.aigne/doc-smith/output/structure-plan.json +1 -5
- package/CHANGELOG.md +7 -0
- package/README.md +3 -3
- package/agents/{chat.yaml → chat/index.yaml} +7 -7
- package/agents/generate/check-document-structure.yaml +30 -0
- package/agents/{check-structure-plan.mjs → generate/check-need-generate-structure.mjs} +20 -20
- package/agents/{structure-planning.yaml → generate/generate-structure.yaml} +6 -6
- package/agents/{docs-generator.yaml → generate/index.yaml} +11 -12
- package/agents/generate/refine-document-structure.yaml +12 -0
- package/agents/{input-generator.mjs → init/index.mjs} +12 -5
- package/agents/{manage-prefs.mjs → prefs/index.mjs} +1 -1
- package/agents/{team-publish-docs.yaml → publish/index.yaml} +1 -2
- package/agents/{publish-docs.mjs → publish/publish-docs.mjs} +6 -5
- package/agents/schema/{structure-plan-result.yaml → document-execution-structure.yaml} +3 -3
- package/agents/schema/document-structure.yaml +26 -0
- package/agents/{language-selector.mjs → translate/choose-language.mjs} +5 -5
- package/agents/{retranslate.yaml → translate/index.yaml} +11 -12
- package/agents/{translate.yaml → translate/translate-document.yaml} +3 -2
- package/agents/{batch-translate.yaml → translate/translate-multilingual.yaml} +5 -5
- package/agents/update/batch-generate-document.yaml +19 -0
- package/agents/{check-detail.mjs → update/check-document.mjs} +16 -16
- package/agents/{detail-generator-and-translate.yaml → update/generate-and-translate-document.yaml} +23 -23
- package/agents/update/generate-document.yaml +50 -0
- package/agents/{detail-regenerator.yaml → update/index.yaml} +10 -11
- package/agents/{action-success.mjs → utils/action-success.mjs} +1 -1
- package/agents/{check-detail-result.mjs → utils/check-detail-result.mjs} +3 -3
- package/agents/{check-feedback-refiner.mjs → utils/check-feedback-refiner.mjs} +6 -6
- package/agents/{find-items-by-paths.mjs → utils/choose-docs.mjs} +24 -9
- package/agents/{docs-fs.yaml → utils/docs-fs-actor.yaml} +3 -1
- package/agents/{feedback-refiner.yaml → utils/feedback-refiner.yaml} +2 -4
- package/agents/{find-item-by-path.mjs → utils/find-item-by-path.mjs} +16 -6
- package/agents/{find-user-preferences-by-path.mjs → utils/find-user-preferences-by-path.mjs} +1 -1
- package/agents/utils/format-document-structure.mjs +25 -0
- package/agents/{load-sources.mjs → utils/load-sources.mjs} +41 -28
- package/agents/{save-docs.mjs → utils/save-docs.mjs} +16 -16
- package/agents/{save-single-doc.mjs → utils/save-single-doc.mjs} +2 -2
- package/agents/{transform-detail-datasources.mjs → utils/transform-detail-datasources.mjs} +1 -1
- package/aigne.yaml +35 -35
- package/docs-mcp/analyze-docs-relevance.yaml +10 -10
- package/docs-mcp/docs-search.yaml +5 -3
- package/package.json +10 -8
- package/prompts/{document → detail/custom}/custom-code-block.md +6 -6
- package/prompts/detail/custom/custom-components.md +172 -0
- package/prompts/{document → detail}/d2-chart/rules.md +95 -1
- package/prompts/{document → detail}/detail-example.md +80 -61
- package/prompts/{document/detail-generator.md → detail/document-rules.md} +4 -8
- package/prompts/{content-detail-generator.md → detail/generate-document.md} +48 -25
- package/prompts/{check-structure-planning-result.md → structure/check-document-structure.md} +23 -17
- package/prompts/{document/structure-planning.md → structure/document-rules.md} +0 -2
- package/prompts/{structure-planning.md → structure/generate-structure.md} +51 -30
- package/prompts/{document → structure}/structure-example.md +2 -2
- package/prompts/{document → structure}/structure-getting-started.md +2 -2
- package/prompts/translate/glossary.md +6 -0
- package/prompts/{translator.md → translate/translate-document.md} +29 -10
- package/prompts/{feedback-refiner.md → utils/feedback-refiner.md} +8 -8
- package/tests/agents/chat/chat.test.mjs +46 -0
- package/tests/agents/generate/check-document-structure.test.mjs +51 -0
- package/tests/agents/generate/check-need-generate-structure.test.mjs +292 -0
- package/tests/agents/generate/generate-structure.test.mjs +51 -0
- package/tests/{input-generator.test.mjs → agents/init/init.test.mjs} +13 -13
- package/tests/agents/prefs/prefs.test.mjs +431 -0
- package/tests/agents/publish/publish-docs.test.mjs +642 -0
- package/tests/agents/translate/choose-language.test.mjs +311 -0
- package/tests/agents/translate/translate-document.test.mjs +51 -0
- package/tests/agents/update/check-document.test.mjs +523 -0
- package/tests/agents/update/generate-document.test.mjs +51 -0
- package/tests/agents/utils/action-success.test.mjs +54 -0
- package/tests/{check-detail-result.test.mjs → agents/utils/check-detail-result.test.mjs} +98 -98
- package/tests/agents/utils/check-feedback-refiner.test.mjs +478 -0
- package/tests/agents/utils/choose-docs.test.mjs +417 -0
- package/tests/agents/utils/exit.test.mjs +70 -0
- package/tests/agents/utils/feedback-refiner.test.mjs +51 -0
- package/tests/agents/utils/find-item-by-path.test.mjs +526 -0
- package/tests/agents/utils/find-user-preferences-by-path.test.mjs +382 -0
- package/tests/agents/utils/format-document-structure.test.mjs +264 -0
- package/tests/agents/utils/fs.test.mjs +267 -0
- package/tests/{load-sources.test.mjs → agents/utils/load-sources.test.mjs} +153 -25
- package/tests/{save-docs.test.mjs → agents/utils/save-docs.test.mjs} +11 -5
- package/tests/agents/utils/save-output.test.mjs +315 -0
- package/tests/agents/utils/save-single-doc.test.mjs +364 -0
- package/tests/agents/utils/transform-detail-datasources.test.mjs +363 -0
- package/tests/utils/auth-utils.test.mjs +358 -0
- package/tests/utils/blocklet.test.mjs +334 -0
- package/tests/{conflict-resolution.test.mjs → utils/conflict-detector.test.mjs} +3 -3
- package/tests/utils/constants.test.mjs +295 -0
- package/tests/utils/d2-utils.test.mjs +423 -0
- package/tests/{deploy.test.mjs → utils/deploy.test.mjs} +25 -36
- package/tests/utils/docs-finder-utils.test.mjs +625 -0
- package/tests/utils/file-utils.test.mjs +213 -0
- package/tests/{kroki-utils.test.mjs → utils/kroki-utils.test.mjs} +2 -2
- package/tests/utils/load-config.test.mjs +141 -0
- package/tests/{mermaid-validation.test.mjs → utils/mermaid-validator.test.mjs} +2 -2
- package/tests/utils/mock-chat-model.mjs +12 -0
- package/tests/{preferences-utils.test.mjs → utils/preferences-utils.test.mjs} +1 -1
- package/tests/{save-value-to-config.test.mjs → utils/save-value-to-config.test.mjs} +61 -4
- package/tests/utils/utils.test.mjs +939 -0
- package/utils/conflict-detector.mjs +1 -1
- package/utils/constants.mjs +5 -3
- package/utils/d2-utils.mjs +194 -0
- package/utils/docs-finder-utils.mjs +26 -26
- package/utils/icon-map.mjs +26 -0
- package/{agents → utils}/load-config.mjs +2 -18
- package/utils/markdown-checker.mjs +5 -5
- package/agents/batch-docs-detail-generator.yaml +0 -19
- package/agents/check-structure-planning-result.yaml +0 -30
- package/agents/content-detail-generator.yaml +0 -50
- package/agents/format-structure-plan.mjs +0 -25
- package/agents/reflective-structure-planner.yaml +0 -12
- package/agents/schema/structure-plan.yaml +0 -26
- package/prompts/document/custom-components.md +0 -104
- package/tests/README.md +0 -93
- package/tests/utils.test.mjs +0 -2067
- /package/agents/{exit.mjs → utils/exit.mjs} +0 -0
- /package/agents/{fs.mjs → utils/fs.mjs} +0 -0
- /package/agents/{save-output.mjs → utils/save-output.mjs} +0 -0
- /package/prompts/{document → detail}/d2-chart/official-examples.md +0 -0
- /package/prompts/{document → detail}/jsx/rules.md +0 -0
|
@@ -1,19 +1,23 @@
|
|
|
1
|
-
|
|
1
|
+
<role>
|
|
2
|
+
你是一位经验丰富的文档结构架构师,精通信息组织和逻辑梳理。你的专长在于深入理解各种形式的数据源(包括但不限于源代码、API定义、数据库 schema、配置信息、业务逻辑描述、用户故事等),并能从中提炼出核心信息和关键关联。
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
你的任务是根据用户提供的上下文和要求生成一个完整的结构规划。
|
|
4
|
+
你的任务是为即将生成的文档设计一份详尽的结构规划。这份规划将作为后续内容生成的“蓝图”,指导LLM如何组织和呈现信息,确保文档的逻辑清晰、易于理解、层级分明且全面覆盖。
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
关键能力与行为准则:
|
|
7
|
+
- 数据理解力: 能够解析和理解结构化和非结构化数据,识别其中的关键概念、实体、属性、关系和流程。
|
|
8
|
+
- 结构化思维: 具备强大的逻辑分析能力,能够将复杂信息分解为清晰的章节、小节和条目,并建立合理的层级关系。
|
|
9
|
+
- 用户导向: 能够根据用户提供的文档目标和受众特征,灵活调整结构规划的侧重点和详细程度。
|
|
10
|
+
- 模块化设计: 倾向于将文档划分为独立的、可复用的模块或章节,便于内容的填充和后续的维护。
|
|
11
|
+
- 灵活性与适应性: 能够处理多种类型的数据源,并根据数据源的特性(如代码的函数/类结构、API的端点/参数、文本的段落/主题)来设计最适合的文档结构。
|
|
12
|
+
- 清晰性与完整性: 确保最终的结构规划易于理解,能够指导LLM生成一份全面且有条理的文档。
|
|
7
13
|
|
|
8
|
-
结构规划需要包含设计中需要哪些{{nodeName}},{{nodeName}}之前的关联关系是什么。
|
|
9
14
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
每个{{nodeName}}需要包含:{{nodeName}}标题、一句话介绍这个{{nodeName}}展示的主要信息,信息的展示、组织方式要匹配目标受众。
|
|
15
|
+
目标:
|
|
16
|
+
- 这个结构规划应该合理且清晰的,能够比较全面的展示用户提供的上下文中信息,并向用户提供了合理的浏览路径。
|
|
17
|
+
- 每个{{nodeName}}需要包含:{{nodeName}}标题、一句话介绍这个{{nodeName}}展示的主要信息,信息的展示、组织方式要匹配目标受众。
|
|
13
18
|
|
|
14
19
|
永远遵循一个原则:你需要确保最终的结构规划需要符合用户的要求。
|
|
15
|
-
|
|
16
|
-
</goal>
|
|
20
|
+
</role>
|
|
17
21
|
|
|
18
22
|
<user_locale>
|
|
19
23
|
{{ locale }}
|
|
@@ -23,41 +27,54 @@
|
|
|
23
27
|
{{ datasources }}
|
|
24
28
|
</datasources>
|
|
25
29
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
30
|
+
{% if originalDocumentStructure %}
|
|
31
|
+
<last_document_structure>
|
|
32
|
+
{{originalDocumentStructure}}
|
|
33
|
+
</last_document_structure>
|
|
29
34
|
|
|
30
|
-
<
|
|
31
|
-
如果提供了上一轮生成的结构规划(
|
|
35
|
+
<last_document_structure_rule>
|
|
36
|
+
如果提供了上一轮生成的结构规划(last_document_structure),需要遵循以下规则:
|
|
32
37
|
1. **反馈的实现**:新的结构规划**必须**正确地实现用户反馈中要求的所有变更。
|
|
33
38
|
2. **无关节点的稳定性**:没有在用户反馈中被提及的节点 ** path、sourcesIds 属性不能被修改 **。`path`、`sourcesIds` 是关联现有内容的关键标识符,其稳定性至关重要。
|
|
34
39
|
理想情况下,其他属性(如 `title`、`description`)也应保持稳定,除非这些变更是由某个被要求的变更直接导致的,或者是 DataSource 变更导致。
|
|
35
|
-
</
|
|
40
|
+
</last_document_structure_rule>
|
|
41
|
+
{% endif %}
|
|
36
42
|
|
|
37
|
-
|
|
43
|
+
|
|
44
|
+
{% if feedback %}
|
|
45
|
+
<document_structure_user_feedback>
|
|
38
46
|
{{ feedback }}
|
|
39
|
-
</
|
|
47
|
+
</document_structure_user_feedback>
|
|
48
|
+
{% endif %}
|
|
40
49
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
50
|
+
{% if documentStructure %}
|
|
51
|
+
<review_document_structure>
|
|
52
|
+
{{ documentStructure }}
|
|
53
|
+
</review_document_structure>
|
|
54
|
+
{% endif %}
|
|
44
55
|
|
|
45
|
-
|
|
56
|
+
{% if structureReviewFeedback %}
|
|
57
|
+
<document_structure_review_feedback>
|
|
46
58
|
{{ structureReviewFeedback }}
|
|
47
|
-
</
|
|
59
|
+
</document_structure_review_feedback>
|
|
60
|
+
{% endif %}
|
|
48
61
|
|
|
62
|
+
{% if glossary %}
|
|
49
63
|
<terms>
|
|
50
64
|
专有词汇表,使用时请确保拼写正确。
|
|
51
65
|
|
|
52
66
|
{{glossary}}
|
|
53
67
|
</terms>
|
|
68
|
+
{% endif %}
|
|
54
69
|
|
|
70
|
+
{% if rules %}
|
|
55
71
|
<user_rules>
|
|
56
72
|
{{ rules }}
|
|
57
73
|
</user_rules>
|
|
74
|
+
{% endif %}
|
|
58
75
|
|
|
59
76
|
<conflict_resolution_guidance>
|
|
60
|
-
When users select potentially conflicting options, conflict resolution guidance will be provided in user_rules. Please carefully read these guidelines and implement the corresponding resolution strategies in the structure
|
|
77
|
+
When users select potentially conflicting options, conflict resolution guidance will be provided in user_rules. Please carefully read these guidelines and implement the corresponding resolution strategies in the document structure.
|
|
61
78
|
|
|
62
79
|
Core principles for conflict resolution:
|
|
63
80
|
1. **Layered need satisfaction**: Simultaneously satisfy multiple purposes and audiences through reasonable document structure hierarchy
|
|
@@ -70,9 +87,10 @@ Common conflict resolution patterns:
|
|
|
70
87
|
- **Audience conflicts**: Design role-oriented sections or paths
|
|
71
88
|
- **Depth conflicts**: Adopt progressive structures that allow users to choose appropriate depth levels
|
|
72
89
|
|
|
73
|
-
When
|
|
90
|
+
When generate document structure, prioritize conflict resolution strategies to ensure the final structure can harmoniously satisfy all user needs.
|
|
74
91
|
</conflict_resolution_guidance>
|
|
75
92
|
|
|
93
|
+
{% if userPreferences %}
|
|
76
94
|
<user_preferences>
|
|
77
95
|
{{userPreferences}}
|
|
78
96
|
|
|
@@ -80,8 +98,11 @@ When planning structure, prioritize conflict resolution strategies to ensure the
|
|
|
80
98
|
- 用户偏好来自用户之前操作中提供的反馈,生成结构规划中需要考虑用户的偏好,避免出现用户反馈的问题又重复出现
|
|
81
99
|
- 用户偏好的权重低于本次用户提交的反馈
|
|
82
100
|
</user_preferences>
|
|
101
|
+
{% endif %}
|
|
102
|
+
|
|
103
|
+
<document_structure_rules>
|
|
104
|
+
这份文档的目标受众是:{{targetAudience}}
|
|
83
105
|
|
|
84
|
-
<rules>
|
|
85
106
|
DataSources 使用规则:
|
|
86
107
|
1. 结构规划时要要尽可能的把 DataSources 中的信息合理的进行规划展示,不能遗漏
|
|
87
108
|
2. 用户可能提供的 DataSources 很少,这个时候你可以用你已知的信息进行补充,来完成结构规划
|
|
@@ -111,22 +132,22 @@ DataSources 使用规则:
|
|
|
111
132
|
2. 内容规划优先展示用户提供的 DataSources 中的信息,或者使用你拥有的知识进行补充,不可以随意虚构信息。
|
|
112
133
|
|
|
113
134
|
{% ifAsync docsType == 'general' %}
|
|
114
|
-
{% include "document
|
|
135
|
+
{% include "./document-rules.md" %}
|
|
115
136
|
|
|
116
137
|
{% endif %}
|
|
117
138
|
|
|
118
139
|
{% ifAsync docsType == 'getting-started' %}
|
|
119
|
-
{% include "
|
|
140
|
+
{% include "./structure-getting-started.md" %}
|
|
120
141
|
{% endif %}
|
|
121
142
|
|
|
122
143
|
其他:
|
|
123
144
|
|
|
124
145
|
1. 必须满足用户提出的规则
|
|
125
146
|
2. 使用用户的语言 {{locale}} 返回信息
|
|
126
|
-
|
|
147
|
+
</document_structure_rules>
|
|
127
148
|
|
|
128
149
|
{% ifAsync docsType == 'general' %}
|
|
129
|
-
{% include "
|
|
150
|
+
{% include "./structure-example.md" %}
|
|
130
151
|
{% endif %}
|
|
131
152
|
|
|
132
153
|
<output_rules>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<
|
|
1
|
+
<getting_started_document_structure_rules>
|
|
2
2
|
基于提供的数据源,规划一份 Getting Started 文档结构规划:
|
|
3
3
|
- 整个结构规划是完整且连续的,用户跟着文档一步步操作,可以完成一个可运行示例
|
|
4
4
|
- 每个部分文档完成一个相对完整的步骤,避免单个部分文档过长,用户阅读有压力
|
|
@@ -7,4 +7,4 @@
|
|
|
7
7
|
- 在示例中介绍项目的核心概念,目标是用户跟随文档完成示例后,对项目有一个比较完整清晰的理解
|
|
8
8
|
- 尽可能包含项目的功能、核心概念
|
|
9
9
|
|
|
10
|
-
</
|
|
10
|
+
</getting_started_document_structure_rules>
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
<role>
|
|
1
2
|
你是一位精通多种语言(尤其精通中文和英语)的专业翻译人员,擅长准确规范的双语转换。
|
|
3
|
+
</role>
|
|
2
4
|
|
|
5
|
+
|
|
6
|
+
<translation_rules>
|
|
3
7
|
翻译要求:
|
|
4
8
|
- **准确传达**原文的事实和背景,确保完整无遗漏。
|
|
5
9
|
- **避免夸张**,避免使用带有情绪化和主观色彩的词语(例如“激动”、“震惊”等)。
|
|
@@ -16,13 +20,9 @@
|
|
|
16
20
|
- **检查遗漏**:将原文与直译结果进行比较,纠正任何歪曲原文含义或遗漏的信息。
|
|
17
21
|
- **格式检查**:将原文与直译结果进行比较,确保翻译后的内容完整,如果原文是 markdown 格式,检查格式与原文相同。
|
|
18
22
|
- **最终输出**:输出优化后的翻译结果,确保符合上述要求(不要输出直译内容)。
|
|
23
|
+
</translation_rules>
|
|
19
24
|
|
|
20
|
-
|
|
21
|
-
<glossary>
|
|
22
|
-
- Agent:指能够自主执行任务的系统或程序。
|
|
23
|
-
- AIGNE: AIGNE 是一个开源的 AI 代理框架,旨在简化 AI 代理的开发和部署。
|
|
24
|
-
- InputSchema/OutputSchema: 输入/输出结构,指用于定义输入/输出数据格式的结构化描述。
|
|
25
|
-
</glossary>
|
|
25
|
+
{% include "./glossary.md" %}
|
|
26
26
|
|
|
27
27
|
保留术语(不翻译):
|
|
28
28
|
<terms>
|
|
@@ -56,19 +56,37 @@
|
|
|
56
56
|
**特别注意**: table 的分隔线 `|---|---|---|` 保持原文不要修改
|
|
57
57
|
</example>
|
|
58
58
|
|
|
59
|
+
<example>
|
|
60
|
+
|
|
61
|
+
<before_translate>
|
|
62
|
+
<x-field data-name="teamDid" data-type="string" data-required="true" data-desc="The DID of the team or Blocklet managing the webhook."></x-field>
|
|
63
|
+
</before_translate>
|
|
64
|
+
|
|
65
|
+
<after_translate>
|
|
66
|
+
<x-field data-name="teamDid" data-type="string" data-required="true" data-desc="管理 Webhook 的团队或 Blocklet 的 DID。"></x-field>
|
|
67
|
+
</after_translate>
|
|
68
|
+
|
|
69
|
+
**特别注意**: x-field 组件的所有属性都需要保持原文格式,只翻译 data-desc 属性中的描述内容
|
|
70
|
+
</example>
|
|
71
|
+
|
|
59
72
|
原文如下:
|
|
60
73
|
<content>
|
|
61
74
|
{{content}}
|
|
62
75
|
</content>
|
|
63
76
|
|
|
64
|
-
|
|
77
|
+
{% if feedback %}
|
|
78
|
+
<translation_user_feedback>
|
|
65
79
|
{{ feedback }}
|
|
66
|
-
</
|
|
80
|
+
</translation_user_feedback>
|
|
81
|
+
{% endif %}
|
|
67
82
|
|
|
68
|
-
|
|
83
|
+
{% if detailFeedback %}
|
|
84
|
+
<translation_review_feedback>
|
|
69
85
|
{{ detailFeedback }}
|
|
70
|
-
</
|
|
86
|
+
</translation_review_feedback>
|
|
87
|
+
{% endif %}
|
|
71
88
|
|
|
89
|
+
{% if userPreferences %}
|
|
72
90
|
<user_preferences>
|
|
73
91
|
{{userPreferences}}
|
|
74
92
|
|
|
@@ -76,6 +94,7 @@
|
|
|
76
94
|
- 用户偏好来自用户之前操作中提供的反馈,生成结构规划中需要考虑用户的偏好,避免出现用户反馈的问题又重复出现
|
|
77
95
|
- 用户偏好的权重低于本次用户提交的反馈
|
|
78
96
|
</user_preferences>
|
|
97
|
+
{% endif %}
|
|
79
98
|
|
|
80
99
|
指令:
|
|
81
100
|
请将 <content> 中的内容(不包含最外层的 <content> 标签) **准确** 地翻译成 **{{ language }}**,并严格遵循翻译要求。
|
|
@@ -5,7 +5,7 @@ and determine whether it needs **persistent saving**, along with its scope (glob
|
|
|
5
5
|
|
|
6
6
|
<input>
|
|
7
7
|
- feedback: {{feedback}}
|
|
8
|
-
- stage: {{stage}} # Possible values:
|
|
8
|
+
- stage: {{stage}} # Possible values: document_structure | document_refine | translation_refine
|
|
9
9
|
- paths: {{paths}} # Array of paths input in current command (can be empty). Used only to determine whether to "limit to these paths". Do not include them in output.
|
|
10
10
|
- existingPreferences: {{existingPreferences}} # Currently saved user preference rules
|
|
11
11
|
</input>
|
|
@@ -14,7 +14,7 @@ and determine whether it needs **persistent saving**, along with its scope (glob
|
|
|
14
14
|
Scope determination heuristic rules:
|
|
15
15
|
|
|
16
16
|
**Classification by stage**:
|
|
17
|
-
- If stage=
|
|
17
|
+
- If stage=document_structure: Default `scope="structure"`, unless feedback is clearly global writing/tone/exclusion policy (then use `global`).
|
|
18
18
|
- If stage=document_refine: Default `scope="document"`; if feedback is general writing policy or exclusion strategy that doesn't depend on specific pages, can be elevated to `global`.
|
|
19
19
|
- If stage=translation_refine: Default `scope="translation"`; if feedback is general translation policy, maintain this scope.
|
|
20
20
|
|
|
@@ -57,19 +57,19 @@ Rule writing requirements:
|
|
|
57
57
|
- Example: "Write for beginners; terms must be given clear explanations on first appearance."
|
|
58
58
|
</rule_format>
|
|
59
59
|
|
|
60
|
-
<
|
|
60
|
+
<output_rules>
|
|
61
61
|
Return a complete JSON object with a `reason` field explaining *why* you are setting `save` to true or false, and how you derived the rule and scope.
|
|
62
62
|
Return the summarized rule in the same language as the feedback in user input.
|
|
63
|
-
</
|
|
63
|
+
</output_rules>
|
|
64
64
|
|
|
65
|
-
<
|
|
65
|
+
<feedback_processing_examples>
|
|
66
66
|
Example 1 (Keyword Preservation):
|
|
67
67
|
- Input: stage=document_refine, paths=["examples/demo.md"], feedback="Do not use ellipsis in the spaceDid part of endpoint strings used in demo"
|
|
68
68
|
- Output:
|
|
69
69
|
{"rule":"Endpoint strings with 'spaceDid' in code examples should not use ellipsis for abbreviation.","scope":"document","save":true,"limitToInputPaths":true,"reason":"The feedback is about a specific keyword 'spaceDid' in endpoint strings being abbreviated. This is a recurring style issue that should be a policy. It's a reusable rule, so `save` is `true`. The rule preserves the keyword 'spaceDid' as it's the subject of the instruction."}
|
|
70
70
|
|
|
71
71
|
Example 2:
|
|
72
|
-
- Input: stage=
|
|
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
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`."}
|
|
75
75
|
|
|
@@ -94,7 +94,7 @@ Example 6 (Non-duplication):
|
|
|
94
94
|
{"rule":"Code comments must be written in English.","scope":"document","save":true,"limitToInputPaths":false,"reason":"The feedback is about the language of code comments. The existing rule is about code minimalism and does not cover comment language. This is a new, non-overlapping rule. Thus, it should be saved. `save` is `true`."}
|
|
95
95
|
|
|
96
96
|
Example 7 (Deletion Handling):
|
|
97
|
-
- Input: stage=
|
|
97
|
+
- Input: stage=document_structure, paths=[], feedback="The 'Legacy API Reference' document is outdated and should be removed."
|
|
98
98
|
- Output:
|
|
99
99
|
{"rule":"Do not generate documents or sections for outdated 'Legacy API Reference'.","scope":"structure","save":true,"limitToInputPaths":false,"reason":"The feedback is about removing outdated content. Following deletion handling rules, this becomes a preventative instruction for future document generation. This is a reusable policy to avoid generating outdated content, so `save` is `true`."}
|
|
100
100
|
|
|
@@ -102,4 +102,4 @@ Example 8 (Path-limited Deletion Rule):
|
|
|
102
102
|
- Input: stage=document_refine, paths=["overview.md"], feedback="Remove contribution-related content from overview"
|
|
103
103
|
- Output:
|
|
104
104
|
{"rule":"Do not include contribution-related content in 'overview' document.","scope":"document","save":true,"limitToInputPaths":true,"reason":"This feedback specifies content that should not appear in a specific document type ('overview'). While it's about removing content, we convert it to a preventative rule. It's worth saving as it defines a clear content boundary for overview documents, but should be limited to overview files only. Therefore `save` is `true` with `limitToInputPaths` also `true`."}
|
|
105
|
-
</
|
|
105
|
+
</feedback_processing_examples>
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { afterAll, beforeAll, describe, expect, test } from "bun:test";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { AIAgent } from "@aigne/core";
|
|
4
|
+
import { loadAgent } from "@aigne/core/loader/index.js";
|
|
5
|
+
import { loadModel } from "../../utils/mock-chat-model.mjs";
|
|
6
|
+
|
|
7
|
+
describe("chat Agent", () => {
|
|
8
|
+
beforeAll(() => {
|
|
9
|
+
process.env.AIGNE_OBSERVABILITY_DISABLED = "true";
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
afterAll(() => {
|
|
13
|
+
delete process.env.AIGNE_OBSERVABILITY_DISABLED;
|
|
14
|
+
});
|
|
15
|
+
test("should load agent correctly with proper configuration", async () => {
|
|
16
|
+
const agent = await loadAgent(join(import.meta.dirname, "../../../agents/chat/index.yaml"), {
|
|
17
|
+
model: loadModel,
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
expect(agent).toBeDefined();
|
|
21
|
+
|
|
22
|
+
// Verify agent exists and is correct type
|
|
23
|
+
expect(agent).toBeDefined();
|
|
24
|
+
expect(agent).toBeInstanceOf(AIAgent);
|
|
25
|
+
expect(agent.name).toBe("chat");
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
test("should have instructions loaded correctly", async () => {
|
|
29
|
+
const agent = await loadAgent(join(import.meta.dirname, "../../../agents/chat/index.yaml"), {
|
|
30
|
+
model: loadModel,
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
expect(agent).toBeDefined();
|
|
34
|
+
|
|
35
|
+
// Verify instructions are loaded
|
|
36
|
+
expect(agent.instructions).toBeDefined();
|
|
37
|
+
const instructions = await agent.instructions.build({});
|
|
38
|
+
expect(instructions.messages).toBeDefined();
|
|
39
|
+
expect(instructions.messages.length).toBeGreaterThan(0);
|
|
40
|
+
|
|
41
|
+
// The instructions should contain content from the inline instructions
|
|
42
|
+
const systemMessage = instructions.messages.find((m) => m.role === "system");
|
|
43
|
+
expect(systemMessage).toBeDefined();
|
|
44
|
+
expect(systemMessage.content).toContain("document generation assistant");
|
|
45
|
+
});
|
|
46
|
+
});
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { afterAll, beforeAll, describe, expect, test } from "bun:test";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { AIAgent } from "@aigne/core";
|
|
4
|
+
import { loadAgent } from "@aigne/core/loader/index.js";
|
|
5
|
+
import { loadModel } from "../../utils/mock-chat-model.mjs";
|
|
6
|
+
|
|
7
|
+
describe("checkDocumentStructure Agent", () => {
|
|
8
|
+
beforeAll(() => {
|
|
9
|
+
process.env.AIGNE_OBSERVABILITY_DISABLED = "true";
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
afterAll(() => {
|
|
13
|
+
delete process.env.AIGNE_OBSERVABILITY_DISABLED;
|
|
14
|
+
});
|
|
15
|
+
test("should load agent correctly with proper configuration", async () => {
|
|
16
|
+
const agent = await loadAgent(
|
|
17
|
+
join(import.meta.dirname, "../../../agents/generate/check-document-structure.yaml"),
|
|
18
|
+
{
|
|
19
|
+
model: loadModel,
|
|
20
|
+
},
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
expect(agent).toBeDefined();
|
|
24
|
+
|
|
25
|
+
// Verify agent exists and is correct type
|
|
26
|
+
expect(agent).toBeDefined();
|
|
27
|
+
expect(agent).toBeInstanceOf(AIAgent);
|
|
28
|
+
expect(agent.name).toBe("checkDocumentStructure");
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
test("should have instructions loaded from file", async () => {
|
|
32
|
+
const agent = await loadAgent(
|
|
33
|
+
join(import.meta.dirname, "../../../agents/generate/check-document-structure.yaml"),
|
|
34
|
+
{
|
|
35
|
+
model: loadModel,
|
|
36
|
+
},
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
expect(agent).toBeDefined();
|
|
40
|
+
|
|
41
|
+
// Verify instructions are loaded
|
|
42
|
+
expect(agent.instructions).toBeDefined();
|
|
43
|
+
const instructions = await agent.instructions.build({});
|
|
44
|
+
expect(instructions.messages).toBeDefined();
|
|
45
|
+
expect(instructions.messages.length).toBeGreaterThan(0);
|
|
46
|
+
|
|
47
|
+
// The instructions should contain content from the prompt file
|
|
48
|
+
const systemMessage = instructions.messages.find((m) => m.role === "system");
|
|
49
|
+
expect(systemMessage).toBeDefined();
|
|
50
|
+
});
|
|
51
|
+
});
|