@aigne/doc-smith 0.8.3 → 0.8.5

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 (58) hide show
  1. package/.aigne/doc-smith/config.yaml +3 -3
  2. package/.aigne/doc-smith/preferences.yml +58 -12
  3. package/.aigne/doc-smith/upload-cache.yaml +600 -207
  4. package/CHANGELOG.md +22 -0
  5. package/README.md +77 -5
  6. package/agents/input-generator.mjs +12 -6
  7. package/agents/publish-docs.mjs +53 -4
  8. package/docs/_sidebar.md +1 -1
  9. package/docs/advanced-how-it-works.md +55 -60
  10. package/docs/advanced-how-it-works.zh.md +60 -65
  11. package/docs/advanced-quality-assurance.md +73 -38
  12. package/docs/advanced-quality-assurance.zh.md +73 -38
  13. package/docs/advanced.md +2 -14
  14. package/docs/advanced.zh.md +5 -17
  15. package/docs/changelog.md +41 -4
  16. package/docs/changelog.zh.md +77 -40
  17. package/docs/cli-reference.md +79 -13
  18. package/docs/cli-reference.zh.md +92 -26
  19. package/docs/configuration-interactive-setup.md +102 -49
  20. package/docs/configuration-interactive-setup.zh.md +102 -49
  21. package/docs/configuration-language-support.md +69 -39
  22. package/docs/configuration-language-support.zh.md +68 -38
  23. package/docs/configuration-llm-setup.md +25 -62
  24. package/docs/configuration-llm-setup.zh.md +25 -62
  25. package/docs/configuration-preferences.md +79 -67
  26. package/docs/configuration-preferences.zh.md +78 -67
  27. package/docs/configuration.md +122 -109
  28. package/docs/configuration.zh.md +130 -117
  29. package/docs/features-generate-documentation.md +44 -24
  30. package/docs/features-generate-documentation.zh.md +52 -32
  31. package/docs/features-publish-your-docs.md +41 -40
  32. package/docs/features-publish-your-docs.zh.md +50 -49
  33. package/docs/features-translate-documentation.md +73 -17
  34. package/docs/features-translate-documentation.zh.md +76 -20
  35. package/docs/features-update-and-refine.md +72 -21
  36. package/docs/features-update-and-refine.zh.md +80 -29
  37. package/docs/features.md +24 -28
  38. package/docs/features.zh.md +25 -29
  39. package/docs/getting-started.md +87 -38
  40. package/docs/getting-started.zh.md +88 -39
  41. package/docs/overview.md +17 -35
  42. package/docs/overview.zh.md +18 -36
  43. package/package.json +9 -8
  44. package/prompts/content-detail-generator.md +1 -0
  45. package/prompts/document/custom-code-block.md +101 -0
  46. package/prompts/document/d2-chart/rules.md +941 -1031
  47. package/prompts/document/detail-generator.md +7 -53
  48. package/tests/input-generator.test.mjs +2 -2
  49. package/tests/kroki-utils.test.mjs +88 -17
  50. package/utils/auth-utils.mjs +9 -2
  51. package/utils/blocklet.mjs +25 -6
  52. package/utils/constants.mjs +17 -1
  53. package/utils/deploy.mjs +404 -0
  54. package/utils/kroki-utils.mjs +22 -14
  55. package/utils/markdown-checker.mjs +1 -1
  56. package/utils/utils.mjs +3 -2
  57. package/prompts/document/d2-chart/diy-examples.md +0 -44
  58. package/prompts/document/d2-chart/shape-rules.md +0 -182
@@ -1,90 +1,53 @@
1
- ---
2
- labels: ["Reference"]
3
- ---
4
-
5
1
  # LLM Setup
6
2
 
7
- AIGNE DocSmith leverages Large Language Models (LLMs) to generate high-quality documentation. You can configure DocSmith to use different AI models through two primary methods: the recommended AIGNE Hub service or by providing your own custom API keys.
8
-
9
- This guide will walk you through both options.
10
-
11
- ## Using AIGNE Hub (Recommended)
3
+ AIGNE DocSmith uses Large Language Models (LLMs) to generate documentation content. The tool provides two primary methods for configuring your AI model provider: using the integrated AIGNE Hub for a streamlined experience, or connecting your own custom API keys for direct provider access.
12
4
 
13
- The most straightforward way to use LLMs with DocSmith is through AIGNE Hub. This approach offers significant advantages:
5
+ ## AIGNE Hub (Recommended)
14
6
 
