@aigne/doc-smith 0.8.15 → 0.8.16-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 (58) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/agents/chat/chat-system.md +32 -0
  3. package/agents/chat/index.yaml +14 -22
  4. package/agents/chat/skills/generate-document.yaml +15 -0
  5. package/agents/chat/skills/update-document.yaml +24 -0
  6. package/agents/evaluate/generate-report.mjs +7 -0
  7. package/agents/evaluate/index.yaml +6 -0
  8. package/agents/generate/check-need-generate-structure.mjs +12 -4
  9. package/agents/generate/document-structure-tools/add-document.mjs +9 -1
  10. package/agents/generate/document-structure-tools/update-document.mjs +18 -0
  11. package/agents/generate/draw-diagram.yaml +2 -2
  12. package/agents/generate/generate-structure.yaml +3 -2
  13. package/agents/generate/user-review-document-structure.mjs +44 -29
  14. package/agents/init/index.mjs +6 -4
  15. package/agents/media/load-media-description.mjs +2 -1
  16. package/agents/schema/document-structure-item.yaml +3 -0
  17. package/agents/schema/document-structure-refine-item.yaml +3 -0
  18. package/agents/schema/document-structure.yaml +3 -0
  19. package/agents/update/pre-check-generate-diagram.yaml +1 -1
  20. package/agents/update/user-review-document.mjs +56 -42
  21. package/agents/utils/document-icon-generate.yaml +52 -0
  22. package/agents/utils/document-title-streamline.yaml +48 -0
  23. package/agents/utils/generate-document-icon-if-needed.mjs +93 -0
  24. package/agents/utils/list-docs.mjs +15 -0
  25. package/agents/utils/streamline-document-titles-if-needed.mjs +88 -0
  26. package/aigne.yaml +7 -1
  27. package/package.json +4 -7
  28. package/prompts/common/document/media-file-list-usage-rules.md +8 -2
  29. package/prompts/common/document/openapi-usage-rules.md +174 -21
  30. package/prompts/common/document-structure/document-icon-generate.md +116 -0
  31. package/prompts/common/document-structure/document-structure-rules.md +8 -3
  32. package/prompts/common/document-structure/document-title-streamline.md +86 -0
  33. package/prompts/common/document-structure/openapi-usage-rules.md +28 -0
  34. package/prompts/common/document-structure/output-constraints.md +9 -0
  35. package/prompts/detail/custom/{custom-code-block.md → code-block-usage-rules.md} +43 -16
  36. package/prompts/detail/custom/custom-components/x-card-usage-rules.md +62 -0
  37. package/prompts/detail/custom/custom-components/x-cards-usage-rules.md +75 -0
  38. package/prompts/detail/custom/custom-components/x-field-desc-usage-rules.md +86 -0
  39. package/prompts/detail/custom/custom-components/x-field-group-usage-rules.md +95 -0
  40. package/prompts/detail/custom/custom-components/x-field-usage-rules.md +189 -0
  41. package/prompts/detail/custom/custom-components-usage-rules.md +10 -534
  42. package/prompts/detail/{d2-diagram → diagram}/rules.md +5 -3
  43. package/prompts/detail/generate/document-rules.md +6 -0
  44. package/prompts/detail/generate/system-prompt.md +3 -2
  45. package/prompts/detail/generate/user-prompt.md +7 -1
  46. package/prompts/detail/update/system-prompt.md +3 -3
  47. package/prompts/structure/generate/system-prompt.md +2 -5
  48. package/prompts/structure/generate/user-prompt.md +14 -39
  49. package/types/document-structure-schema.mjs +1 -0
  50. package/utils/evaluate/report-utils.mjs +7 -3
  51. package/agents/utils/docs-fs-actor.yaml +0 -27
  52. package/agents/utils/fs.mjs +0 -60
  53. /package/prompts/detail/{d2-diagram → diagram}/guide.md +0 -0
  54. /package/prompts/detail/{d2-diagram → diagram}/official-examples.md +0 -0
  55. /package/prompts/detail/{d2-diagram → diagram}/pre-check.md +0 -0
  56. /package/prompts/detail/{d2-diagram → diagram}/role-and-personality.md +0 -0
  57. /package/prompts/detail/{d2-diagram → diagram}/system-prompt.md +0 -0
  58. /package/prompts/detail/{d2-diagram → diagram}/user-prompt.md +0 -0
@@ -1,542 +1,18 @@
1
1
  <custom_components_usage_rules>
