@aigne/doc-smith 0.8.9 → 0.8.10-beta.1
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/.github/workflows/release.yml +6 -2
- package/.release-please-manifest.json +3 -0
- package/CHANGELOG.md +20 -0
- package/LICENSE +93 -0
- package/README.md +6 -2
- package/RELEASE.md +10 -0
- package/agents/generate/check-need-generate-structure.mjs +40 -18
- package/agents/generate/index.yaml +1 -0
- package/agents/generate/user-review-document-structure.mjs +168 -0
- 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 +3 -3
- package/prompts/detail/document-rules.md +1 -1
- package/prompts/structure/check-document-structure.md +11 -15
- package/release-please-config.json +13 -0
- 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/utils/auth-utils.mjs +2 -2
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
# Update and Refine
|
|
2
2
|
|
|
3
|
-
Keeping documentation synchronized with an evolving codebase is
|
|
3
|
+
Keeping documentation synchronized with an evolving codebase is a critical task. AIGNE DocSmith provides direct and flexible methods to keep your content current, whether through automatic updates based on code changes or precise, feedback-driven refinements.
|
|
4
4
|
|
|
5
5
|
This guide covers how to:
|
|
6
|
-
|
|
7
|
-
-
|
|
8
|
-
-
|
|
6
|
+
|
|
7
|
+
- Automatically update documents when your source code changes.
|
|
8
|
+
- Regenerate specific documents using targeted feedback.
|
|
9
|
+
- Adjust the overall documentation structure.
|
|
9
10
|
|
|
10
11
|
### Document Update Workflows
|
|
11
12
|
|
|
12
13
|
The following diagram illustrates the different paths you can take to update your documentation:
|
|
13
14
|
|
|
14
|
-
```d2
|
|
15
|
+
```d2 Update Workflows
|
|
15
16
|
direction: down
|
|
16
17
|
|
|
17
18
|
Start: {
|
|
@@ -66,9 +67,9 @@ Replan -> End
|
|
|
66
67
|
|
|
67
68
|
## Automatic Updates with Change Detection
|
|
68
69
|
|
|
69
|
-
When you run the `aigne doc generate` command, DocSmith analyzes your codebase, detects any changes since the last run, and regenerates only the documents that are affected. This process saves time and reduces unnecessary
|
|
70
|
+
When you run the `aigne doc generate` command, DocSmith analyzes your codebase, detects any changes since the last run, and regenerates only the documents that are affected. This process saves time and reduces unnecessary API calls.
|
|
70
71
|
|
|
71
|
-
```
|
|
72
|
+
```shell icon=lucide:terminal
|
|
72
73
|
# DocSmith will detect changes and update only what's necessary
|
|
73
74
|
aigne doc generate
|
|
74
75
|
```
|
|
@@ -79,7 +80,7 @@ aigne doc generate
|
|
|
79
80
|
|
|
80
81
|
If you need to regenerate all documentation from scratch, ignoring any cached or previous state, use the `--forceRegenerate` flag. This is useful after significant configuration changes or when you want to ensure a completely fresh build.
|
|
81
82
|
|
|
82
|
-
```
|
|
83
|
+
```shell icon=lucide:terminal
|
|
83
84
|
# Regenerate all documentation from the ground up
|
|
84
85
|
aigne doc generate --forceRegenerate
|
|
85
86
|
```
|
|
@@ -88,15 +89,15 @@ aigne doc generate --forceRegenerate
|
|
|
88
89
|
|
|
89
90
|
## Refining Individual Documents
|
|
90
91
|
|
|
91
|
-
To improve a specific document without any corresponding code changes, the `aigne doc update` command allows you to provide targeted
|
|
92
|
+
To improve a specific document without any corresponding code changes, the `aigne doc update` command allows you to provide targeted instructions for content refinement.
|
|
92
93
|
|
|
93
94
|
You can use this command in two ways: interactively or directly via command-line arguments.
|
|
94
95
|
|
|
95
96
|
### Interactive Mode
|
|
96
97
|
|
|
97
|
-
For a guided experience, run the command without any arguments. DocSmith will present
|
|
98
|
+
For a guided experience, run the command without any arguments. DocSmith will present a menu to select which document you want to update. After you choose, you'll be prompted to enter your feedback.
|
|
98
99
|
|
|
99
|
-
```
|
|
100
|
+
```shell icon=lucide:terminal
|
|
100
101
|
# Start the interactive update process
|
|
101
102
|
aigne doc update
|
|
102
103
|
```
|
|
@@ -107,9 +108,9 @@ aigne doc update
|
|
|
107
108
|
|
|
108
109
|
For faster workflows or scripting, you can specify the document and feedback directly using flags. This allows for precise, non-interactive updates.
|
|
109
110
|
|
|
110
|
-
```
|
|
111
|
+
```shell icon=lucide:terminal
|
|
111
112
|
# Update a specific document with feedback
|
|
112
|
-
aigne doc update --docs overview.md --feedback "Add a more
|
|
113
|
+
aigne doc update --docs overview.md --feedback "Add a more detailed FAQ section at the end."
|
|
113
114
|
```
|
|
114
115
|
|
|
115
116
|
Key parameters for the `update` command:
|
|
@@ -117,19 +118,19 @@ Key parameters for the `update` command:
|
|
|
117
118
|
| Parameter | Description |
|
|
118
119
|
| ---------- | ------------------------------------------------------------------------------------------------ |
|
|
119
120
|
| `--docs` | The path to the document you want to update. You can use this flag multiple times for batch updates. |
|
|
120
|
-
| `--feedback` | The specific instructions
|
|
121
|
+
| `--feedback` | The specific instructions to use when regenerating the content. |
|
|
121
122
|
|
|
122
123
|
---
|
|
123
124
|
|
|
124
125
|
## Optimizing the Overall Structure
|
|
125
126
|
|
|
126
|
-
Beyond refining the content of individual documents, you can also adjust the overall documentation structure. If a section is missing or the existing organization could be improved, you can provide feedback to
|
|
127
|
+
Beyond refining the content of individual documents, you can also adjust the overall documentation structure. If a section is missing or the existing organization could be improved, you can provide feedback to the `generate` command.
|
|
127
128
|
|
|
128
|
-
This command instructs DocSmith to
|
|
129
|
+
This command instructs DocSmith to re-evaluate the entire document plan based on your new input.
|
|
129
130
|
|
|
130
|
-
```
|
|
131
|
+
```shell icon=lucide:terminal
|
|
131
132
|
# Regenerate the documentation structure with specific feedback
|
|
132
|
-
aigne doc generate --feedback "Remove the 'About' section and add a
|
|
133
|
+
aigne doc generate --feedback "Remove the 'About' section and add a detailed 'API Reference'."
|
|
133
134
|
```
|
|
134
135
|
|
|
135
136
|
This approach is best for high-level changes to the document's table of contents, rather than line-by-line content edits.
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
#
|
|
1
|
+
# 更新与优化
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
保持文档与不断演进的代码库同步是一项至关重要的任务。AIGNE DocSmith 提供了直接而灵活的方法来确保内容保持最新,无论是通过基于代码变更的自动更新,还是通过由反馈驱动的精确优化。
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
-
|
|
8
|
-
-
|
|
5
|
+
本指南将介绍如何:
|
|
6
|
+
|
|
7
|
+
- 在源代码变更时自动更新文档。
|
|
8
|
+
- 使用有针对性的反馈重新生成特定文档。
|
|
9
|
+
- 调整整体文档结构。
|
|
9
10
|
|
|
10
11
|
### 文档更新工作流
|
|
11
12
|
|
|
12
|
-
|
|
13
|
+
下图说明了更新文档可采用的不同路径:
|
|
13
14
|
|
|
14
|
-
```d2
|
|
15
|
+
```d2 Update Workflows
|
|
15
16
|
direction: down
|
|
16
17
|
|
|
17
18
|
Start: {
|
|
@@ -25,12 +26,12 @@ Code-Change: {
|
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
Content-Tweak: {
|
|
28
|
-
label: "
|
|
29
|
+
label: "需要内容\n改进?"
|
|
29
30
|
shape: rectangle
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
Structure-Tweak: {
|
|
33
|
-
label: "
|
|
34
|
+
label: "需要结构\n改进?"
|
|
34
35
|
shape: rectangle
|
|
35
36
|
}
|
|
36
37
|
|
|
@@ -66,20 +67,20 @@ Replan -> End
|
|
|
66
67
|
|
|
67
68
|
## 通过变更检测自动更新
|
|
68
69
|
|
|
69
|
-
当您运行 `aigne doc generate` 命令时,DocSmith
|
|
70
|
+
当您运行 `aigne doc generate` 命令时,DocSmith 会分析您的代码库,检测自上次运行以来的所有变更,并仅重新生成受影响的文档。这一过程可以节省时间并减少不必要的 API 调用。
|
|
70
71
|
|
|
71
|
-
```
|
|
72
|
-
# DocSmith
|
|
72
|
+
```shell icon=lucide:terminal
|
|
73
|
+
# DocSmith 将检测变更并仅更新必要部分
|
|
73
74
|
aigne doc generate
|
|
74
75
|
```
|
|
75
76
|
|
|
76
|
-

|
|
77
78
|
|
|
78
79
|
### 强制完全重新生成
|
|
79
80
|
|
|
80
|
-
如果您需要从头开始重新生成所有文档,忽略任何缓存或先前的状态,请使用 `--forceRegenerate`
|
|
81
|
+
如果您需要从头开始重新生成所有文档,忽略任何缓存或先前的状态,请使用 `--forceRegenerate` 标志。这在进行重大配置更改后,或当您希望确保构建一个全新的版本时非常有用。
|
|
81
82
|
|
|
82
|
-
```
|
|
83
|
+
```shell icon=lucide:terminal
|
|
83
84
|
# 从头开始重新生成所有文档
|
|
84
85
|
aigne doc generate --forceRegenerate
|
|
85
86
|
```
|
|
@@ -88,15 +89,15 @@ aigne doc generate --forceRegenerate
|
|
|
88
89
|
|
|
89
90
|
## 优化单个文档
|
|
90
91
|
|
|
91
|
-
|
|
92
|
+
如果想在没有相应代码变更的情况下改进特定文档,可以使用 `aigne doc update` 命令提供有针对性的内容优化指令。
|
|
92
93
|
|
|
93
|
-
|
|
94
|
+
您可以通过两种方式使用此命令:交互式模式或直接通过命令行参数。
|
|
94
95
|
|
|
95
96
|
### 交互模式
|
|
96
97
|
|
|
97
|
-
|
|
98
|
+
如需引导式体验,请直接运行该命令,不带任何参数。DocSmith 将会展示一个菜单,供您选择要更新的文档。选择后,系统将提示您输入反馈。
|
|
98
99
|
|
|
99
|
-
```
|
|
100
|
+
```shell icon=lucide:terminal
|
|
100
101
|
# 启动交互式更新流程
|
|
101
102
|
aigne doc update
|
|
102
103
|
```
|
|
@@ -105,33 +106,33 @@ aigne doc update
|
|
|
105
106
|
|
|
106
107
|
### 直接通过命令行更新
|
|
107
108
|
|
|
108
|
-
|
|
109
|
+
为了实现更快的工作流或用于脚本编写,您可以使用标志直接指定文档和反馈。这支持精确的非交互式更新。
|
|
109
110
|
|
|
110
|
-
```
|
|
111
|
+
```shell icon=lucide:terminal
|
|
111
112
|
# 使用反馈更新特定文档
|
|
112
|
-
aigne doc update --docs overview.md --feedback "
|
|
113
|
+
aigne doc update --docs overview.md --feedback "在末尾添加一个更详细的 FAQ 部分。"
|
|
113
114
|
```
|
|
114
115
|
|
|
115
116
|
`update` 命令的关键参数:
|
|
116
117
|
|
|
117
118
|
| Parameter | Description |
|
|
118
119
|
| ---------- | ------------------------------------------------------------------------------------------------ |
|
|
119
|
-
| `--docs` |
|
|
120
|
-
| `--feedback` |
|
|
120
|
+
| `--docs` | 您希望更新的文档路径。您可以多次使用此标志进行批量更新。 |
|
|
121
|
+
| `--feedback` | 重新生成内容时要使用的具体指令。 |
|
|
121
122
|
|
|
122
123
|
---
|
|
123
124
|
|
|
124
125
|
## 优化整体结构
|
|
125
126
|
|
|
126
|
-
|
|
127
|
+
除了优化单个文档的内容,您还可以调整整体文档结构。如果缺少某个部分或现有组织结构有待改进,您可以向 `generate` 命令提供反馈。
|
|
127
128
|
|
|
128
|
-
|
|
129
|
+
该命令会指示 DocSmith 根据您的新输入重新评估整个文档计划。
|
|
129
130
|
|
|
130
|
-
```
|
|
131
|
-
#
|
|
132
|
-
aigne doc generate --feedback "
|
|
131
|
+
```shell icon=lucide:terminal
|
|
132
|
+
# 使用特定反馈重新生成文档结构
|
|
133
|
+
aigne doc generate --feedback "删除‘关于’部分,并添加一个详细的‘API 参考’。"
|
|
133
134
|
```
|
|
134
135
|
|
|
135
|
-
|
|
136
|
+
这种方法最适合对文档的目录进行高层级的更改,而不是逐行编辑内容。
|
|
136
137
|
|
|
137
|
-
|
|
138
|
+
借助这些工具,您可以维护与项目共同演进的准确文档。内容优化后,您可以将其提供给全球用户。具体方法请参阅[翻译文档](./features-translate-documentation.md)指南。
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aigne/doc-smith",
|
|
3
|
-
"version": "0.8.
|
|
4
|
-
"description": "",
|
|
3
|
+
"version": "0.8.10-beta.1",
|
|
4
|
+
"description": "AI-driven documentation generation tool built on the AIGNE Framework",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"bin": "aigne.yaml",
|
|
11
11
|
"keywords": [],
|
|
12
12
|
"author": "Arcblock <blocklet@arcblock.io> https://github.com/blocklet",
|
|
13
|
-
"license": "
|
|
13
|
+
"license": "Elastic-2.0",
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"@aigne/aigne-hub": "^0.9.3",
|
|
16
16
|
"@aigne/anthropic": "^0.13.3",
|
|
@@ -13,7 +13,7 @@
|
|
|
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
19
|
- 接口/方法调用的说明必须包含 **响应数据示例**
|
|
@@ -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
|
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json",
|
|
3
|
+
"packages": {
|
|
4
|
+
".": {
|
|
5
|
+
"release-type": "node",
|
|
6
|
+
"bump-minor-pre-major": true,
|
|
7
|
+
"bump-patch-for-minor-pre-major": true,
|
|
8
|
+
"include-component-in-tag": false,
|
|
9
|
+
"prerelease-type": "beta",
|
|
10
|
+
"versioning": "prerelease"
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -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
|
});
|