15
- - **No API Key Required:** You don't need to sign up for separate AI services or manage your own API keys.
16
- - **Easy Model Switching:** You can switch between different state-of-the-art models from providers like Google, Anthropic, and OpenAI with a simple command-line flag.
7
+ The simplest way to get started is with AIGNE Hub. It acts as a gateway to multiple LLM providers, offering two key advantages:
17
8
 
18
- To specify a model, use the `--model` flag with the `generate` command. DocSmith will handle the API requests through the AIGNE Hub.
9
+ - **No API Key Required:** Generate documents without needing to manage your own API keys or service subscriptions.
10
+ - **Easy Model Switching:** Change the AI model for any command using a simple flag.
19
11
 
20
- ### Examples
12
+ To use a specific model through AIGNE Hub, add the `--model` flag to your command. Here are a few examples:
21
13
 
22
- Here are some examples of how to generate documentation using different models available via AIGNE Hub:
23
-
24
- **Using Google's Gemini 1.5 Flash:**
25
- ```bash
14
+ ```bash Use Google's Gemini 2.5 Flash model
26
15
  aigne doc generate --model google:gemini-2.5-flash
27
- ```
28
16
 
29
- **Using Anthropic's Claude 3.5 Sonnet:**
30
- ```bash
17
+ # Use Anthropic's Claude 3.5 Sonnet model
31
18
  aigne doc generate --model claude:claude-3-5-sonnet
32
- ```
33
19
 
34
- **Using OpenAI's GPT-4o:**
35
- ```bash
20
+ # Use OpenAI's GPT-4o model
36
21
  aigne doc generate --model openai:gpt-4o
37
22
  ```
38
23
 
39
- ## Configuring Custom API Keys
24
+ If you don't specify a model, DocSmith will use the default model defined in your project's configuration.
25
+
26
+ ## Using Custom API Keys
40
27
 
41
- If you prefer to use your own API keys for providers like OpenAI or Anthropic, you can configure them using the interactive setup wizard.
28
+ If you prefer to use your own accounts with providers like OpenAI or Anthropic, you can configure DocSmith with your personal API keys. This gives you direct control over API usage and billing.
42
29
 
43
- Run the `init` command to launch the wizard, which will guide you through setting up your LLM provider and credentials, among other project settings.
30
+ Configuration is handled through an interactive wizard. To launch it, run:
44
31
 
45
32
  ```bash
46
- # Launch the interactive configuration wizard
47
33
  aigne doc init
48
34
  ```
49
35
 
50
- This process ensures your keys are stored correctly for all subsequent documentation generation and update tasks.
51
-
52
- ## How It Works
53
-
54
- The following diagram illustrates how DocSmith processes requests with different LLM configurations.
55
-
56
- ```d2
57
- direction: down
36
+ The wizard will prompt you to select your provider and enter your credentials. For a complete guide, please see the [Interactive Setup](./configuration-interactive-setup.md) documentation.
58
37
 
59
- User: {
60
- shape: person
61
- label: "Developer"
62
- }
38
+ ## Setting a Default Model
63
39
 
64
- CLI: "`aigne doc generate`"
65
-
66
- DocSmith: {
67
- shape: package
68
- "Configuration Check": {
69
- "AIGNE Hub (Default)": "No API Key Needed"
70
- "Custom Provider": "User API Key Found"
71
- }
72
- }
73
-
74
- LLM_Providers: {
75
- label: "LLM Providers"
76
- shape: cloud
77
- "AIGNE Hub": "Manages access to multiple models"
78
- "Direct API (e.g., OpenAI)": "Uses custom key"
79
- }
80
-
81
- User -> CLI: "Runs command"
82
- CLI -> DocSmith: "Initiates process"
83
- DocSmith."Configuration Check"."AIGNE Hub (Default)" -> LLM_Providers."AIGNE Hub" : "Routes request via Hub"
84
- DocSmith."Configuration Check"."Custom Provider" -> LLM_Providers."Direct API (e.g., OpenAI)" : "Routes request with user's key"
40
+ To ensure consistency across all documentation generation tasks, you can set a default LLM in your project's `aigne.yaml` configuration file. This model will be used automatically unless you override it with the `--model` flag.
85
41
 
42
+ ```yaml aigne.yaml icon=mdi:file-document
43
+ chat_model:
44
+ provider: google
45
+ name: gemini-2.5-pro
46
+ temperature: 0.8
86
47
  ```
87
48
 
49
+ In this configuration, DocSmith defaults to using Google's `gemini-2.5-pro` model with a `temperature` of `0.8` for all generation tasks.
50
+
88
51
  ---
89
52
 
