@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.
Files changed (48) hide show
  1. package/.aigne/doc-smith/config.yaml +3 -1
  2. package/.aigne/doc-smith/preferences.yml +4 -4
  3. package/.aigne/doc-smith/upload-cache.yaml +180 -0
  4. package/.github/workflows/release.yml +6 -2
  5. package/.release-please-manifest.json +3 -0
  6. package/CHANGELOG.md +20 -0
  7. package/LICENSE +93 -0
  8. package/README.md +6 -2
  9. package/RELEASE.md +10 -0
  10. package/agents/generate/check-need-generate-structure.mjs +40 -18
  11. package/agents/generate/index.yaml +1 -0
  12. package/agents/generate/user-review-document-structure.mjs +168 -0
  13. package/agents/update/generate-and-translate-document.yaml +3 -3
  14. package/agents/utils/check-feedback-refiner.mjs +2 -0
  15. package/agents/utils/save-docs.mjs +16 -22
  16. package/aigne.yaml +1 -0
  17. package/docs/advanced-how-it-works.md +26 -24
  18. package/docs/advanced-how-it-works.zh.md +32 -30
  19. package/docs/advanced-quality-assurance.md +6 -9
  20. package/docs/advanced-quality-assurance.zh.md +19 -22
  21. package/docs/cli-reference.md +35 -76
  22. package/docs/cli-reference.zh.md +48 -89
  23. package/docs/configuration-interactive-setup.md +18 -18
  24. package/docs/configuration-interactive-setup.zh.md +33 -33
  25. package/docs/configuration-language-support.md +12 -12
  26. package/docs/configuration-language-support.zh.md +20 -20
  27. package/docs/configuration-llm-setup.md +14 -13
  28. package/docs/configuration-llm-setup.zh.md +16 -15
  29. package/docs/configuration-preferences.md +22 -27
  30. package/docs/configuration-preferences.zh.md +35 -40
  31. package/docs/configuration.md +31 -45
  32. package/docs/configuration.zh.md +48 -62
  33. package/docs/features-generate-documentation.md +6 -7
  34. package/docs/features-generate-documentation.zh.md +21 -22
  35. package/docs/features-publish-your-docs.md +38 -30
  36. package/docs/features-publish-your-docs.zh.md +45 -37
  37. package/docs/features-translate-documentation.md +14 -74
  38. package/docs/features-translate-documentation.zh.md +19 -79
  39. package/docs/features-update-and-refine.md +19 -18
  40. package/docs/features-update-and-refine.zh.md +33 -32
  41. package/docs-mcp/get-docs-structure.mjs +1 -1
  42. package/package.json +3 -3
  43. package/prompts/detail/document-rules.md +1 -1
  44. package/prompts/structure/check-document-structure.md +11 -15
  45. package/release-please-config.json +13 -0
  46. package/tests/agents/generate/check-need-generate-structure.test.mjs +21 -24
  47. package/tests/agents/generate/user-review-document-structure.test.mjs +294 -0
  48. 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 essential. AIGNE DocSmith provides direct and flexible methods to keep your content current, whether through automatic updates triggered by code changes or precise, feedback-driven refinements.
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
- - Automatically update documents when your code changes.
7
- - Manually regenerate specific documents with targeted feedback.
8
- - Optimize the overall documentation structure.
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 LLM API calls.
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
- ```bash
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
- ```bash
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 feedback to the AI for content refinement.
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 an interactive menu to select which document you want to update. After you choose, you'll be prompted to enter your feedback.
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
- ```bash
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
- ```bash
111
+ ```shell icon=lucide:terminal
111
112
  # Update a specific document with feedback
112
- aigne doc update --docs overview.md --feedback "Add a more comprehensive FAQ section at the end."
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 for the AI to use when regenerating the content. |
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 improve the documentation structure using the `generate` command with the `--feedback` flag.
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 reconsider the entire document plan based on your new input.
129
+ This command instructs DocSmith to re-evaluate the entire document plan based on your new input.
129
130
 
130
- ```bash
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 more detailed 'API Reference'."
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
- 保持文档与不断演进的代码库同步至关重要。AIGNE DocSmith 提供了直接且灵活的方法来保持内容最新,无论是通过代码变更触发的自动更新,还是通过精确的、由反馈驱动的优化。
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: "需要改进\n内容?"
29
+ label: "需要内容\n改进?"
29
30
  shape: rectangle
30
31
  }
31
32
 