2
- When generating document details, you can use the following custom components at appropriate locations based on their descriptions and functionality to enhance document presentation:
3
-
4
- ## XCard: Individual link display card
5
-
6
- Suitable for displaying individual links with a richer and more visually appealing presentation format.
7
-
8
- ### Attributes
9
-
10
- - `data-title` (required): Card title.
11
- - `data-icon` (optional): Icon identifier (e.g., lucide:icon-name or material-symbols:rocket-outline).
12
- - Icons should prioritize Lucide (lucide:icon-name). If not available in Lucide, use Iconify (collection:icon-name, e.g., material-symbols:rocket-outline).
13
- - `data-image` (optional): Image URL, can coexist with icon.
14
- - **Requirement**: At least one of `data-icon` or `data-image` must be provided.
15
- - It's recommended to always provide data-icon.
16
- - `data-href` (optional): Navigation link for clicking the card or button.
17
- - `data-horizontal` (optional): Whether to use horizontal layout.
18
- - `data-cta` (optional): Button text (call to action).
19
-
20
- ### Children
21
-
22
- - Must be written within `<x-card>...</x-card>` children.
23
- - **Plain Text Only**: All markdown formatting is prohibited, including inline formats like `code`, **bold**, _italic_, [links](), and block-level formats like headers (# ##), lists (- \*), code blocks (```), tables (|), and any other markdown syntax. Only plain text content is allowed.
24
-
25
- ### Good Examples
26
-
27
- Example 1: Basic card with icon and description
28
-
29
- ```md
30
- <x-card data-title="alarm()" data-icon="lucide:alarm-clock"> SIGALRM: Sent when a real-time timer has expired. </x-card>
31
- ```
32
-
33
- Example 2: Horizontal card layout
34
-
35
- ```md
36
- <x-card data-title="Horizontal card" data-icon="lucide:atom" data-horizontal="true">
37
- This is an example of a horizontal card.
38
- </x-card>
39
- ```
40
-
41
- ### Bad Examples
42
-
43
- Example 1: Inline Markdown formatting in card content
44
-
45
- ```md
46
- <x-card data-title="alarm()" data-icon="lucide:alarm-clock"> `SIGALRM`: Sent when a real-time timer has expired. </x-card>
47
- ```
48
-
49
- Example 2: Code block inside card content
50
-
51
- ````md
52
- <x-card data-title="ctrl_break()" data-icon="lucide:keyboard">
53
- Creates a listener for "ctrl-break" events.
54
-
55
- ```rust
56
- use tokio::signal::windows::ctrl_break;
57
-
58
- #[tokio::main]
59
- async fn main() -> std::io::Result<()> {
60
- let mut stream = ctrl_break()?;
61
- stream.recv().await;
62
- println!("got ctrl-break");
63
- Ok(())
64
- }
65
- ```
66
-
67
- ````
68
-
69
-
70
- ## XCards: Multiple cards container
71
-
72
- Suitable for displaying multiple links using a card list format, providing a richer and more visually appealing presentation.
73
-
74
- ### Attributes
75
-
76
- - data-columns (optional): Must be an **integer ≥ 2**. Values below 2 are disallowed. Default is 2.
77
-
78
- ### Children
79
-
80
- - Must contain multiple `<x-card>` elements internally.
81
-
82
- ### Usage Rules
83
-
84
- - **Visual Consistency**: All `<x-card>` elements within the same `<x-cards>` must maintain visual consistency:
85
- - It's recommended to always provide data-icon for each card.
86
- - Or all cards should have data-image.
87
- - Avoid mixing (some with icons, some with only images).
88
-
89
- ### Good Examples
90
-
91
- Example 1: Three-column cards with icons
92
-
93
- ```md
94
- <x-cards data-columns="3">
95
- <x-card data-title="Feature 1" data-icon="lucide:rocket">Description of Feature 1.</x-card>
96
- <x-card data-title="Feature 2" data-icon="lucide:bolt">Description of Feature 2.</x-card>
97
- <x-card data-title="Feature 3" data-icon="material-symbols:rocket-outline">Description of Feature 3.</x-card>
98
- </x-cards>
99
- ```
100
-
101
- Example 2: Two-column cards with images
102
-
103
- ```md
104
- <x-cards data-columns="2">
105
- <x-card data-title="Card A" data-image="https://picsum.photos/id/10/300/300">Content A</x-card>
106
- <x-card data-title="Card B" data-image="https://picsum.photos/id/11/300/300">Content B</x-card>
107
- </x-cards>
108
- ```
109
-
110
- Example 3: Replace markdown format multiple links
111
-
112
- ```md
113
- For more detailed information on specific features, please refer to the following sections:
114
-
115
- <x-cards data-columns="3">
116
- <x-card data-title="Using Discussions" data-href="/discussions">Introduce how to use discussions</x-card>
117
- <x-card data-title="Using the Blog" data-href="/blog">Introduce how to use the Blog</x-card>
118
- <x-card data-title="Using Chat" data-href="/chat">Introduce how to use Chat</x-card>
119
- </x-cards>
120
- ```
121
-
122
- ### Bad Examples
123
-
124
- Example 1: Using a single-column layout (`data-columns="1"`) is not allowed
125
-
126
- ```md
127
- <x-cards data-columns="1">
128
- <x-card data-title="Feature 1" data-icon="lucide:rocket">Description of Feature 1.</x-card>
129
- <x-card data-title="Feature 2" data-icon="lucide:bolt">Description of Feature 2.</x-card>
130
- </x-cards>
131
- ```
132
-
133
- Example 2: Contains only one `<x-card>` (must include multiple cards)
134
-
135
- ```md
136
- <x-cards data-columns="2">
137
- <x-card data-title="Card A" data-image="https://picsum.photos/id/10/300/300">Content A</x-card>
138
- </x-cards>
139
- ```
140
-
141
- Example 3: Markdown format multiple links
142
-
143
- ```md
144
- For more detailed information on specific features, please refer to the following sections:
145
- - [Using Discussions](./discussions.md)
146
- - [Using the Blog](./blog.md)
147
- - [Using Chat](./chat.md)
148
- ```
149
-
150
- ## XField: Structured data field
151
-
152
- Suitable for displaying API parameters, return values, context data, and any structured data with metadata in a clean, organized format. Supports nested structures for complex data types.
153
-
154
- ### Attributes
155
-
156
- - `data-name` (optional): The name of the field/parameter
157
- - `data-type` (optional): The data type of the field (e.g., "string", "number", "boolean", "symbol", "object", "array", "function")
158
- - `data-default` (optional): Default value for the field
159
- - `data-required` (optional): Whether the field is required ("true" or "false")
160
- - `data-deprecated` (optional): Whether the field is deprecated ("true" or "false")
161
- - `data-desc` (optional): Simple description of the field (plain text only)
162
-
163
- ### Children
164
-
165
- - For simple types (string, number, boolean): children can be empty or contain exactly one `<x-field-desc>` element
166
- - For complex types (object, array), children contain nested `<x-field>` elements and optionally one `<x-field-desc>` element
167
-
168
- ### Usage Rules
169
-
170
- - **Opening/Closing Tags Format**: `<x-field ...></x-field>` for all types
171
- - **Maximum Nesting Depth**: 5 levels (to avoid overly complex structures)
172
- - **Description Mutually Exclusive**: Use either `data-desc` attribute OR `<x-field-desc>` element, not both
173
- - **Single Description Rule**: Only one `<x-field-desc>` element per `<x-field>` is allowed
174
- - **Grouping Requirement**: Wrap the outermost `<x-field>` elements with `<x-field-group>`, even if there's only one `<x-field>` element
175
- - **Recursive Structure**: Use recursive `<x-field>` structures to fully express complex object type hierarchies, decomposing all nested properties into more fundamental types
176
- - **Fixed Value Fields**: For fields that accept a limited set of predefined values (including enums, constants, or fixed strings), use `<x-field>` with the base data type (e.g., "string", "number") in the `data-type` attribute, and list all possible values in the description.
177
- - **Function-Type Fields**: For fields with `data-type="function"`, nest `<x-field>` elements for parameters (`data-name="parameters"`) and return value (`data-name="returnValue"`) **whenever their types are available**.
178
-
179
- ### Good Examples
180
-
181
- Example 1: Simple field with all attributes
182
-
183
- ```md
184
- ### Returns
185
-
186
- <x-field-group>
187
- <x-field data-name="user_id" data-type="string" data-default="u0911" data-required="true" data-deprecated="true" data-desc="Unique identifier for the user. Must be a valid UUID v4 format."></x-field>
188
- </x-field-group>
189
- ```
190
-
191
- Example 2: Field with markdown description
192
-
193
- ```md
194
- ### Context
195
-
196
- <x-field-group>
197
- <x-field data-name="api_key" data-type="string" data-required="true">
198
- <x-field-desc markdown>Your **API key** for authentication. Generate one from the `Settings > API Keys` section. Keep it secure and never expose it in client-side code.</x-field-desc>
199
- </x-field>
200
- </x-field-group>
201
- ```
202
-
203
- Example 3: Nested object structure
204
-
205
- ```md
206
- ### Properties
207
-
208
- <x-field-group>
209
- <x-field data-name="session" data-type="object" data-required="true">
210
- <x-field-desc markdown>Contains all **authentication** and **authorization** data for the current user session. This object is automatically populated after successful login.</x-field-desc>
211
- <x-field data-name="user" data-type="object" data-required="true" data-desc="User basic information">
212
- <x-field data-name="name" data-type="string" data-required="true" data-default="John Doe" data-desc="User name"></x-field>
213
- <x-field data-name="email" data-type="string" data-required="true" data-default="john.doe@example.com">
214
- <x-field-desc markdown>Primary email address used for **login** and **notifications**. Must be a valid email format.</x-field-desc>
215
- </x-field>
216
- <x-field data-name="avatar" data-type="string" data-required="false" data-default="https://example.com/avatars/john-doe.jpg" data-desc="User avatar URL"></x-field>
217
- </x-field>
218
- <x-field data-name="permissions" data-type="array" data-required="true" data-default='["read", "write", "admin"]'>
219
- <x-field-desc markdown>Array of **permission strings** that determine what actions the user can perform. Common values: `"read"`, `"write"`, `"admin"`, `"delete"`.</x-field-desc>
220
- </x-field>
221
- </x-field>
222
- </x-field-group>
223
- ```
224
-
225
- Example 4: Multiple fields for Parameters
226
-
227
- ```md
228
- ### Parameters
229
-
230
- <x-field-group>
231
- <x-field data-name="user_id" data-type="string" data-required="true" data-desc="Unique identifier for the user. Must be a valid UUID v4 format."></x-field>
232
- <x-field data-name="include_profile" data-type="boolean" data-required="false" data-default="false" data-desc="Whether to include the user's profile information in the response"></x-field>
233
- <x-field data-name="options" data-type="object" data-required="false" data-desc="Additional options for the request">
234
- <x-field data-name="format" data-type="string" data-required="false" data-default="json">
235
- <x-field-desc>Response format: `json` or `xml`</x-field-desc>
236
- </x-field>
237
- <x-field data-name="locale" data-type="string" data-required="false" data-default="en" data-desc="Language locale for localized content"></x-field>
238
- </x-field>
239
- </x-field-group>
240
- ```
241
-
242
- Example 5: Enum values with base type and description
2
+ ## Custom Components Usage Rules
243
3
 
244
- ```md
245
- ### Status
246
-
247
- <x-field-group>
248
- <x-field data-name="status" data-type="string" data-required="true" data-default="pending" data-desc="Current status of the request. Possible values: 'pending', 'processing', 'completed', 'failed'"></x-field>
249
- <x-field data-name="priority" data-type="number" data-required="false" data-default="1">
250
- <x-field-desc markdown>Priority level for the task. **Valid values**: `1` (low), `2` (medium), `3` (high), `4` (urgent)</x-field-desc>
251
- </x-field>
252
- </x-field-group>
253
- ```
254
-
255
- Example 6: Function type field with nested parameters and return value
256
-
257
- ```md
258
- ### API Methods
259
-
260
- <x-field-group>
261
- <x-field data-name="authenticate" data-type="function" data-required="true" data-desc="Authenticates a user with email and password">
262
- <x-field data-name="parameters" data-type="object" data-desc="Function parameters">
263
- <x-field data-name="email" data-type="string" data-required="true" data-desc="User's email address"></x-field>
264
- <x-field data-name="password" data-type="string" data-required="true" data-desc="User's password"></x-field>
265
- <x-field data-name="rememberMe" data-type="boolean" data-required="false" data-default="false" data-desc="Whether to keep user logged in"></x-field>
266
- </x-field>
267
- <x-field data-name="returnValue" data-type="object" data-desc="Function return value">
268
- <x-field data-name="success" data-type="boolean" data-required="true" data-desc="Whether authentication was successful"></x-field>
269
- <x-field data-name="token" data-type="string" data-required="false" data-desc="JWT token if authentication successful"></x-field>
270
- <x-field data-name="user" data-type="object" data-required="false" data-desc="User information if authentication successful">
271
- <x-field data-name="id" data-type="string" data-required="true" data-desc="User ID"></x-field>
272
- <x-field data-name="name" data-type="string" data-required="true" data-desc="User's display name"></x-field>
273
- <x-field data-name="email" data-type="string" data-required="true" data-desc="User's email address"></x-field>
274
- </x-field>
275
- </x-field>
276
- </x-field>
277
- </x-field-group>
278
- ```
279
-
280
- ### Bad Examples
281
-
282
- Example 1: Using self-closing tag (violates "Opening/Closing Tags Format" rule)
283
-
284
- ```md
285
- <x-field-group>
286
- <x-field data-name="user_id" data-type="string" data-required="true" data-desc="User identifier" />
287
- </x-field-group>
288
- ```
289
-
290
- Example 2: Using both `data-desc` and `<x-field-desc>` (violates "Description Mutually Exclusive" rule)
291
-
292
- ```md
293
- <x-field-group>
294
- <x-field data-name="api_key" data-type="string" data-required="true" data-desc="API key for authentication">
295
- <x-field-desc markdown>Your **API key** for authentication. Keep it secure and never expose it.</x-field-desc>
296
- </x-field>
297
- </x-field-group>
298
- ```
299
-
300
- Example 3: Using multiple `<x-field-desc>` elements (violates "Single Description Rule")
301
-
302
- ```md
303
- <x-field-group>
304
- <x-field data-name="config" data-type="object" data-required="true">
305
- <x-field-desc markdown>Configuration object for the application.</x-field-desc>
306
- <x-field-desc markdown>Contains all runtime settings and preferences.</x-field-desc>
307
- </x-field>
308
- </x-field-group>
309
- ```
310
-
311
- Example 4: Nesting other child elements (violates "Children" rule)
312
-
313
- ```md
314
- <x-field-group>
315
- <x-field data-name="user" data-type="object" data-required="true">
316
- <div>User information</div>
317
- <x-field data-name="name" data-type="string" data-required="true" data-desc="User name"></x-field>
318
- </x-field>
319
- </x-field-group>
320
- ```
321
-
322
- Example 5: Missing x-field-group wrapper (violates "Grouping Requirement" rule)
323
-
324
- ```md
325
- <x-field data-name="apiConfig" data-type="object" data-required="true" data-desc="API configuration object">
326
- <x-field data-name="baseUrl" data-type="string" data-required="true" data-desc="Base URL for API calls"></x-field>
327
- <x-field data-name="timeout" data-type="number" data-required="false" data-default="5000" data-desc="Request timeout in milliseconds"></x-field>
328
- </x-field>
329
- ```
330
-
331
- Example 6: Exceeding maximum nesting depth (violates "Maximum Nesting Depth" rule)
332
-
333
- ```md
334
- <x-field-group>
335
- <x-field data-name="level1" data-type="object" data-required="true">
336
- <x-field data-name="level2" data-type="object" data-required="true">
337
- <x-field data-name="level3" data-type="object" data-required="true">
338
- <x-field data-name="level4" data-type="object" data-required="true">
339
- <x-field data-name="level5" data-type="object" data-required="true">
340
- <x-field data-name="level6" data-type="string" data-required="true" data-desc="Too deep nesting"></x-field>
341
- </x-field>
342
- </x-field>
343
- </x-field>
344
- </x-field>
345
- </x-field>
346
- </x-field-group>
347
- ```
348
-
349
- ## XFieldDesc Rich field description
350
-
351
- Used to provide rich text descriptions for `<x-field>` elements, supporting inline markdown formatting for enhanced readability.
352
-
353
- ### Attributes
354
-
355
- - `markdown` (required): **MUST** be set to "markdown" . This attribute is mandatory and cannot be omitted
356
- - **Validation**: `<x-field-desc>` without `markdown` attribute will be rejected
357
-
358
- ### Children
359
-
360
- - Supports **bold text**, `inline code`, _italic text_, and other inline markdown
361
- - Description text must be provided as child content of `<x-field-desc>`, not as the value of the `markdown` attribute
362
- - **Inline Markdown Only**: Allow only inline Markdown (e.g., `**bold**`, *italic*, `inline code`); block elements like code blocks, headings, lists, or tables are **not allowed**.
363
-
364
- ### Usage Rules
365
-
366
- - **Parent Requirement**: Must be child of `<x-field>`: `<x-field-desc>` can only appear as a child element of `<x-field>` components
367
-
368
- ### Good Examples
369
-
370
- Example 1: Basic markdown description
371
-
372
- ```md
373
- <x-field-desc markdown>Your **API key** for authentication. Generate one from the `Settings > API Keys` section. Keep it secure and never expose it in client-side code.</x-field-desc>
374
- ```
375
-
376
- Example 2: Description with inline code
377
-
378
- ```md
379
- <x-field-desc markdown>**JWT token** containing user identity and permissions. Expires in `24 hours` by default. Use the `refresh_token` to obtain a new one.</x-field-desc>
380
- ```
381
-
382
- ### Bad Examples
383
-
384
- Example 1: Missing markdown attribute (violates "markdown attribute required" rule)
385
-
386
- ```md
387
- <x-field data-name="api_key" data-type="string" data-required="true">
388
- <x-field-desc>Your **API key** for authentication.</x-field-desc>
389
- </x-field>
390
- ```
391
-
392
- Example 2: Incorrect markdown attribute usage (violates "markdown attribute format" rule)
393
-
394
- ```md
395
- <x-field data-name="api_key" data-type="string" data-required="true">
396
- <x-field-desc markdown="Your **API key** for authentication."></x-field-desc>
397
- </x-field>
398
- ```
399
-
400
- Example 3: Using self-closing tag (violates "opening/closing tags format" rule)
401
-
402
- ```md
403
- <x-field data-name="user_id" data-type="string" data-required="true">
404
- <x-field-desc markdown />
405
- </x-field>
406
- ```
407
-
408
- Example 4: Containing block-level elements (violates "Inline Content Only" rule)
409
-
410
- ````md
411
- <x-field data-name="config" data-type="object" data-required="true">
412
- <x-field-desc markdown>
413
- **Configuration settings** for the application.
414
-
415
- ## Important Notes
416
- - Set debug to true for development
417
- - Use production database in production
418
-
419
- ```javascript
420
- const config = { debug: true };
421
- ```
422
- </x-field-desc>
423
- </x-field>
424
- ````
425
-
426
- Example 5: Used outside of x-field component (violates "Parent Requirement" rule)
427
-
428
- ```md
429
- <x-field-desc markdown>This description is not inside an x-field component.</x-field-desc>
430
- ```
431
-
432
- Example 6: Used as child of other components (violates "Parent Requirement" rule)
433
-
434
- ```md
435
- <x-field-group>
436
- <x-field data-name="name" data-type="string" data-required="true" data-desc="User name"></x-field>
437
- <x-field-desc markdown>This description is not inside an x-field component.</x-field-desc>
438
- </x-field-group>
439
- ```
440
-
441
- ## XFieldGroup: Field grouping container
442
-
443
- Used to group multiple related `<x-field>` elements at the top level, indicating they belong to the same object or context. This provides better organization and visual grouping for related parameters.
444
-
445
- ### Attributes
446
-
447
- - No attributes required
448
-
449
- ### Children
450
-
451
- - Only `<x-field>` elements are allowed as children
452
-
453
- ### Usage Rules
454
-
455
- - **Top-Level Only**: Used only at the top level for grouping related `<x-field>` elements. Cannot be nested inside other `<x-field>` or `<x-field-group>` elements
456
- - **Structured Data Only**: Use `<x-field-group>` for fields **other than simple types** (`string`, `number`, `boolean`, `symbol`), e.g., Properties, Context, Parameters, Return values. For simple-type fields, use plain Markdown text.
457
- - **Spacing Around**: Always insert a blank line before and after `<x-field-group>` when it’s adjacent to Markdown content.
458
-
459
- ### Good Examples
460
-
461
- Example 1: Product information fields
462
-
463
- ```md
464
- <x-field-group>
465
- <x-field data-name="name" data-type="string" data-required="true" data-desc="The name of the product."></x-field>
466
- <x-field data-name="description" data-type="string" data-required="false" data-desc="An optional description for the product."></x-field>
467
- <x-field data-name="type" data-type="string" data-required="false" data-desc="The type of product (e.g., 'service', 'good')."></x-field>
468
- <x-field data-name="price" data-type="number" data-required="true" data-default="0">
469
- <x-field-desc markdown>Product price in **USD**. Must be a positive number with up to 2 decimal places.</x-field-desc>
470
- </x-field>
471
- </x-field-group>
472
- ```
473
-
474
- ### Bad Examples
475
-
476
- Example 1: Nested inside x-field component (violates "Top-Level Only" rule)
477
-
478
- ```md
479
- <x-field data-name="user" data-type="object" data-required="true">
480
- <x-field-group>
481
- <x-field data-name="name" data-type="string" data-required="true" data-desc="User name"></x-field>
482
- <x-field data-name="email" data-type="string" data-required="true" data-desc="User email"></x-field>
483
- </x-field-group>
484
- </x-field>
485
- ```
486
-
487
- Example 2: Nested inside another x-field-group (violates "Top-Level Only" rule)
488
-
489
- ```md
490
- <x-field-group>
491
- <x-field data-name="user" data-type="object" data-required="true" data-desc="User information"></x-field>
492
- <x-field-group>
493
- <x-field data-name="name" data-type="string" data-required="true" data-desc="User name"></x-field>
494
- <x-field data-name="email" data-type="string" data-required="true" data-desc="User email"></x-field>
495
- </x-field-group>
496
- </x-field-group>
497
- ```
498
-
499
- Example 3: Containing non-x-field elements (violates "Only x-field elements allowed" rule)
500
-
501
- ```md
502
- <x-field-group>
503
- <x-field data-name="name" data-type="string" data-required="true" data-desc="User name"></x-field>
504
- <div>Additional information</div>
505
- <x-field data-name="email" data-type="string" data-required="true" data-desc="User email"></x-field>
506
- </x-field-group>
507
- ```
508
-
509
- Example 4: Empty x-field-group (violates "Must contain x-field elements" rule)
510
-
511
- ```md
512
- <x-field-group>
513
- </x-field-group>
514
- ```
515
-
516
- Example 5: Using x-field-group for simple-type (violates "Structured Data Only" rule)
517
-
518
- ```md
519
- ### appName
4
+ When generating document details, you can use the following custom components at appropriate locations based on their descriptions and functionality to enhance document presentation:
520
5
 
521
- <x-field-group>
522
- <x-field data-name="appName" data-type="string" data-required="true" data-desc="specifies the name of the application"></x-field>
523
- </x-field-group>
524
- ```
6
+ ### XCard Relate Component Usage Rules
7
+ {% include "./custom-components/x-card-usage-rules.md" %}
8
+ {% include "./custom-components/x-cards-usage-rules.md" %}
525
9
 
526
- Example 6: Missing blank line before x-field-group (violates "Spacing Around" rule)
10
+ ### XField Relate Component Usage Rules
527
11
 
528
- ```md
529
- **Parameters**
530
- <x-field-group>
531
- <x-field data-name="initialState" data-type="any" data-required="false">
532
- <x-field-desc markdown>The initial state value.</x-field-desc>
533
- </x-field>
534
- </x-field-group>
12
+ XField-related components are designed to enhance API-related documentation and should be used only for API-type documents. For other document types that need XField-style presentation, prefer displaying the information using a Markdown table.
535
13
 
536
- `useReducer` returns an array with two items:
537
- <x-field-group>
538
- <x-field data-name="dispatch" data-type="function" data-desc="A function that you can call with an action to update the state."></x-field>
539
- </x-field-group>
540
- ```
14
+ {% include "./custom-components/x-field-usage-rules.md" %}
15
+ {% include "./custom-components/x-field-desc-usage-rules.md" %}
16
+ {% include "./custom-components/x-field-group-usage-rules.md" %}
541
17
 
542
18
  </custom_components_usage_rules>
@@ -1,15 +1,17 @@
1
1
  <diagram_generation_rules>
2
2
 
3
+ ## Diagram Generation Rules
4
+
3
5
  You must analyze the provided inputs to determine if a diagram is needed and where to insert a placeholder. You must not generate the diagram itself (e.g., no Mermaid, PlantUML, or other code). You are only deciding and placing the placeholder.
4
6
 
5
- ## Inputs
7
+ ### Inputs
6
8
 
7
9
  - `<document_content>`: The main body of text to be evaluated.
8
10
  - `<previous_generation_content>`: The content from the previous run, which may contain DIAGRAM_PLACEHOLDER.
9
11
  - `<feedback>`: Specific user instructions for this run (e.g., "add a diagram," "remove the diagram").
10
12
  - `<content_review_feedback>`: General automated or human feedback on the content.
11
13
 
12
- ## Scoring conditions
14
+ ### Scoring conditions
13
15
 
14
16
  - `add`: If `<feedback>` explicitly requests to add a diagram, ignore other conditions, +30000
15
17
  - `remove`: If `<feedback>` explicitly requests to remove a diagram, ignore other conditions, -30000
@@ -22,7 +24,7 @@ You must analyze the provided inputs to determine if a diagram is needed and whe
22
24
  - `hierarchy`: If `<document_content>` describes a clear hierarchy (linked sub-docs / deeply nested sections), +1
23
25
  - `introductory-major`: If `<document_content>` is an introductory page for a major section, +1
24
26
 
25
- ## Output Requirements
27
+ ### Output Requirements
26
28
  - `details` is an array. Each element must include:
27
29
  - `type`: matched scoring condition's type name
28
30
  - `score`: matched scoring condition's score
@@ -2,6 +2,12 @@
2
2
  <document_rules>
3
3
 
4
4
  Documentation Generation Rules:
5
+ - **Opening Hook Requirement:** The document must begin with a compelling, relaxed, and concise introductory paragraph (The "Hook").
6
+ - **Hook Content:** This paragraph must clearly state the specific outcome, knowledge, or skill the reader will gain upon completing the document (Preferably 50 words or less).
7
+ - **Hook Variation:** To maintain a natural reading flow and avoid a repetitive pattern, the Hook must be generated using one of the following varied structural approaches:
8
+ 1. **Direct Promise:** Start with a clear "You will achieve..." or "By the end, you'll master..." statement.
9
+ 2. **Question-Led:** Begin by posing a relevant question to engage the reader's interest.
10
+ 3. **Problem/Scenario:** Start by briefly acknowledging a common difficulty (the pain point) and positioning the document's content as the solution.
5
11
  - When a section contains sub-documents, display only a brief overview and direct users to the sub-documents for detailed information
6
12
  - Each document section should include: a title, introductory content, multiple subsections, and a summary
7
13
  - Since API names are already specified in document titles, avoid repeating them in subheadings—use sub-API names directly
@@ -35,15 +35,16 @@ Glossary of specialized terms. Please ensure correct spelling when using these t
35
35
  {% include "../../common/document/content-rules-core.md" %}
36
36
 
37
37
  Documentation content generation rules:
38
+
38
39
  {% include "./document-rules.md" %}
39
40
 
40
41
  {% include "../custom/custom-components-usage-rules.md" %}
41
42
 
42
- Custom code block generation rules:
43
- {% include "../custom/custom-code-block.md" %}
43
+ {% include "../custom/code-block-usage-rules.md" %}
44
44
 
45
45
  {% include "../../common/document/media-file-list-usage-rules.md" %}
46
46
 
47
+ {% include "../../common/document/openapi-usage-rules.md" %}
47
48
 
48
49
  </content_generation_rules>
49
50
 
@@ -26,8 +26,14 @@
26
26
 
27
27
  </detail_data_source>
28
28
 
29
+ {% if openAPISpec %}
30
+ <openapi_spec_content>
29
31
 
30
- {% include "../../common/document/openapi-usage-rules.md" %}
32
+ ## OpenAPI File Content
33
+ {{ openAPISpec }}
34
+
35
+ </openapi_spec_content>
36
+ {% endif %}
31
37
 
32
38
  {% include "./detail-example.md" %}
33
39
 
@@ -30,16 +30,16 @@ Glossary of specialized terms. Please ensure correct spelling when using these t
30
30
  {% include "../../common/document/content-rules-core.md" %}
31
31
 
32
32
  Documentation content optimization rules:
33
+
33
34
  {% include "../generate/document-rules.md" %}
34
35
 
35
36
  {% include "../custom/custom-components-usage-rules.md" %}
36
37
 
37
- Custom code block optimization rules:
38
- {% include "../custom/custom-code-block.md" %}
38
+ {% include "../custom/code-block-usage-rules.md" %}
39
39
 
40
40
  {% include "../../common/document/media-file-list-usage-rules.md" %}
41
41
 
42
- {% include "../d2-diagram/rules.md" %}
42
+ {% include "../diagram/rules.md" %}
43
43
 
44
44
  </content_optimization_rules>
45
45
 
@@ -1,16 +1,13 @@
1
1
  <role_and_goal>
2
2
  You are an AI document strategist with the personality of an **INTJ (The Architect)**. Your core strengths are strategic thinking, understanding complex systems, and creating logically sound blueprints. You are a perfectionist, rigorously logical, and can anticipate future challenges.
3
-
4
3
  </role_and_goal>
5
4
 
6
-
7
5
  {% include "../../common/document-structure/glossary.md" %}
8
6
 
9
-
10
7
  {% include "../../common/document-structure/document-structure-rules.md" %}
11
8
 
12
-
13
9
  {% include "../../common/document-structure/conflict-resolution-guidance.md" %}
14
10
 
15
-
16
11
  {% include "../../common/document-structure/output-constraints.md" %}
12
+
13
+ {% include "../../common/document-structure/openapi-usage-rules.md" %}