90
- With your LLM provider configured, you are ready to customize language settings for your documentation. Learn more in the [Language Support](./configuration-language-support.md) guide.
53
+ Now that your LLM provider is configured, you can explore how to manage translations for your documentation. Proceed to the [Language Support](./configuration-language-support.md) guide to see the full list of supported languages and learn how to enable them.
@@ -1,90 +1,53 @@
1
- ---
2
- labels: ["Reference"]
3
- ---
4
-
5
1
  # LLM 设置
6
2
 
7
- AIGNE DocSmith 利用大型语言模型 (LLMs) 生成高质量的文档。你可以通过两种主要方法配置 DocSmith 以使用不同的 AI 模型:推荐的 AIGNE Hub 服务,或提供你自己的自定义 API 密钥。
8
-
9
- 本指南将引导你了解这两种选项。
10
-
11
- ## 使用 AIGNE Hub (推荐)
3
+ AIGNE DocSmith 使用大型语言模型 (LLMs) 生成文档内容。该工具提供两种配置 AI 模型提供商的主要方法:使用集成的 AIGNE Hub 以获得简化的体验,或连接你自己的自定义 API 密钥以直接访问提供商。
12
4
 
13
- 通过 AIGNE Hub 是将 DocSmith 与 LLMs 结合使用的最直接方法。该方法具有以下显著优势:
5
+ ## AIGNE Hub (推荐)
14
6
 
15
- - **无需 API 密钥:** 你无需注册单独的 AI 服务或管理自己的 API 密钥。
16
- - **轻松切换模型:** 你可以通过一个简单的命令行标志,在 Google、Anthropic 和 OpenAI 等提供商提供的不同顶尖模型之间进行切换。
7
+ 最简单的入门方法是使用 AIGNE Hub。它充当多个 LLM 提供商的网关,提供两大关键优势:
17
8
 
18
- 要指定模型,请在 `generate` 命令中使用 `--model` 标志。DocSmith 将通过 AIGNE Hub 处理 API 请求。
9
+ - **无需 API 密钥:** 无需管理自己的 API 密钥或服务订阅即可生成文档。
10
+ - **轻松切换模型:** 使用一个简单的标志即可为任何命令更改 AI 模型。
19
11
 
20
- ### 示例
12
+ 要通过 AIGNE Hub 使用特定模型,请在命令中添加 `--model` 标志。以下是一些示例:
21
13
 
22
- 以下示例展示了如何通过 AIGNE Hub 使用不同的模型生成文档:
23
-
24
- **使用 Google 的 Gemini 1.5 Flash:**
25
- ```bash
14
+ ```bash 使用 Google 的 Gemini 2.5 Flash 模型
26
15
  aigne doc generate --model google:gemini-2.5-flash
27
- ```
28
16
 
29
- **使用 Anthropic 的 Claude 3.5 Sonnet:**
30
- ```bash
17
+ # 使用 Anthropic 的 Claude 3.5 Sonnet 模型
31
18
  aigne doc generate --model claude:claude-3-5-sonnet
32
- ```
33
19
 
34
- **使用 OpenAI 的 GPT-4o:**
35
- ```bash
20
+ # 使用 OpenAI 的 GPT-4o 模型
36
21
  aigne doc generate --model openai:gpt-4o
37
22
  ```
38
23
 
39
- ## 配置自定义 API 密钥
24
+ 如果不指定模型,DocSmith 将使用项目配置中定义的默认模型。
25
+
26
+ ## 使用自定义 API 密钥
40
27
 
41
- 如果你希望为 OpenAI 或 Anthropic 等提供商使用自己的 API 密钥,可以通过交互式设置向导进行配置。
28
+ 如果你更喜欢使用自己在 OpenAI 或 Anthropic 等提供商处的账户,可以用个人 API 密钥来配置 DocSmith。这样你就可以直接控制 API 的使用和计费。
42
29
 
43
- 运行 `init` 命令启动向导,它将指导你完成 LLM 提供商、凭据以及其他项目设置。
30
+ 配置通过交互式向导完成。运行以下命令以启动它:
44
31
 
45
32
  ```bash
46
- # 启动交互式配置向导
47
33
  aigne doc init
48
34
  ```
49
35
 
50
- 该过程可确保你的密钥被正确存储,以便用于所有后续的文档生成和更新任务。
51
-
52
- ## 工作原理
53
-
54
- 下图说明了 DocSmith 在不同 LLM 配置下处理请求的流程。
55
-
56
- ```d2
57
- direction: down
36
+ 该向导将提示你选择提供商并输入凭据。有关完整指南,请参阅 [交互式设置](./configuration-interactive-setup.md) 文档。
58
37
 
