@aigne/doc-smith 0.8.10-beta → 0.8.10-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/.aigne/doc-smith/config.yaml +3 -1
- package/.aigne/doc-smith/preferences.yml +4 -4
- package/.aigne/doc-smith/upload-cache.yaml +180 -0
- package/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +22 -0
- package/README.md +2 -2
- package/RELEASE.md +3 -3
- package/agents/generate/check-need-generate-structure.mjs +40 -18
- package/agents/generate/index.yaml +7 -0
- package/agents/generate/user-review-document-structure.mjs +173 -0
- package/agents/init/index.mjs +5 -11
- package/agents/update/generate-and-translate-document.yaml +3 -3
- package/agents/utils/check-feedback-refiner.mjs +2 -0
- package/agents/utils/save-docs.mjs +16 -22
- package/aigne.yaml +1 -0
- package/docs/advanced-how-it-works.md +26 -24
- package/docs/advanced-how-it-works.zh.md +32 -30
- package/docs/advanced-quality-assurance.md +6 -9
- package/docs/advanced-quality-assurance.zh.md +19 -22
- package/docs/cli-reference.md +35 -76
- package/docs/cli-reference.zh.md +48 -89
- package/docs/configuration-interactive-setup.md +18 -18
- package/docs/configuration-interactive-setup.zh.md +33 -33
- package/docs/configuration-language-support.md +12 -12
- package/docs/configuration-language-support.zh.md +20 -20
- package/docs/configuration-llm-setup.md +14 -13
- package/docs/configuration-llm-setup.zh.md +16 -15
- package/docs/configuration-preferences.md +22 -27
- package/docs/configuration-preferences.zh.md +35 -40
- package/docs/configuration.md +31 -45
- package/docs/configuration.zh.md +48 -62
- package/docs/features-generate-documentation.md +6 -7
- package/docs/features-generate-documentation.zh.md +21 -22
- package/docs/features-publish-your-docs.md +38 -30
- package/docs/features-publish-your-docs.zh.md +45 -37
- package/docs/features-translate-documentation.md +14 -74
- package/docs/features-translate-documentation.zh.md +19 -79
- package/docs/features-update-and-refine.md +19 -18
- package/docs/features-update-and-refine.zh.md +33 -32
- package/docs-mcp/get-docs-structure.mjs +1 -1
- package/package.json +9 -9
- package/prompts/detail/custom/custom-components.md +113 -18
- package/prompts/detail/detail-example.md +58 -65
- package/prompts/detail/document-rules.md +2 -1
- package/prompts/structure/check-document-structure.md +11 -15
- package/prompts/translate/translate-document.md +20 -9
- package/tests/agents/generate/check-need-generate-structure.test.mjs +21 -24
- package/tests/agents/generate/user-review-document-structure.test.mjs +294 -0
- package/tests/agents/init/init.test.mjs +2 -8
- package/utils/auth-utils.mjs +2 -2
|
@@ -63,21 +63,20 @@
|
|
|
63
63
|
|
|
64
64
|
**Parameters**
|
|
65
65
|
|
|
66
|
-
<x-field
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
<x-field data-name="interval_count" data-type="number" data-required="true" data-desc="The number of intervals between each billing"></x-field>
|
|
66
|
+
<x-field-group>
|
|
67
|
+
<x-field data-name="name" data-type="string" data-required="true" data-desc="The name of the product."></x-field>
|
|
68
|
+
<x-field data-name="description" data-type="string" data-required="false" data-desc="An optional description for the product."></x-field>
|
|
69
|
+
<x-field data-name="type" data-type="string" data-required="false" data-desc="The type of product (e.g., 'service', 'good')."></x-field>
|
|
70
|
+
<x-field data-name="prices" data-type="Partial<TPrice>[]" data-required="false" data-desc="An optional array of partial price objects to associate with the product upon creation">
|
|
71
|
+
<x-field data-name="type" data-type="string" data-required="true" data-desc="The type of price (e.g., 'recurring', 'one_time')"></x-field>
|
|
72
|
+
<x-field data-name="unit_amount" data-type="string" data-required="true" data-desc="The price amount as a string"></x-field>
|
|
73
|
+
<x-field data-name="currency_id" data-type="string" data-required="true" data-desc="The currency identifier"></x-field>
|
|
74
|
+
<x-field data-name="recurring" data-type="object" data-required="false" data-desc="Recurring price configuration">
|
|
75
|
+
<x-field data-name="interval" data-type="string" data-required="true" data-desc="The billing interval (e.g., 'month', 'year')"></x-field>
|
|
76
|
+
<x-field data-name="interval_count" data-type="number" data-required="true" data-desc="The number of intervals between each billing"></x-field>
|
|
77
|
+
</x-field>
|
|
79
78
|
</x-field>
|
|
80
|
-
</x-field>
|
|
79
|
+
</x-field-group>
|
|
81
80
|
|
|
82
81
|
**Returns**
|
|
83
82
|
|
|
@@ -169,10 +168,11 @@
|
|
|
169
168
|
Use the `update` method to modify an existing product's details.
|
|
170
169
|
|
|
171
170
|
**Parameters**
|
|
172
|
-
|
|
173
|
-
<x-field
|
|
174
|
-
|
|
175
|
-
|
|
171
|
+
|
|
172
|
+
<x-field-group>
|
|
173
|
+
<x-field data-name="id" data-type="string" data-required="true" data-desc="The unique identifier of the product to update."></x-field>
|
|
174
|
+
<x-field data-name="data" data-type="Partial<TProduct>" data-required="true" data-desc="An object containing the product fields to update. Available fields include name, description, type, etc."></x-field>
|
|
175
|
+
</x-field-group>
|
|
176
176
|
|
|
177
177
|
**Returns**
|
|
178
178
|
|
|
@@ -213,31 +213,25 @@
|
|
|
213
213
|
|
|
214
214
|
**Parameters**
|
|
215
215
|
|
|
216
|
-
<x-field
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
<x-field data-name="pageSize" data-type="number" data-default="50" data-required="false" data-desc="Optional. The number of items per page (default: 50)."></x-field>
|
|
227
|
-
|
|
228
|
-
<x-field data-name="order" data-type="string" data-required="false" data-desc="Optional. Sort order (e.g., 'created_at:ASC', 'updated_at:DESC')."></x-field>
|
|
229
|
-
|
|
230
|
-
<x-field data-name="activeFirst" data-type="boolean" data-required="false" data-desc="Optional. If true, active products are listed first."></x-field>
|
|
216
|
+
<x-field-group>
|
|
217
|
+
<x-field data-name="active" data-type="boolean" data-required="false" data-desc="Optional. Filter by product active status."></x-field>
|
|
218
|
+
<x-field data-name="name" data-type="string" data-required="false" data-desc="Optional. Filter by product name."></x-field>
|
|
219
|
+
<x-field data-name="description" data-type="string" data-required="false" data-desc="Optional. Filter by product description."></x-field>
|
|
220
|
+
<x-field data-name="metadata.{key}" data-type="string" data-required="false" data-desc="Optional. Filter by custom metadata fields. Use metadata.yourKey to specify a metadata property."></x-field>
|
|
221
|
+
<x-field data-name="page" data-type="number" data-default="1" data-required="false" data-desc="Optional. The page number for pagination (default: 1)."></x-field>
|
|
222
|
+
<x-field data-name="pageSize" data-type="number" data-default="50" data-required="false" data-desc="Optional. The number of items per page (default: 50)."></x-field>
|
|
223
|
+
<x-field data-name="order" data-type="string" data-required="false" data-desc="Optional. Sort order (e.g., 'created_at:ASC', 'updated_at:DESC')."></x-field>
|
|
224
|
+
<x-field data-name="activeFirst" data-type="boolean" data-required="false" data-desc="Optional. If true, active products are listed first."></x-field>
|
|
225
|
+
</x-field-group>
|
|
231
226
|
|
|
232
227
|
**Returns**
|
|
233
228
|
|
|
234
|
-
<x-field
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
<x-field data-name="total" data-type="number" data-desc="The total number of products matching the criteria."></x-field>
|
|
229
|
+
<x-field-group>
|
|
230
|
+
<x-field data-name="data" data-type="TProductExpanded[]" data-desc="An array of product objects."></x-field>
|
|
231
|
+
<x-field data-name="page" data-type="number" data-desc="The current page number."></x-field>
|
|
232
|
+
<x-field data-name="pageSize" data-type="number" data-desc="The number of items per page."></x-field>
|
|
233
|
+
<x-field data-name="total" data-type="number" data-desc="The total number of products matching the criteria."></x-field>
|
|
234
|
+
</x-field-group>
|
|
241
235
|
|
|
242
236
|
**Example**
|
|
243
237
|
|
|
@@ -286,21 +280,20 @@
|
|
|
286
280
|
|
|
287
281
|
**Parameters**
|
|
288
282
|
|
|
289
|
-
<x-field
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
283
|
+
<x-field-group>
|
|
284
|
+
<x-field data-name="query" data-type="string" data-required="true" data-desc="The search string to match against product fields."></x-field>
|
|
285
|
+
<x-field data-name="page" data-type="number" data-default="1" data-required="false" data-desc="Optional. The page number for pagination (default: 1)."></x-field>
|
|
286
|
+
<x-field data-name="pageSize" data-type="number" data-default="50" data-required="false" data-desc="Optional. The number of items per page (default: 50)."></x-field>
|
|
287
|
+
</x-field-group>
|
|
294
288
|
|
|
295
289
|
**Returns**
|
|
296
290
|
|
|
297
|
-
<x-field
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
<x-field data-name="total" data-type="number" data-desc="The total number of products matching the criteria."></x-field>
|
|
291
|
+
<x-field-group>
|
|
292
|
+
<x-field data-name="data" data-type="TProductExpanded[]" data-desc="An array of product objects that match the search query."></x-field>
|
|
293
|
+
<x-field data-name="page" data-type="number" data-desc="The current page number."></x-field>
|
|
294
|
+
<x-field data-name="pageSize" data-type="number" data-desc="The number of items per page."></x-field>
|
|
295
|
+
<x-field data-name="total" data-type="number" data-desc="The total number of products matching the criteria."></x-field>
|
|
296
|
+
</x-field-group>
|
|
304
297
|
|
|
305
298
|
**Example**
|
|
306
299
|
|
|
@@ -426,19 +419,19 @@
|
|
|
426
419
|
|
|
427
420
|
**UserContext**
|
|
428
421
|
|
|
429
|
-
<x-field
|
|
430
|
-
<x-field data-name="
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
422
|
+
<x-field-group>
|
|
423
|
+
<x-field data-name="user" data-type="object" data-required="true" data-desc="Current user information">
|
|
424
|
+
<x-field data-name="id" data-type="string" data-required="true" data-desc="User unique identifier"></x-field>
|
|
425
|
+
<x-field data-name="name" data-type="string" data-required="true" data-desc="User display name"></x-field>
|
|
426
|
+
<x-field data-name="email" data-type="string" data-required="true" data-desc="User email address"></x-field>
|
|
427
|
+
<x-field data-name="role" data-type="string" data-default="user" data-desc="User role (user, admin, moderator)"></x-field>
|
|
428
|
+
</x-field>
|
|
429
|
+
<x-field data-name="session" data-type="object" data-required="true" data-desc="Current session information">
|
|
430
|
+
<x-field data-name="token" data-type="string" data-required="true" data-desc="Session authentication token"></x-field>
|
|
431
|
+
<x-field data-name="expiresAt" data-type="number" data-required="true" data-desc="Session expiration timestamp"></x-field>
|
|
432
|
+
</x-field>
|
|
433
|
+
<x-field data-name="permissions" data-type="array" data-required="false" data-desc="User permissions list"></x-field>
|
|
434
|
+
</x-field-group>
|
|
442
435
|
|
|
443
436
|
---
|
|
444
437
|
|
|
@@ -13,9 +13,10 @@
|
|
|
13
13
|
- 每个 section 需要包含:标题、介绍、代码示例、响应数据示例、示例说明,示例说明跟在示例代码后描述,不需要‘示例说明’这样的小标题
|
|
14
14
|
- 确保文档中的内容是完整、连贯的,用户可以跟着文档一步步顺利执行
|
|
15
15
|
- 说明要尽可能的详细,如果存在配置项或参数,需要解释每个配置项或参数的含义,如果参数有多个可选值,每种可选值需要解释其含义,并尽可能配上代码示例
|
|
16
|
-
- 参数、返回值、上下文数据(Context)、Props
|
|
16
|
+
- 参数、返回值、上下文数据(Context)、Props 以及其它与类型相关的内容优先使用 `<x-field>` 自定义组件来展示,支持嵌套结构来清晰描述复杂数据类型
|
|
17
17
|
- 对于复杂对象类型,使用嵌套的 `<x-field>` 结构来递归描述参数结构,嵌套层级不超过 5 级
|
|
18
18
|
- 所有类型都使用开闭标签格式 `<x-field ...></x-field>`,简单类型 children 为空,复杂类型包含嵌套字段
|
|
19
|
+
- 描述同一个对象的多个最外层的 `<x-field>` 元素应该用 `<x-field-group>` 元素包裹。注意内嵌的 `<x-field>` 不需要包裹
|
|
19
20
|
- 接口/方法调用的说明必须包含 **响应数据示例**
|
|
20
21
|
- 对于其他类型的列表数据,数据内容简单,优先使用 markdown 中的 table 来展示,让内容看上去更整齐,容易阅读
|
|
21
22
|
- 对输出的 markdown 进行检查,确认输出内容完整,table、d2 信息完整并且格式正确
|
|
@@ -5,29 +5,25 @@
|
|
|
5
5
|
<context>
|
|
6
6
|
- **上一轮的结构规划 (originalDocumentStructure)**:
|
|
7
7
|
<original_document_structure>
|
|
8
|
-
```json
|
|
9
8
|
{{ originalDocumentStructure }}
|
|
10
|
-
```
|
|
11
9
|
</original_document_structure>
|
|
12
10
|
|
|
13
|
-
- **新生成的结构规划 (documentStructure)**:
|
|
14
|
-
<document_structure>
|
|
15
|
-
```json
|
|
16
|
-
{{ documentStructure }}
|
|
17
|
-
```
|
|
18
|
-
</document_structure>
|
|
19
|
-
|
|
20
11
|
{% if feedback %}
|
|
21
12
|
- **用户反馈**:
|
|
22
13
|
```
|
|
23
14
|
{{ feedback }}
|
|
24
15
|
```
|
|
25
16
|
{% endif %}
|
|
17
|
+
|
|
18
|
+
- **新生成的结构规划 (documentStructure)**:
|
|
19
|
+
<document_structure>
|
|
20
|
+
{{ documentStructure }}
|
|
21
|
+
</document_structure>
|
|
26
22
|
</context>
|
|
27
23
|
|
|
28
24
|
<goal>
|
|
29
25
|
你的主要目标是验证三条关键规则:
|
|
30
|
-
1.
|
|
26
|
+
1. **反馈的实现**:新的结构规划(document_structure)**必须**正确地实现用户反馈中要求的所有变更。
|
|
31
27
|
2. **无关节点的稳定性**:没有在用户反馈中被提及的节点 ** path、sourcesIds 属性不能被修改 **
|
|
32
28
|
- `path`、`sourcesIds` 是关联现有内容的关键标识符,其稳定性至关重要。
|
|
33
29
|
- 对于用户要求新增节点的场景,新增的节点可能会影响原来节点的顺序,这是允许的。
|
|
@@ -36,17 +32,17 @@
|
|
|
36
32
|
|
|
37
33
|
<quality_control_rules>
|
|
38
34
|
### 场景 1:首次运行(没有旧的规划)
|
|
39
|
-
如果 `
|
|
35
|
+
如果 `original_document_structure` 为 null、为空或未提供,这意味着这是第一次生成结构。没有可供比较的对象。
|
|
40
36
|
你的检查自动通过。
|
|
41
37
|
|
|
42
38
|
### 场景 2:迭代运行(存在旧的规划)
|
|
43
39
|
这是主要场景。你必须执行详细的比较。
|
|
44
40
|
|
|
45
41
|
**分步分析**:
|
|
46
|
-
1.
|
|
47
|
-
2.
|
|
48
|
-
3. **验证无关节点的稳定性**:这是最关键的检查。遍历 `
|
|
49
|
-
* **至关重要**:其 `path`、`sourcesIds` 属性**必须**与 `
|
|
42
|
+
1. **分析反馈**:仔细阅读并理解中用户反馈提出的每一项变更要求。明确哪些节点是需要被修改、添加或删除的目标。
|
|
43
|
+
2. **验证反馈的实现**:确认所要求的变更在`document_structure`已执行。例如,如果反馈是“移除‘示例’部分”,你必须检查该部分在 `document_structure` 中是否已不存在。
|
|
44
|
+
3. **验证无关节点的稳定性**:这是最关键的检查。遍历 `document_structure` 中的所有节点。对于每一个在 `original_document_structure` 中也存在、但并未在反馈中被提及的节点:
|
|
45
|
+
* **至关重要**:其 `path`、`sourcesIds` 属性**必须**与 `original_document_structure` 中的完全相同。
|
|
50
46
|
* 理想情况下,其他属性(如 `title`、`description`)也应保持稳定,除非这些变更是由某个被要求的变更直接导致的,或者是 DataSource 变更导致。
|
|
51
47
|
</quality_control_rules>
|
|
52
48
|
|
|
@@ -2,30 +2,32 @@
|
|
|
2
2
|
你是一位精通多种语言(尤其精通中文和英语)的专业翻译人员,擅长准确规范的双语转换。
|
|
3
3
|
</role>
|
|
4
4
|
|
|
5
|
-
|
|
6
5
|
<translation_rules>
|
|
7
6
|
翻译要求:
|
|
7
|
+
|
|
8
8
|
- **准确传达**原文的事实和背景,确保完整无遗漏。
|
|
9
9
|
- **避免夸张**,避免使用带有情绪化和主观色彩的词语(例如“激动”、“震惊”等)。
|
|
10
10
|
- **遵守语言规范**,确保标点符号和语法正确,表达自然流畅。
|
|
11
11
|
- **保留原文结构**,仅翻译内容部分,不添加或修改标签,不添加额外内容或标点符号。不要在最外层添加 markdown 语法。确保翻译后结构和原文相同,原文中的换行、空白行也要保留。
|
|
12
|
-
- **严格保护 Markdown 语法**:Markdown 的所有语法字符,包括但不限于表格中的 `|` 和 `-`、列表中的 `*` 和 `-`、标题的 `#`、代码块的
|
|
12
|
+
- **严格保护 Markdown 语法**:Markdown 的所有语法字符,包括但不限于表格中的 `|` 和 `-`、列表中的 `*` 和 `-`、标题的 `#`、代码块的 `` ` `` 等,都必须**原样复制**,不得进行任何形式的修改、增删或合并。特别是表格的分隔线(例如 `|---|---|---|`),必须与原文的列数和格式完全一致,且表格的分隔线与表格数据列数相同。
|
|
13
13
|
- **遵循翻译流程**,包括直译、优化和检查遗漏,确保最终输出符合要求。
|
|
14
14
|
- **使用术语参考**,确保专业术语的准确性和一致性。
|
|
15
15
|
- **保留术语**,保留特定术语的原文形式,避免翻译。
|
|
16
16
|
|
|
17
17
|
翻译过程:
|
|
18
|
+
|
|
18
19
|
- **直译**:将原文逐字逐句翻译成目标语言,确保每个词语的含义都被准确传达。
|
|
19
20
|
- **优化**:在直译结果的基础上,确保译文在忠实于原文含义的同时更加通俗易懂,并符合 **{{ language }}** 的表达习惯。
|
|
20
21
|
- **检查遗漏**:将原文与直译结果进行比较,纠正任何歪曲原文含义或遗漏的信息。
|
|
21
22
|
- **格式检查**:将原文与直译结果进行比较,确保翻译后的内容完整,如果原文是 markdown 格式,检查格式与原文相同。
|
|
22
23
|
- **最终输出**:输出优化后的翻译结果,确保符合上述要求(不要输出直译内容)。
|
|
23
|
-
</translation_rules>
|
|
24
|
+
</translation_rules>
|
|
24
25
|
|
|
25
26
|
{% include "./glossary.md" %}
|
|
26
27
|
|
|
27
28
|
保留术语(不翻译):
|
|
28
29
|
<terms>
|
|
30
|
+
|
|
29
31
|
- Agent(所有 Agent 或带有 Agent 前缀或后缀的术语均不翻译)
|
|
30
32
|
|
|
31
33
|
{{glossary}}
|
|
@@ -33,9 +35,9 @@
|
|
|
33
35
|
|
|
34
36
|
双语术语(使用 `原文 (翻译)` 格式):
|
|
35
37
|
<bilingual-terms>
|
|
36
|
-
- Guide Rails: 行为导轨
|
|
37
|
-
</bilingual-terms>
|
|
38
38
|
|
|
39
|
+
- Guide Rails: 行为导轨
|
|
40
|
+
</bilingual-terms>
|
|
39
41
|
|
|
40
42
|
<example>
|
|
41
43
|
<before_translate>
|
|
@@ -62,11 +64,19 @@
|
|
|
62
64
|
<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
65
|
</before_translate>
|
|
64
66
|
|
|
67
|
+
<x-field data-name="apiKey" data-type="string" data-required="true">
|
|
68
|
+
<x-field-desc markdown>Your **API key** for authentication. Generate one from the `Settings > API Keys` section.</x-field-desc>
|
|
69
|
+
</x-field>
|
|
70
|
+
|
|
65
71
|
<after_translate>
|
|
66
72
|
<x-field data-name="teamDid" data-type="string" data-required="true" data-desc="管理 Webhook 的团队或 Blocklet 的 DID。"></x-field>
|
|
73
|
+
|
|
74
|
+
<x-field data-name="apiKey" data-type="string" data-required="true">
|
|
75
|
+
<x-field-desc markdown>您的 **API 密钥**,用于身份验证。请从 `设置 > API 密钥` 部分生成一个。</x-field-desc>
|
|
76
|
+
</x-field>
|
|
67
77
|
</after_translate>
|
|
68
78
|
|
|
69
|
-
**特别注意**: x-field 组件的所有属性都需要保持原文格式,只翻译 data-desc
|
|
79
|
+
**特别注意**: x-field 组件的所有属性都需要保持原文格式,只翻译 data-desc 属性中或 x-field-desc 元素中的描述内容
|
|
70
80
|
</example>
|
|
71
81
|
|
|
72
82
|
原文如下:
|
|
@@ -91,10 +101,11 @@
|
|
|
91
101
|
{{userPreferences}}
|
|
92
102
|
|
|
93
103
|
用户偏好使用规则:
|
|
104
|
+
|
|
94
105
|
- 用户偏好来自用户之前操作中提供的反馈,生成结构规划中需要考虑用户的偏好,避免出现用户反馈的问题又重复出现
|
|
95
106
|
- 用户偏好的权重低于本次用户提交的反馈
|
|
96
|
-
</user_preferences>
|
|
97
|
-
{% endif %}
|
|
107
|
+
</user_preferences>
|
|
108
|
+
{% endif %}
|
|
98
109
|
|
|
99
110
|
指令:
|
|
100
|
-
请将 <content> 中的内容(不包含最外层的 <content> 标签) **准确** 地翻译成 **{{ language }}**,并严格遵循翻译要求。
|
|
111
|
+
请将 <content> 中的内容(不包含最外层的 <content> 标签) **准确** 地翻译成 **{{ language }}**,并严格遵循翻译要求。
|
|
@@ -21,6 +21,9 @@ describe("check-need-generate-structure", () => {
|
|
|
21
21
|
let saveValueToConfigSpy;
|
|
22
22
|
|
|
23
23
|
beforeEach(() => {
|
|
24
|
+
// Set test environment variable
|
|
25
|
+
process.env.NODE_ENV = "test";
|
|
26
|
+
|
|
24
27
|
// Reset all mocks
|
|
25
28
|
mock.restore();
|
|
26
29
|
|
|
@@ -32,6 +35,7 @@ describe("check-need-generate-structure", () => {
|
|
|
32
35
|
mockOptions = {
|
|
33
36
|
prompts: {
|
|
34
37
|
input: mock(async () => ""),
|
|
38
|
+
select: mock(async () => ""),
|
|
35
39
|
},
|
|
36
40
|
context: {
|
|
37
41
|
agents: { refineDocumentStructure: {} },
|
|
@@ -70,6 +74,9 @@ describe("check-need-generate-structure", () => {
|
|
|
70
74
|
});
|
|
71
75
|
|
|
72
76
|
afterEach(() => {
|
|
77
|
+
// Clean up environment variable
|
|
78
|
+
delete process.env.NODE_ENV;
|
|
79
|
+
|
|
73
80
|
// Restore all spies
|
|
74
81
|
accessSpy?.mockRestore();
|
|
75
82
|
getActiveRulesForScopeSpy?.mockRestore();
|
|
@@ -92,19 +99,7 @@ describe("check-need-generate-structure", () => {
|
|
|
92
99
|
expect(mockOptions.context.invoke).not.toHaveBeenCalled();
|
|
93
100
|
});
|
|
94
101
|
|
|
95
|
-
test("should
|
|
96
|
-
const userFeedback = "Need more API documentation";
|
|
97
|
-
mockOptions.prompts.input.mockImplementation(async () => userFeedback);
|
|
98
|
-
|
|
99
|
-
await checkNeedGenerateStructure({ originalDocumentStructure, docsDir: "./docs" }, mockOptions);
|
|
100
|
-
|
|
101
|
-
expect(mockOptions.prompts.input).toHaveBeenCalledWith({
|
|
102
|
-
message: "How can we improve the documentation structure? (press Enter to skip):",
|
|
103
|
-
});
|
|
104
|
-
expect(mockOptions.context.invoke).toHaveBeenCalled();
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
test("should skip prompting if feedback is already provided", async () => {
|
|
102
|
+
test("should handle pre-existing feedback without prompting", async () => {
|
|
108
103
|
const providedFeedback = "Already provided feedback";
|
|
109
104
|
|
|
110
105
|
await checkNeedGenerateStructure(
|
|
@@ -257,17 +252,6 @@ describe("check-need-generate-structure", () => {
|
|
|
257
252
|
expect(result.feedback).toBe("");
|
|
258
253
|
});
|
|
259
254
|
|
|
260
|
-
test("should preserve documentStructureFeedback", async () => {
|
|
261
|
-
const feedback = "user submitted feedback";
|
|
262
|
-
|
|
263
|
-
const result = await checkNeedGenerateStructure(
|
|
264
|
-
{ originalDocumentStructure, feedback, docsDir: "./docs" },
|
|
265
|
-
mockOptions,
|
|
266
|
-
);
|
|
267
|
-
|
|
268
|
-
expect(result.documentStructureFeedback).toBe(feedback);
|
|
269
|
-
});
|
|
270
|
-
|
|
271
255
|
test("should pass through additional parameters", async () => {
|
|
272
256
|
const additionalParams = {
|
|
273
257
|
customParam1: "value1",
|
|
@@ -289,4 +273,17 @@ describe("check-need-generate-structure", () => {
|
|
|
289
273
|
expect.objectContaining(additionalParams),
|
|
290
274
|
);
|
|
291
275
|
});
|
|
276
|
+
|
|
277
|
+
test("should return userDeferred when user selects 'later' and no originalDocumentStructure exists", async () => {
|
|
278
|
+
mockOptions.prompts.select.mockImplementation(async () => "later");
|
|
279
|
+
|
|
280
|
+
const result = await checkNeedGenerateStructure({ docsDir: "./docs" }, mockOptions);
|
|
281
|
+
|
|
282
|
+
expect(result).toBeDefined();
|
|
283
|
+
expect(result.userDeferred).toBe(true);
|
|
284
|
+
expect(result.documentStructure).toBe(null);
|
|
285
|
+
|
|
286
|
+
expect(mockOptions.prompts.select).toHaveBeenCalled();
|
|
287
|
+
expect(mockOptions.context.invoke).not.toHaveBeenCalled();
|
|
288
|
+
});
|
|
292
289
|
});
|