32
33
  Structure-Tweak: {
33
- label: "需要改进\n结构?"
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 会分析您的代码库,检测自上次运行以来的任何变更,并仅重新生成受影响的文档。此过程可以节省时间并减少不必要的 LLM API 调用。
70
+ 当您运行 `aigne doc generate` 命令时,DocSmith 会分析您的代码库,检测自上次运行以来的所有变更,并仅重新生成受影响的文档。这一过程可以节省时间并减少不必要的 API 调用。
70
71
 
71
- ```bash
72
- # DocSmith 将检测变更并仅更新必要的部分
72
+ ```shell icon=lucide:terminal
73
+ # DocSmith 将检测变更并仅更新必要部分
73
74
  aigne doc generate
74
75
  ```
75
76
 
76
- ![DocSmith 会检测变更并仅重新生成所需的文档。](https://docsmith.aigne.io/image-bin/uploads/21a76b2f65d14d16a49c13d800f1e2c1.png)
77
+ ![DocSmith 检测变更并仅重新生成所需文档。](https://docsmith.aigne.io/image-bin/uploads/21a76b2f65d14d16a49c13d800f1e2c1.png)
77
78
 
78
79
  ### 强制完全重新生成
79
80
 
80
- 如果您需要从头开始重新生成所有文档,忽略任何缓存或先前的状态,请使用 `--forceRegenerate` 标志。这在进行重大配置更改或希望确保完全重新构建时非常有用。
81
+ 如果您需要从头开始重新生成所有文档,忽略任何缓存或先前的状态,请使用 `--forceRegenerate` 标志。这在进行重大配置更改后,或当您希望确保构建一个全新的版本时非常有用。
81
82
 
82
- ```bash
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
- 要在没有任何相应代码变更的情况下改进特定文档,`aigne doc update` 命令允许您向 AI 提供有针对性的反馈以进行内容优化。
92
+ 如果想在没有相应代码变更的情况下改进特定文档,可以使用 `aigne doc update` 命令提供有针对性的内容优化指令。
92
93
 
93
- 您可以通过两种方式使用此命令:交互式或直接通过命令行参数。
94
+ 您可以通过两种方式使用此命令:交互式模式或直接通过命令行参数。
94
95
 
95
96
  ### 交互模式
96
97
 
97
- 要获得引导式体验,请在不带任何参数的情况下运行该命令。DocSmith 将呈现一个交互式菜单,供您选择要更新的文档。选择后,系统将提示您输入反馈。
98
+ 如需引导式体验,请直接运行该命令,不带任何参数。DocSmith 将会展示一个菜单,供您选择要更新的文档。选择后,系统将提示您输入反馈。
98
99
 
99
- ```bash
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
- ```bash
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` | 供 AI 在重新生成内容时使用的具体说明。 |
120
+ | `--docs` | 您希望更新的文档路径。您可以多次使用此标志进行批量更新。 |
121
+ | `--feedback` | 重新生成内容时要使用的具体指令。 |
121
122
 
122
123
  ---
123
124
 
124
125
  ## 优化整体结构
125
126
 
126
- 除了优化单个文档的内容外,您还可以调整整体文档结构。如果缺少某个部分或现有组织结构可以改进,您可以使用带 `--feedback` 标志的 `generate` 命令向结构规划 agent 提供反馈。
127
+ 除了优化单个文档的内容,您还可以调整整体文档结构。如果缺少某个部分或现有组织结构有待改进,您可以向 `generate` 命令提供反馈。
127
128
 
128
- 此命令指示 DocSmith 根据您的新输入重新考虑整个文档计划。
129
+ 该命令会指示 DocSmith 根据您的新输入重新评估整个文档计划。
129
130
 
130
- ```bash
131
- # 使用特定反馈重新生成结构计划
132
- aigne doc generate --feedback "移除‘关于’部分,并添加一个更详细的‘API 参考’。"
131
+ ```shell icon=lucide:terminal
132
+ # 使用特定反馈重新生成文档结构
133
+ aigne doc generate --feedback "删除‘关于’部分,并添加一个详细的‘API 参考’。"
133
134
  ```
134
135
 
135
- 此方法最适用于文档目录的高层级更改,而非逐行内容编辑。
136
+ 这种方法最适合对文档的目录进行高层级的更改,而不是逐行编辑内容。
136
137
 
137
- 借助这些工具,您可以维护与项目一同演进的准确文档。内容优化后,您可以将其提供给全球受众。在 [翻译文档](./features-translate-documentation.md) 指南中了解如何操作。
138
+ 借助这些工具,您可以维护与项目共同演进的准确文档。内容优化后,您可以将其提供给全球用户。具体方法请参阅[翻译文档](./features-translate-documentation.md)指南。
@@ -13,4 +13,4 @@ export default async function getDocsStructure() {
13
13
  return { structure };
14
14
  }
15
15
 
16
- getDocsStructure.description = "Get docs structure";
16
+ getDocsStructure.description = "Get documentation structure";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@aigne/doc-smith",
3
- "version": "0.8.9",
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": "MIT",
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 以及与类型相关的内容优先使用 `<x-field>` 自定义组件来展示,支持嵌套结构来清晰描述复杂数据类型
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
- 如果 `originalDocumentStructure` 为 null、为空或未提供,这意味着这是第一次生成结构。没有可供比较的对象。
35
+ 如果 `original_document_structure` 为 null、为空或未提供,这意味着这是第一次生成结构。没有可供比较的对象。
40
36
  你的检查自动通过。
41
37
 
42
38
  ### 场景 2:迭代运行(存在旧的规划)
43
39
  这是主要场景。你必须执行详细的比较。
44
40
 
45
41
  **分步分析**:
46
- 1. **分析反馈**:仔细阅读并理解 `<context>` 中 用户反馈 提出的每一项变更要求。明确哪些节点是需要被修改、添加或删除的目标。
47
- 2. **验证反馈的实现**:对比 `<context>` 中的 `documentStructure` 和 `originalDocumentStructure`,确认所要求的变更是否已执行。例如,如果反馈是“移除‘示例’部分”,你必须检查该部分在 `documentStructure` 中是否已不存在。
48
- 3. **验证无关节点的稳定性**:这是最关键的检查。遍历 `documentStructure` 中的所有节点。对于每一个在 `originalDocumentStructure` 中也存在、但并未在反馈中被提及的节点:
49
- * **至关重要**:其 `path`、`sourcesIds` 属性**必须**与 `originalDocumentStructure` 中的完全相同。
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 prompt for user feedback when originalDocumentStructure exists", async () => {
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
  });