59
- User: {
60
- shape: person
61
- label: "开发者"
62
- }
38
+ ## 设置默认模型
63
39
 
64
- CLI: "`aigne doc generate`"
65
-
66
- DocSmith: {
67
- shape: package
68
- "配置检查": {
69
- "AIGNE Hub (默认)": "无需 API 密钥"
70
- "自定义提供商": "找到用户 API 密钥"
71
- }
72
- }
73
-
74
- LLM_Providers: {
75
- label: "LLM 提供商"
76
- shape: cloud
77
- "AIGNE Hub": "管理对多个模型的访问"
78
- "直接 API (例如 OpenAI)": "使用自定义密钥"
79
- }
80
-
81
- User -> CLI: "运行命令"
82
- CLI -> DocSmith: "启动流程"
83
- DocSmith."配置检查"."AIGNE Hub (默认)" -> LLM_Providers."AIGNE Hub" : "通过 Hub 路由请求"
84
- DocSmith."配置检查"."自定义提供商" -> LLM_Providers."直接 API (例如 OpenAI)" : "使用用户密钥路由请求"
40
+ 为确保所有文档生成任务的一致性,你可以在项目的 `aigne.yaml` 配置文件中设置默认的 LLM。除非使用 `--model` 标志覆盖,否则将自动使用此模型。
85
41
 
42
+ ```yaml aigne.yaml icon=mdi:file-document
43
+ chat_model:
44
+ provider: google
45
+ name: gemini-2.5-pro
46
+ temperature: 0.8
86
47
  ```
87
48
 
49
+ 在此配置中,DocSmith 默认对所有生成任务使用 Google 的 `gemini-2.5-pro` 模型,并将 `temperature` 设置为 `0.8`。
50
+
88
51
  ---
89
52
 
90
- 配置好 LLM 提供商后,你就可以为文档自定义语言设置了。请在 [语言支持](./configuration-language-support.md) 指南中了解更多信息。
53
+ 既然你的 LLM 提供商已配置完毕,你可以探索如何管理文档的翻译。请继续阅读 [语言支持](./configuration-language-support.md) 指南,查看支持的语言完整列表并了解如何启用它们。
@@ -1,60 +1,86 @@
1
- ---
2
- labels: ["Reference"]
3
- ---
4
-
5
1
  # Managing Preferences
6
2
 
7
- DocSmith is designed to learn from your feedback. When you refine documents and provide corrections, the system can convert that feedback into persistent, reusable rules called "preferences". This ensures that your stylistic choices, structural conventions, and specific instructions are remembered and applied consistently in future operations.
3
+ AIGNE DocSmith is designed to learn from your feedback. When you refine or correct generated content, DocSmith can convert that feedback into persistent rules, called preferences. These rules ensure that your specific style, structural requirements, and content policies are applied consistently in future documentation tasks. All preferences are stored in a human-readable YAML file located at `.aigne/doc-smith/preferences.yml` in your project root.
8
4
 
9
- All preferences are stored in a human-readable YAML file located at `.aigne/doc-smith/preferences.yml` in your project root. While you can view this file, it's recommended to manage your preferences using the dedicated `aigne doc prefs` command-line interface.
5
+ ## The Preference Lifecycle
10
6
 
11
- ## How Preferences Are Created
7
+ The following diagram illustrates how your feedback becomes a reusable rule that can be applied to future tasks and managed via the command line.
12
8
 
13
- Preferences are automatically generated during the feedback cycle of commands like `aigne doc refine`. The process works as follows:
9
+ ```d2 The Preference Lifecycle
10
+ direction: down
14
11
 
15
- ```d2
16
- direction: right
12
+ feedback: {
13
+ label: "1. User provides feedback\nduring 'refine' or 'translate'"
14
+ shape: rectangle
15
+ }
17
16
 
