@aigne/doc-smith 0.8.16-beta → 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 (46) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/agents/evaluate/generate-report.mjs +7 -0
  3. package/agents/evaluate/index.yaml +6 -0
  4. package/agents/generate/check-need-generate-structure.mjs +8 -4
  5. package/agents/generate/document-structure-tools/add-document.mjs +4 -0
  6. package/agents/generate/document-structure-tools/update-document.mjs +11 -0
  7. package/agents/generate/draw-diagram.yaml +2 -2
  8. package/agents/generate/generate-structure.yaml +3 -2
  9. package/agents/init/index.mjs +6 -4
  10. package/agents/media/load-media-description.mjs +2 -1
  11. package/agents/schema/document-structure-item.yaml +3 -0
  12. package/agents/schema/document-structure-refine-item.yaml +3 -0
  13. package/agents/schema/document-structure.yaml +3 -0
  14. package/agents/update/pre-check-generate-diagram.yaml +1 -1
  15. package/agents/utils/document-icon-generate.yaml +52 -0
  16. package/agents/utils/generate-document-icon-if-needed.mjs +93 -0
  17. package/aigne.yaml +2 -0
  18. package/package.json +3 -7
  19. package/prompts/common/document/media-file-list-usage-rules.md +8 -2
  20. package/prompts/common/document/openapi-usage-rules.md +174 -21
  21. package/prompts/common/document-structure/document-icon-generate.md +116 -0
  22. package/prompts/common/document-structure/document-structure-rules.md +8 -3
  23. package/prompts/common/document-structure/openapi-usage-rules.md +28 -0
  24. package/prompts/common/document-structure/output-constraints.md +9 -0
  25. package/prompts/detail/custom/{custom-code-block.md → code-block-usage-rules.md} +43 -16
  26. package/prompts/detail/custom/custom-components/x-card-usage-rules.md +62 -0
  27. package/prompts/detail/custom/custom-components/x-cards-usage-rules.md +75 -0
  28. package/prompts/detail/custom/custom-components/x-field-desc-usage-rules.md +86 -0
  29. package/prompts/detail/custom/custom-components/x-field-group-usage-rules.md +95 -0
  30. package/prompts/detail/custom/custom-components/x-field-usage-rules.md +189 -0
  31. package/prompts/detail/custom/custom-components-usage-rules.md +10 -534
  32. package/prompts/detail/{d2-diagram → diagram}/rules.md +5 -3
  33. package/prompts/detail/generate/document-rules.md +6 -0
  34. package/prompts/detail/generate/system-prompt.md +3 -2
  35. package/prompts/detail/generate/user-prompt.md +7 -1
  36. package/prompts/detail/update/system-prompt.md +3 -3
  37. package/prompts/structure/generate/system-prompt.md +2 -5
  38. package/prompts/structure/generate/user-prompt.md +14 -39
  39. package/types/document-structure-schema.mjs +1 -0
  40. package/utils/evaluate/report-utils.mjs +7 -3
  41. /package/prompts/detail/{d2-diagram → diagram}/guide.md +0 -0
  42. /package/prompts/detail/{d2-diagram → diagram}/official-examples.md +0 -0
  43. /package/prompts/detail/{d2-diagram → diagram}/pre-check.md +0 -0
  44. /package/prompts/detail/{d2-diagram → diagram}/role-and-personality.md +0 -0
  45. /package/prompts/detail/{d2-diagram → diagram}/system-prompt.md +0 -0
  46. /package/prompts/detail/{d2-diagram → diagram}/user-prompt.md +0 -0