18
- User: {
19
- shape: person
17
+ refiner: {
18
+ label: "2. Feedback Refiner Agent\nAnalyzes feedback"
19
+ shape: rectangle
20
20
  }
21
21
 
22
- Refine: "`aigne doc refine` command"
22
+ decision: {
23
+ label: "Is it a reusable policy?"
24
+ shape: diamond
25
+ }
23
26
 
24
- FeedbackRefiner: "Feedback→Rule Converter"
27
+ pref_file: {
28
+ label: "3. preferences.yml\nRule is saved"
29
+ shape: cylinder
30
+ }
25
31
 
26
- PreferencesFile: "preferences.yml" {
27
- shape: document
32
+ future_tasks: {
33
+ label: "4. Future Tasks\nSaved rules are applied"
34
+ shape: rectangle
28
35
  }
29
36
 
30
- User -> Refine: "Provide feedback, e.g., 'Don't translate variable names'"
31
- Refine -> FeedbackRefiner: "Sends feedback for analysis"
32
- FeedbackRefiner -> PreferencesFile: "Saves new, reusable rule" {
33
- style.animated: true
37
+ cli: {
38
+ label: "5. CLI Management\n('aigne doc prefs')"
39
+ shape: rectangle
34
40
  }
35
41
 
42
+ feedback -> refiner: "Input"
43
+ refiner -> decision: "Analyzes"
44
+ decision -> pref_file: "Yes"
45
+ decision -> "Discard (One-time fix)": "No"
46
+ pref_file -> future_tasks: "Applies to"
47
+ cli <-> pref_file: "Manages"
48
+
36
49
  ```
37
50
 
38
- 1. **Feedback Input**: You provide natural language feedback during a refinement session.
39
- 2. **Rule Generation**: An internal agent analyzes your feedback to determine if it represents a reusable policy rather than a one-time fix.
40
- 3. **Rule Creation**: If deemed reusable, it creates a structured rule with a specific scope (e.g., `document`, `translation`), a unique ID, and the instruction itself.
41
- 4. **Persistence**: The new rule is saved to the `preferences.yml` file, making it active for future tasks.
51
+ ### How DocSmith Learns from Feedback
52
+
53
+ When you provide feedback during the `refine` or `translate` stages, an internal agent called the 'Feedback Refiner' analyzes your input. Its goal is to distinguish between a one-time fix (e.g., correcting a typo) and a reusable policy (e.g., "always write code comments in English"). If it determines the feedback represents a lasting instruction, it creates a new preference rule.
54
+
55
+ Each rule has several key properties that define its behavior:
56
+
57
+ | Property | Description |
58
+ |---|---|
59
+ | **id** | A unique identifier for the rule (e.g., `pref_a1b2c3d4`). |
60
+ | **active** | A boolean (`true`/`false`) indicating if the rule is currently enabled. |
61
+ | **scope** | Defines when the rule should be applied: `global`, `structure`, `document`, or `translation`. |
62
+ | **rule** | The instruction that will be passed to the AI in future tasks. |
63
+ | **feedback** | The original natural language feedback you provided. |
64
+ | **createdAt** | The ISO 8601 timestamp of when the rule was created. |
65
+ | **paths** | An optional list of file paths. If present, the rule only applies to content generated for those specific paths. |
42
66
 
43
- ## Managing Preferences via CLI
67
+ ## Managing Preferences via the CLI
44
68
 
45
- The `aigne doc prefs` command is your primary tool for viewing and managing all saved preferences.
69
+ You can view and manage all your saved preferences using the `aigne doc prefs` command. This allows you to list, activate, deactivate, or permanently remove rules.
46
70
 
47
- ### List All Preferences
71
+ ### Listing All Preferences
48
72
 
49
- To see a formatted list of all your preferences, use the `--list` flag.
73
+ To see all saved preferences, both active and inactive, use the `--list` flag.
50
74
 
51
- ```bash
75
+ ```bash List all preferences icon=lucide:terminal
52
76
  aigne doc prefs --list
53
77
  ```
54
78
 
55
- The output provides a clear overview of each rule:
79
+ The command displays a formatted list explaining the status, scope, ID, and any path limitations for each rule.
56
80
 
57
- ```text
81
+ **Example Output:**
82
+
83
+ ```text Example Output icon=lucide:clipboard-list
58
84
  # User Preferences
59
85
 
60
86
  **Format explanation:**
@@ -63,60 +89,46 @@ The output provides a clear overview of each rule:
63
89
  - ID = Unique preference identifier
64
90
  - Paths = Specific file paths (if applicable)
65
91
 
66
- 🟢 [translation] pref_1a2b3c4d
67
- Keep code and identifiers unchanged during translation, must not translate them.
68
-
69
- ⚪ [structure] pref_5e6f7g8h | Paths: overview.md, tutorials.md
70
- Add 'Next Steps' section at the end of overview and tutorial documents with 2-3 links within the repository.
92
+ 🟢 [structure] pref_a1b2c3d4e5f6g7h8 | Paths: overview.md
93
+ Add a 'Next Steps' section at the end of overview documents.
94
+
95
+ ⚪ [document] pref_i9j0k1l2m3n4o5p6
96
+ Code comments must be written in English.
97
+
71
98
  ```
72
99
 
73
- - **Status (🟢 / ⚪)**: Shows whether a rule is currently active or inactive.
74
- - **Scope**: Indicates where the rule applies (e.g., `translation`, `structure`).
75
- - **ID**: A unique identifier used to manage the rule.
76
- - **Paths**: If a rule is limited to specific files, they will be listed here.
77
-
78
- ### Toggle Preference Status
79
-
80
- You can activate or deactivate preferences using the `--toggle` flag. This is useful for temporarily disabling a rule without deleting it permanently.
100
+ ### Toggling Preference Status
81
101
 
82
- **Interactive Mode**
102
+ If you want to temporarily disable a rule without deleting it, you can toggle its active status. Use the `--toggle` flag.
83
103
 
84
- If you run the command without specifying an ID, an interactive prompt will appear, allowing you to select multiple rules to toggle.
104
+ Running the command without an ID will launch an interactive mode, allowing you to select one or more preferences to toggle:
85
105
 
86
- ```bash
106
+ ```bash Toggle preferences interactively icon=lucide:terminal
87
107
  aigne doc prefs --toggle
88
108
  ```
89
109
 
90
- **By ID**
110
+ To toggle specific rules directly, provide their IDs using the `--id` flag:
91
111
 
92
- To toggle specific rules, provide their IDs using the `--id` option.
93
-
94
- ```bash
95
- aigne doc prefs --toggle --id pref_5e6f7g8h
112
+ ```bash Toggle a specific preference icon=lucide:terminal
113
+ aigne doc prefs --toggle --id pref_i9j0k1l2m3n4o5p6
96
114
  ```
97
115
 
98
- ### Remove Preferences
99
-
100
- To permanently delete one or more preferences, use the `--remove` flag.
116
+ ### Removing Preferences
101
117
 
102
- **Interactive Mode**
118
+ To permanently delete one or more preferences, use the `--remove` flag. This action cannot be undone.
103
119
 
104
- Running the command without an ID will launch an interactive selection prompt.
120
+ For an interactive selection prompt, run the command without an ID:
105
121
 
106
- ```bash
122
+ ```bash Remove preferences interactively icon=lucide:terminal
107
123
  aigne doc prefs --remove
108
124
  ```
109
125
 
110
- **By ID**
126
+ To remove specific rules directly by their ID, use the `--id` flag:
111
127
 
112
- To remove a specific rule, pass its ID.
113
-
114
- ```bash
115
- aigne doc prefs --remove --id pref_1a2b3c4d
128
+ ```bash Remove a specific preference icon=lucide:terminal
129
+ aigne doc prefs --remove --id pref_a1b2c3d4e5f6g7h8
116
130
  ```
117
131
 
118
- This action is irreversible, so use it with care.
119
-
120
- ---
132
+ ## Next Steps
121
133
 
122
- By managing your preferences, you can fine-tune DocSmith's behavior over time, making the documentation process increasingly automated and aligned with your project's specific needs. To see how feedback is provided, you can learn more in the [Update and Refine](./features-update-and-refine.md) guide.
134
+ Managing preferences is a key part of tailoring DocSmith to your project's specific needs. For more customization options, explore the main [Configuration Guide](./configuration.md).
@@ -1,123 +1,134 @@
1
- ---
2
- labels: ["Reference"]
3
- ---
4
-
5
1
  # 管理偏好
6
2
 
7
- DocSmith 旨在通过您的反馈进行学习。当您优化文档并提供更正时,系统可以将这些反馈转化为称为“偏好”的持久、可重用的规则。这确保了您的风格选择、结构约定和具体指令在未来的操作中能够被记住并一致地应用。
3
+ AIGNE DocSmith 旨在从您的反馈中学习。当您优化或更正生成的内容时,DocSmith 可以将这些反馈转化为持久性规则,即偏好。这些规则确保您特定的风格、结构要求和内容策略在未来的文档任务中得到一致应用。所有偏好都存储在项目根目录下 `.aigne/doc-smith/preferences.yml` 文件中,该文件为人类可读的 YAML 格式。
8
4
 
9
- 所有偏好都存储在项目根目录下名为 `.aigne/doc-smith/preferences.yml` 的人类可读 YAML 文件中。虽然您可以查看此文件,但建议使用专用的 `aigne doc prefs` 命令行界面来管理您的偏好。
5
+ ## 偏好生命周期
10
6
 
11
- ## 偏好是如何创建的
7
+ 下图说明了您的反馈如何成为一个可重用的规则,该规则可应用于未来的任务,并通过命令行进行管理。
12
8
 
13
- 偏好在 `aigne doc refine` 等命令的反馈周期中自动生成。其过程如下:
9
+ ```d2 偏好生命周期
10
+ direction: down
14
11
 
15
- ```d2
16
- direction: right
12
+ feedback: {
13
+ label: "1. 用户在 'refine' 或 'translate' 期间\n提供反馈"
14
+ shape: rectangle
15
+ }
17
16
 
18
- User: {
19
- shape: person
20
- label: "用户"
17
+ refiner: {
18
+ label: "2. Feedback Refiner Agent\n分析反馈"
19
+ shape: rectangle
21
20
  }
22
21
 
23
- Refine: "`aigne doc refine` 命令"
22
+ decision: {
23
+ label: "这是一个可重用的策略吗?"
24
+ shape: diamond
25
+ }
24
26
 
25
- FeedbackRefiner: "反馈→规则转换器"
27
+ pref_file: {
28
+ label: "3. preferences.yml\n规则已保存"
29
+ shape: cylinder
30
+ }
26
31
 
27
- PreferencesFile: "preferences.yml" {
28
- shape: document
32
+ future_tasks: {
33
+ label: "4. 未来的任务\n应用已保存的规则"
34
+ shape: rectangle
29
35
  }
30
36
 
31
- User -> Refine: "提供反馈,例如‘不要翻译变量名’"
32
- Refine -> FeedbackRefiner: "发送反馈进行分析"
33
- FeedbackRefiner -> PreferencesFile: "保存新的可重用规则" {
34
- style.animated: true
37
+ cli: {
38
+ label: "5. CLI 管理\n('aigne doc prefs')"
39
+ shape: rectangle
35
40
  }
36
41
 
42
+ feedback -> refiner: "输入"
43
+ refiner -> decision: "分析"
44
+ decision -> pref_file: "是"
45
+ decision -> "丢弃(一次性修复)": "否"
46
+ pref_file -> future_tasks: "应用于"
47
+ cli <-> pref_file: "管理"
48
+
37
49
  ```
38
50
 
39
- 1. **反馈输入**:您在优化会话期间提供自然语言反馈。
40
- 2. **规则生成**:一个内部 Agent 会分析您的反馈,以确定它代表的是可重用策略还是一次性修复。
41
- 3. **规则创建**:如果被认为是可重用的,它会创建一个结构化规则,包含特定的作用域(例如,`document`、`translation`)、唯一的 ID 以及指令本身。
42
- 4. **持久化**:新规则被保存到 `preferences.yml` 文件中,使其在未来的任务中生效。
51
+ ### DocSmith 如何从反馈中学习
52
+
53
+ 当您在 `refine` 或 `translate` 阶段提供反馈时,一个名为 'Feedback Refiner' 的内部 Agent 会分析您的输入。其目标是区分一次性修复(例如,更正拼写错误)和可重用策略(例如,“始终用英语编写代码注释”)。如果它确定反馈代表一个持久性指令,就会创建一个新的偏好规则。
54
+
55
+ 每个规则都有几个关键属性来定义其行为:
56
+
57
+ | 属性 | 描述 |
58
+ |---|---|
59
+ | **id** | 规则的唯一标识符(例如,`pref_a1b2c3d4`)。 |
60
+ | **active** | 一个布尔值(`true`/`false`),指示规则当前是否已启用。 |
61
+ | **scope** | 定义规则的应用时机:`global`、`structure`、`document` 或 `translation`。 |
62
+ | **rule** | 将在未来任务中传递给 AI 的指令。 |
63
+ | **feedback** | 您提供的原始自然语言反馈。 |
64
+ | **createdAt** | 规则创建时的 ISO 8601 时间戳。 |
65
+ | **paths** | 一个可选的文件路径列表。如果存在,该规则仅适用于为这些特定路径生成的内容。 |
43
66
 
44
67
  ## 通过 CLI 管理偏好
45
68
 
46
- `aigne doc prefs` 命令是您查看和管理所有已保存偏好的主要工具。
69
+ 您可以使用 `aigne doc prefs` 命令查看和管理所有已保存的偏好。这允许您列出、激活、停用或永久删除规则。
47
70
 
48
71
  ### 列出所有偏好
49
72
 
50
- 要查看所有偏好的格式化列表,请使用 `--list` 标志。
73
+ 要查看所有已保存的偏好(包括活动和非活动的),请使用 `--list` 标志。
51
74
 
52
- ```bash
75
+ ```bash 列出所有偏好 icon=lucide:terminal
53
76
  aigne doc prefs --list
54
77
  ```
55
78
 
56
- 输出清晰地展示了每个规则的概览:
79
+ 该命令会显示一个格式化列表,解释每个规则的状态、范围、ID 以及任何路径限制。
57
80
 
58
- ```text
81
+ **示例输出:**
82
+
83
+ ```text 示例输出 icon=lucide:clipboard-list
59
84
  # 用户偏好
60
85
 
61
86
  **格式说明:**
62
87
  - 🟢 = 活动偏好, ⚪ = 非活动偏好
63
- - [scope] = 偏好作用域 (global, structure, document, translation)
64
- - ID = 唯一偏好标识符
88
+ - [scope] = 偏好范围 (global, structure, document, translation)
89
+ - ID = 偏好唯一标识符
65
90
  - Paths = 特定文件路径 (如果适用)
66
91
 
67
- 🟢 [translation] pref_1a2b3c4d
68
- 在翻译期间保持代码和标识符不变,不得翻译它们。
69
-
70
- ⚪ [structure] pref_5e6f7g8h | 路径:overview.md, tutorials.md
71
- 在概述和教程文档末尾添加“后续步骤”部分,并附上 2-3 个仓库内的链接。
92
+ 🟢 [structure] pref_a1b2c3d4e5f6g7h8 | Paths: overview.md
93
+ 在概览文档末尾添加一个 'Next Steps' 部分。
94
+
95
+ ⚪ [document] pref_i9j0k1l2m3n4o5p6
96
+ 代码注释必须用英语编写。
97
+
72
98
  ```
73
99
 
74
- - **状态 (🟢 / ⚪)**:显示规则当前是活动还是非活动状态。
75
- - **作用域**:指明规则的应用范围(例如,`translation`、`structure`)。
76
- - **ID**:用于管理规则的唯一标识符。
77
- - **路径**:如果规则仅限于特定文件,这些文件将在此处列出。
78
-
79
100
  ### 切换偏好状态
80
101
 
81
- 您可以使用 `--toggle` 标志来激活或停用偏好。这在临时禁用某个规则而不想永久删除它时非常有用。
82
-
83
- **交互模式**
102
+ 如果您想临时禁用某个规则而不删除它,可以切换其活动状态。请使用 `--toggle` 标志。
84
103
 
85
- 如果您在运行命令时未指定 ID,将会出现一个交互式提示,允许您选择多个规则进行切换。
104
+ 不带 ID 运行该命令将启动交互模式,允许您选择一个或多个要切换的偏好:
86
105
 
87
- ```bash
106
+ ```bash 以交互方式切换偏好 icon=lucide:terminal
88
107
  aigne doc prefs --toggle
89
108
  ```
90
109
 
91
- **按 ID 操作**
110
+ 要直接切换特定规则,请使用 `--id` 标志提供其 ID
92
111
 
93
- 要切换特定规则的状态,请使用 `--id` 选项提供其 ID。
94
-
95
- ```bash
96
- aigne doc prefs --toggle --id pref_5e6f7g8h
112
+ ```bash 切换特定偏好 icon=lucide:terminal
113
+ aigne doc prefs --toggle --id pref_i9j0k1l2m3n4o5p6
97
114
  ```
98
115
 
99
- ### 删除偏好
100
-
101
- 要永久删除一个或多个偏好,请使用 `--remove` 标志。
116
+ ### 移除偏好
102
117
 
103
- **交互模式**
118
+ 要永久删除一个或多个偏好,请使用 `--remove` 标志。此操作无法撤销。
104
119
 
105
- 在不带 ID 的情况下运行该命令将启动一个交互式选择提示。
120
+ 要进入交互式选择提示,请不带 ID 运行该命令:
106
121
 
107
- ```bash
122
+ ```bash 以交互方式移除偏好 icon=lucide:terminal
108
123
  aigne doc prefs --remove
109
124
  ```
110
125
 
111
- **按 ID 操作**
126
+ 要通过 ID 直接移除特定规则,请使用 `--id` 标志:
112
127
 
113
- 要删除特定规则,请传递其 ID。
114
-
115
- ```bash
116
- aigne doc prefs --remove --id pref_1a2b3c4d
128
+ ```bash 移除特定偏好 icon=lucide:terminal
129
+ aigne doc prefs --remove --id pref_a1b2c3d4e5f6g7h8
117
130
  ```
118
131
 
119
- 此操作不可逆,请谨慎使用。
120
-
121
- ---
132
+ ## 后续步骤
122
133
 
123
- 通过管理您的偏好,您可以随着时间的推移微调 DocSmith 的行为,使文档处理过程越来越自动化,并与您项目的特定需求保持一致。要了解如何提供反馈,您可以在 [更新与优化](./features-update-and-refine.md) 指南中了解更多信息。
134
+ 管理偏好是根据项目特定需求定制 DocSmith 的关键部分。要了解更多自定义选项,请查阅主要的[配置指南](./configuration.md)