@@ -0,0 +1,86 @@
1
+ <x-field-desc-usage-rules>
2
+ ## XFieldDesc Usage Rules
3
+
4
+ XFieldDesc is rich field description. Used to provide rich text descriptions for `<x-field>` elements, supporting inline markdown formatting for enhanced readability.
5
+
6
+ ### Attributes
7
+
8
+ - `markdown` (required): **MUST** be set to "markdown" . This attribute is mandatory and cannot be omitted
9
+ - **Validation**: `<x-field-desc>` without `markdown` attribute will be rejected
10
+
11
+ ### Children
12
+
13
+ - Supports **bold text**, `inline code`, _italic text_, and other inline markdown
14
+ - Description text must be provided as child content of `<x-field-desc>`, not as the value of the `markdown` attribute
15
+ - **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**.
16
+
17
+ ### Usage Rules
18
+
19
+ - **Parent Requirement**: Must be child of `<x-field>`: `<x-field-desc>` can only appear as a child element of `<x-field>` components
20
+
21
+ ### Good Examples
22
+
23
+ - Example 1: Basic markdown description
24
+ ```md
25
+ <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>
26
+ ```
27
+
28
+ - Example 2: Description with inline code
29
+ ```md
30
+ <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>
31
+ ```
32
+
33
+ ### Bad Examples
34
+
35
+ - Example 1: Missing markdown attribute (violates "markdown attribute required" rule)
36
+ ```md
37
+ <x-field data-name="api_key" data-type="string" data-required="true">
38
+ <x-field-desc>Your **API key** for authentication.</x-field-desc>
39
+ </x-field>
40
+ ```
41
+
42
+ - Example 2: Incorrect markdown attribute usage (violates "markdown attribute format" rule)
43
+ ```md
44
+ <x-field data-name="api_key" data-type="string" data-required="true">
45
+ <x-field-desc markdown="Your **API key** for authentication."></x-field-desc>
46
+ </x-field>
47
+ ```
48
+
49
+ - Example 3: Using self-closing tag (violates "opening/closing tags format" rule)
50
+ ```md
51
+ <x-field data-name="user_id" data-type="string" data-required="true">
52
+ <x-field-desc markdown />
53
+ </x-field>
54
+ ```
55
+
56
+ - Example 4: Containing block-level elements (violates "Inline Content Only" rule)
57
+ ````md
58
+ <x-field data-name="config" data-type="object" data-required="true">
59
+ <x-field-desc markdown>
60
+ **Configuration settings** for the application.
61
+
62
+ ## Important Notes
63
+ - Set debug to true for development
64
+ - Use production database in production
65
+
66
+ ```javascript
67
+ const config = { debug: true };
68
+ ```
69
+ </x-field-desc>
70
+ </x-field>
71
+ ````
72
+
73
+ - Example 5: Used outside of x-field component (violates "Parent Requirement" rule)
74
+ ```md
75
+ <x-field-desc markdown>This description is not inside an x-field component.</x-field-desc>
76
+ ```
77
+
78
+ - Example 6: Used as child of other components (violates "Parent Requirement" rule)
79
+ ```md
80
+ <x-field-group>
81
+ <x-field data-name="name" data-type="string" data-required="true" data-desc="User name"></x-field>
82
+ <x-field-desc markdown>This description is not inside an x-field component.</x-field-desc>
83
+ </x-field-group>
84
+ ```
85
+
86
+ </x-field-desc-usage-rules>
@@ -0,0 +1,95 @@
1
+ <x-field-group-usage-rules>
2
+ ## XFieldGroup Usage Rules
3
+
4
+ XFieldGroup is `<x-field>` grouping container. 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.
5
+
6
+ ### Attributes
7
+
8
+ - No attributes required
9
+
10
+ ### Children
11
+
12
+ - Only `<x-field>` elements are allowed as children
13
+
14
+ ### Usage Rules
15
+
16
+ - **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
17
+ - **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.
18
+ - **Spacing Around**: Always insert a blank line before and after `<x-field-group>` when it’s adjacent to Markdown content.
19
+
20
+ ### Good Examples
21
+
22
+ - Example 1: Product information fields
23
+ ```md
24
+ <x-field-group>
25
+ <x-field data-name="name" data-type="string" data-required="true" data-desc="The name of the product."></x-field>
26
+ <x-field data-name="description" data-type="string" data-required="false" data-desc="An optional description for the product."></x-field>
27
+ <x-field data-name="type" data-type="string" data-required="false" data-desc="The type of product (e.g., 'service', 'good')."></x-field>
28
+ <x-field data-name="price" data-type="number" data-required="true" data-default="0">
29
+ <x-field-desc markdown>Product price in **USD**. Must be a positive number with up to 2 decimal places.</x-field-desc>
30
+ </x-field>
31
+ </x-field-group>
32
+ ```
33
+
34
+ ### Bad Examples
35
+
36
+ - Example 1: Nested inside x-field component (violates "Top-Level Only" rule)
37
+ ```md
38
+ <x-field data-name="user" data-type="object" data-required="true">
39
+ <x-field-group>
40
+ <x-field data-name="name" data-type="string" data-required="true" data-desc="User name"></x-field>
41
+ <x-field data-name="email" data-type="string" data-required="true" data-desc="User email"></x-field>
42
+ </x-field-group>
43
+ </x-field>
44
+ ```
45
+
46
+ - Example 2: Nested inside another x-field-group (violates "Top-Level Only" rule)
47
+ ```md
48
+ <x-field-group>
49
+ <x-field data-name="user" data-type="object" data-required="true" data-desc="User information"></x-field>
50
+ <x-field-group>
51
+ <x-field data-name="name" data-type="string" data-required="true" data-desc="User name"></x-field>
52
+ <x-field data-name="email" data-type="string" data-required="true" data-desc="User email"></x-field>
53
+ </x-field-group>
54
+ </x-field-group>
55
+ ```
56
+
57
+ - Example 3: Containing non-x-field elements (violates "Only x-field elements allowed" rule)
58
+ ```md
59
+ <x-field-group>
60
+ <x-field data-name="name" data-type="string" data-required="true" data-desc="User name"></x-field>
61
+ <div>Additional information</div>
62
+ <x-field data-name="email" data-type="string" data-required="true" data-desc="User email"></x-field>
63
+ </x-field-group>
64
+ ```
65
+
66
+ - Example 4: Empty x-field-group (violates "Must contain x-field elements" rule)
67
+ ```md
68
+ <x-field-group>
69
+ </x-field-group>
70
+ ```
71
+
72
+ - Example 5: Using x-field-group for simple-type (violates "Structured Data Only" rule)
73
+ ```md
74
+ ### appName
75
+
76
+ <x-field-group>
77
+ <x-field data-name="appName" data-type="string" data-required="true" data-desc="specifies the name of the application"></x-field>
78
+ </x-field-group>
79
+ ```
80
+
81
+ - Example 6: Missing blank line before x-field-group (violates "Spacing Around" rule)
82
+ ```md
83
+ **Parameters**
84
+ <x-field-group>
85
+ <x-field data-name="initialState" data-type="any" data-required="false">
86
+ <x-field-desc markdown>The initial state value.</x-field-desc>
87
+ </x-field>
88
+ </x-field-group>
89
+
90
+ `useReducer` returns an array with two items:
91
+ <x-field-group>
92
+ <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>
93
+ </x-field-group>
94
+ ```
95
+ </x-field-group-usage-rules>
@@ -0,0 +1,189 @@
1
+ <x-field-usage-rules>
2
+ ## XField Usage Rules
3
+
4
+ XField is structured data field, 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.
5
+
6
+ ### Attributes
7
+
8
+ - `data-name` (optional): The name of the field/parameter
9
+ - `data-type` (optional): The data type of the field (e.g., "string", "number", "boolean", "symbol", "object", "array", "function")
10
+ - `data-default` (optional): Default value for the field
11
+ - `data-required` (optional): Whether the field is required ("true" or "false")
12
+ - `data-deprecated` (optional): Whether the field is deprecated ("true" or "false")
13
+ - `data-desc` (optional): Simple description of the field (plain text only)
14
+
15
+ ### Children
16
+
17
+ - For simple types (string, number, boolean): children can be empty or contain exactly one `<x-field-desc>` element
18
+ - For complex types (object, array), children contain nested `<x-field>` elements and optionally one `<x-field-desc>` element
19
+
20
+ ### Usage Rules
21
+
22
+ - **Opening/Closing Tags Format**: `<x-field ...></x-field>` for all types
23
+ - **Maximum Nesting Depth**: 5 levels (to avoid overly complex structures)
24
+ - **Description Mutually Exclusive**: Use either `data-desc` attribute OR `<x-field-desc>` element, not both
25
+ - **Single Description Rule**: Only one `<x-field-desc>` element per `<x-field>` is allowed
26
+ - **Grouping Requirement**: Wrap the outermost `<x-field>` elements with `<x-field-group>`, even if there's only one `<x-field>` element
27
+ - **Recursive Structure**: Use recursive `<x-field>` structures to fully express complex object type hierarchies, decomposing all nested properties into more fundamental types
28
+ - **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.
29
+ - **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**.
30
+
31
+ ### Good Examples
32
+
33
+ - Example 1: Simple field with all attributes
34
+ ```md
35
+ ### Returns
36
+
37
+ <x-field-group>
38
+ <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>
39
+ </x-field-group>
40
+ ```
41
+
42
+ - Example 2: Field with markdown description
43
+ ```md
44
+ ### Context
45
+
46
+ <x-field-group>
47
+ <x-field data-name="api_key" data-type="string" data-required="true">
48
+ <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>
49
+ </x-field>
50
+ </x-field-group>
51
+ ```
52
+
53
+ - Example 3: Nested object structure
54
+ ```md
55
+ ### Properties
56
+
57
+ <x-field-group>
58
+ <x-field data-name="session" data-type="object" data-required="true">
59
+ <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>
60
+ <x-field data-name="user" data-type="object" data-required="true" data-desc="User basic information">
61
+ <x-field data-name="name" data-type="string" data-required="true" data-default="John Doe" data-desc="User name"></x-field>
62
+ <x-field data-name="email" data-type="string" data-required="true" data-default="john.doe@example.com">
63
+ <x-field-desc markdown>Primary email address used for **login** and **notifications**. Must be a valid email format.</x-field-desc>
64
+ </x-field>
65
+ <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>
66
+ </x-field>
67
+ <x-field data-name="permissions" data-type="array" data-required="true" data-default='["read", "write", "admin"]'>
68
+ <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>
69
+ </x-field>
70
+ </x-field>
71
+ </x-field-group>
72
+ ```
73
+
74
+ - Example 4: Multiple fields for Parameters
75
+ ```md
76
+ ### Parameters
77
+
78
+ <x-field-group>
79
+ <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>
80
+ <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>
81
+ <x-field data-name="options" data-type="object" data-required="false" data-desc="Additional options for the request">
82
+ <x-field data-name="format" data-type="string" data-required="false" data-default="json">
83
+ <x-field-desc>Response format: `json` or `xml`</x-field-desc>
84
+ </x-field>
85
+ <x-field data-name="locale" data-type="string" data-required="false" data-default="en" data-desc="Language locale for localized content"></x-field>
86
+ </x-field>
87
+ </x-field-group>
88
+ ```
89
+
90
+ - Example 5: Enum values with base type and description
91
+ ```md
92
+ ### Status
93
+
94
+ <x-field-group>
95
+ <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>
96
+ <x-field data-name="priority" data-type="number" data-required="false" data-default="1">
97
+ <x-field-desc markdown>Priority level for the task. **Valid values**: `1` (low), `2` (medium), `3` (high), `4` (urgent)</x-field-desc>
98
+ </x-field>
99
+ </x-field-group>
100
+ ```
101
+
102
+ - Example 6: Function type field with nested parameters and return value
103
+ ```md
104
+ ### API Methods
105
+
106
+ <x-field-group>
107
+ <x-field data-name="authenticate" data-type="function" data-required="true" data-desc="Authenticates a user with email and password">
108
+ <x-field data-name="parameters" data-type="object" data-desc="Function parameters">
109
+ <x-field data-name="email" data-type="string" data-required="true" data-desc="User's email address"></x-field>
110
+ <x-field data-name="password" data-type="string" data-required="true" data-desc="User's password"></x-field>
111
+ <x-field data-name="rememberMe" data-type="boolean" data-required="false" data-default="false" data-desc="Whether to keep user logged in"></x-field>
112
+ </x-field>
113
+ <x-field data-name="returnValue" data-type="object" data-desc="Function return value">
114
+ <x-field data-name="success" data-type="boolean" data-required="true" data-desc="Whether authentication was successful"></x-field>
115
+ <x-field data-name="token" data-type="string" data-required="false" data-desc="JWT token if authentication successful"></x-field>
116
+ <x-field data-name="user" data-type="object" data-required="false" data-desc="User information if authentication successful">
117
+ <x-field data-name="id" data-type="string" data-required="true" data-desc="User ID"></x-field>
118
+ <x-field data-name="name" data-type="string" data-required="true" data-desc="User's display name"></x-field>
119
+ <x-field data-name="email" data-type="string" data-required="true" data-desc="User's email address"></x-field>
120
+ </x-field>
121
+ </x-field>
122
+ </x-field>
123
+ </x-field-group>
124
+ ```
125
+
126
+ ### Bad Examples
127
+
128
+ - Example 1: Using self-closing tag (violates "Opening/Closing Tags Format" rule)
129
+ ```md
130
+ <x-field-group>
131
+ <x-field data-name="user_id" data-type="string" data-required="true" data-desc="User identifier" />
132
+ </x-field-group>
133
+ ```
134
+
135
+ - Example 2: Using both `data-desc` and `<x-field-desc>` (violates "Description Mutually Exclusive" rule)
136
+ ```md
137
+ <x-field-group>
138
+ <x-field data-name="api_key" data-type="string" data-required="true" data-desc="API key for authentication">
139
+ <x-field-desc markdown>Your **API key** for authentication. Keep it secure and never expose it.</x-field-desc>
140
+ </x-field>
141
+ </x-field-group>
142
+ ```
143
+
144
+ - Example 3: Using multiple `<x-field-desc>` elements (violates "Single Description Rule")
145
+ ```md
146
+ <x-field-group>
147
+ <x-field data-name="config" data-type="object" data-required="true">
148
+ <x-field-desc markdown>Configuration object for the application.</x-field-desc>
149
+ <x-field-desc markdown>Contains all runtime settings and preferences.</x-field-desc>
150
+ </x-field>
151
+ </x-field-group>
152
+ ```
153
+
154
+ - Example 4: Nesting other child elements (violates "Children" rule)
155
+ ```md
156
+ <x-field-group>
157
+ <x-field data-name="user" data-type="object" data-required="true">
158
+ <div>User information</div>
159
+ <x-field data-name="name" data-type="string" data-required="true" data-desc="User name"></x-field>
160
+ </x-field>
161
+ </x-field-group>
162
+ ```
163
+
164
+ - Example 5: Missing x-field-group wrapper (violates "Grouping Requirement" rule)
165
+ ```md
166
+ <x-field data-name="apiConfig" data-type="object" data-required="true" data-desc="API configuration object">
167
+ <x-field data-name="baseUrl" data-type="string" data-required="true" data-desc="Base URL for API calls"></x-field>
168
+ <x-field data-name="timeout" data-type="number" data-required="false" data-default="5000" data-desc="Request timeout in milliseconds"></x-field>
169
+ </x-field>
170
+ ```
171
+
172
+ - Example 6: Exceeding maximum nesting depth (violates "Maximum Nesting Depth" rule)
173
+ ```md
174
+ <x-field-group>
175
+ <x-field data-name="level1" data-type="object" data-required="true">
176
+ <x-field data-name="level2" data-type="object" data-required="true">
177
+ <x-field data-name="level3" data-type="object" data-required="true">
178
+ <x-field data-name="level4" data-type="object" data-required="true">
179
+ <x-field data-name="level5" data-type="object" data-required="true">
180
+ <x-field data-name="level6" data-type="string" data-required="true" data-desc="Too deep nesting"></x-field>
181
+ </x-field>
182
+ </x-field>
183
+ </x-field>
184
+ </x-field>
185
+ </x-field>
186
+ </x-field-group>
187
+ ```
188
+
189
+ </x-field-usage-rules>