@aigne/doc-smith 0.8.10-beta.1 → 0.8.10-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +17 -0
- package/agents/generate/check-need-generate-structure.mjs +11 -11
- package/agents/generate/index.yaml +6 -0
- package/agents/generate/user-review-document-structure.mjs +26 -21
- package/agents/init/index.mjs +5 -11
- package/package.json +8 -8
- package/prompts/detail/custom/custom-code-block.md +3 -3
- package/prompts/detail/custom/custom-components.md +114 -19
- package/prompts/detail/d2-chart/official-examples.md +5 -1
- package/prompts/detail/d2-chart/rules.md +4 -1
- package/prompts/detail/detail-example.md +59 -78
- package/prompts/detail/document-rules.md +25 -24
- package/prompts/detail/generate-document.md +85 -82
- package/prompts/detail/jsx/rules.md +4 -1
- package/prompts/structure/check-document-structure.md +35 -37
- package/prompts/structure/document-rules.md +14 -13
- package/prompts/structure/generate-structure.md +98 -98
- package/prompts/structure/structure-example.md +43 -52
- package/prompts/structure/structure-getting-started.md +7 -7
- package/prompts/translate/glossary.md +4 -4
- package/prompts/translate/translate-document.md +61 -58
- package/tests/agents/init/init.test.mjs +2 -8
- package/tests/utils/deploy.test.mjs +103 -6
- package/utils/deploy.mjs +29 -23
- package/utils/markdown-checker.mjs +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.8.10-beta.3](https://github.com/AIGNE-io/aigne-doc-smith/compare/v0.8.10-beta.2...v0.8.10-beta.3) (2025-09-19)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* **cli:** add enterprise deployment related links ([#125](https://github.com/AIGNE-io/aigne-doc-smith/issues/125)) ([f115309](https://github.com/AIGNE-io/aigne-doc-smith/commit/f11530967fef0bf2ead7f307a5513a1f3d6513f5))
|
|
9
|
+
* polish review prompt copywriting ([#124](https://github.com/AIGNE-io/aigne-doc-smith/issues/124)) ([ea3c6a8](https://github.com/AIGNE-io/aigne-doc-smith/commit/ea3c6a837a32b0135e75faf85406049406055931))
|
|
10
|
+
|
|
11
|
+
## [0.8.10-beta.2](https://github.com/AIGNE-io/aigne-doc-smith/compare/v0.8.10-beta.1...v0.8.10-beta.2) (2025-09-18)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
* polish code test ([#122](https://github.com/AIGNE-io/aigne-doc-smith/issues/122)) ([0629705](https://github.com/AIGNE-io/aigne-doc-smith/commit/0629705ebd271282411d507421c1ba5dd01473b9))
|
|
17
|
+
* update document structure review prompts and display ([#119](https://github.com/AIGNE-io/aigne-doc-smith/issues/119)) ([e2d99db](https://github.com/AIGNE-io/aigne-doc-smith/commit/e2d99db83ff3a6266b32dd450a79b6e000aff09e))
|
|
18
|
+
* update usage rules for field elements ([#120](https://github.com/AIGNE-io/aigne-doc-smith/issues/120)) ([434f161](https://github.com/AIGNE-io/aigne-doc-smith/commit/434f161ab7dd989d57ca670f36d0828c09abe38a))
|
|
19
|
+
|
|
3
20
|
## [0.8.10-beta.1](https://github.com/AIGNE-io/aigne-doc-smith/compare/v0.8.10-beta...v0.8.10-beta.1) (2025-09-18)
|
|
4
21
|
|
|
5
22
|
|
|
@@ -21,11 +21,11 @@ export default async function checkNeedGenerateStructure(
|
|
|
21
21
|
"Your project configuration is complete. Would you like to generate the document structure now?",
|
|
22
22
|
choices: [
|
|
23
23
|
{
|
|
24
|
-
name: "Generate now - Start
|
|
24
|
+
name: "Generate now - Start generating the document structure",
|
|
25
25
|
value: "generate",
|
|
26
26
|
},
|
|
27
27
|
{
|
|
28
|
-
name: "Review configuration first -
|
|
28
|
+
name: "Review configuration first - Edit configuration before generating",
|
|
29
29
|
value: "later",
|
|
30
30
|
},
|
|
31
31
|
],
|
|
@@ -34,7 +34,7 @@ export default async function checkNeedGenerateStructure(
|
|
|
34
34
|
if (choice === "later") {
|
|
35
35
|
console.log(`\nConfiguration file: ${chalk.cyan("./.aigne/doc-smith/config.yaml")}`);
|
|
36
36
|
console.log(
|
|
37
|
-
"Review and
|
|
37
|
+
"Review and edit your configuration as needed, then run 'aigne doc generate' to continue.",
|
|
38
38
|
);
|
|
39
39
|
|
|
40
40
|
// In test environment, return a special result instead of exiting
|
|
@@ -81,12 +81,12 @@ export default async function checkNeedGenerateStructure(
|
|
|
81
81
|
if (shouldRegenerate) {
|
|
82
82
|
finalFeedback = `
|
|
83
83
|
${finalFeedback || ""}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
1.
|
|
87
|
-
2.
|
|
88
|
-
3.
|
|
89
|
-
4.
|
|
84
|
+
|
|
85
|
+
Update document structure based on the latest DataSources:
|
|
86
|
+
1. For new content, add new sections as needed or supplement existing section displays
|
|
87
|
+
2. Be cautious when deleting sections, unless all associated sourceIds have been removed
|
|
88
|
+
3. Do not modify the path of existing sections
|
|
89
|
+
4. Update section sourceIds as needed based on the latest Data Sources
|
|
90
90
|
`;
|
|
91
91
|
}
|
|
92
92
|
}
|
|
@@ -97,7 +97,7 @@ export default async function checkNeedGenerateStructure(
|
|
|
97
97
|
finalFeedback = `
|
|
98
98
|
${finalFeedback || ""}
|
|
99
99
|
|
|
100
|
-
|
|
100
|
+
User requested forced regeneration of document structure. Please regenerate based on the latest Data Sources and user requirements, **allowing any modifications**.
|
|
101
101
|
`;
|
|
102
102
|
}
|
|
103
103
|
|
|
@@ -167,7 +167,7 @@ export default async function checkNeedGenerateStructure(
|
|
|
167
167
|
}
|
|
168
168
|
|
|
169
169
|
if (hasUpdated) {
|
|
170
|
-
message = `\n
|
|
170
|
+
message = `\n## Project Information Updated\n\nSaved to \`.aigne/doc-smith/config.yaml\`:\n\n${message}\n\n`;
|
|
171
171
|
}
|
|
172
172
|
}
|
|
173
173
|
} catch (error) {
|
|
@@ -10,6 +10,12 @@ skills:
|
|
|
10
10
|
skipIfExists: true
|
|
11
11
|
- ../utils/load-sources.mjs
|
|
12
12
|
- ./check-need-generate-structure.mjs
|
|
13
|
+
- url: ../utils/save-output.mjs
|
|
14
|
+
default_input:
|
|
15
|
+
saveKey: documentStructure
|
|
16
|
+
savePath:
|
|
17
|
+
$get: outputDir
|
|
18
|
+
fileName: structure-plan.json
|
|
13
19
|
- ./user-review-document-structure.mjs
|
|
14
20
|
- url: ../utils/save-output.mjs
|
|
15
21
|
default_input:
|
|
@@ -29,8 +29,8 @@ function formatDocumentStructure(structure) {
|
|
|
29
29
|
|
|
30
30
|
function printNode(node, depth = 0) {
|
|
31
31
|
const INDENT_SPACES = " ";
|
|
32
|
-
const FOLDER_ICON = "📁";
|
|
33
|
-
const FILE_ICON = "📄";
|
|
32
|
+
const FOLDER_ICON = " 📁";
|
|
33
|
+
const FILE_ICON = " 📄";
|
|
34
34
|
const indent = INDENT_SPACES.repeat(depth);
|
|
35
35
|
const prefix = depth === 0 ? FOLDER_ICON : FILE_ICON;
|
|
36
36
|
|
|
@@ -46,6 +46,21 @@ function formatDocumentStructure(structure) {
|
|
|
46
46
|
return { rootNodes, printNode };
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
+
function printDocumentStructure(structure) {
|
|
50
|
+
console.log(`\n ${"-".repeat(50)}`);
|
|
51
|
+
console.log(" Current Document Structure");
|
|
52
|
+
console.log(` ${"-".repeat(50)}`);
|
|
53
|
+
|
|
54
|
+
const { rootNodes, printNode } = formatDocumentStructure(structure);
|
|
55
|
+
|
|
56
|
+
if (rootNodes.length === 0) {
|
|
57
|
+
console.log(" No document structure found.");
|
|
58
|
+
} else {
|
|
59
|
+
rootNodes.forEach((node) => printNode(node));
|
|
60
|
+
}
|
|
61
|
+
console.log();
|
|
62
|
+
}
|
|
63
|
+
|
|
49
64
|
export default async function userReviewDocumentStructure({ documentStructure, ...rest }, options) {
|
|
50
65
|
// Check if document structure exists
|
|
51
66
|
if (!documentStructure || !Array.isArray(documentStructure) || documentStructure.length === 0) {
|
|
@@ -53,17 +68,20 @@ export default async function userReviewDocumentStructure({ documentStructure, .
|
|
|
53
68
|
return { documentStructure };
|
|
54
69
|
}
|
|
55
70
|
|
|
71
|
+
// Print current document structure in a user-friendly format
|
|
72
|
+
printDocumentStructure(documentStructure);
|
|
73
|
+
|
|
56
74
|
// Ask user if they want to review the document structure
|
|
57
75
|
const needReview = await options.prompts.select({
|
|
58
76
|
message:
|
|
59
|
-
"Would you like to
|
|
77
|
+
"Would you like to optimize the document structure?\n You can edit titles, reorganize sections.",
|
|
60
78
|
choices: [
|
|
61
79
|
{
|
|
62
80
|
name: "Looks good - proceed with current structure",
|
|
63
81
|
value: "no",
|
|
64
82
|
},
|
|
65
83
|
{
|
|
66
|
-
name: "
|
|
84
|
+
name: "Yes, optimize the structure",
|
|
67
85
|
value: "yes",
|
|
68
86
|
},
|
|
69
87
|
],
|
|
@@ -80,27 +98,11 @@ export default async function userReviewDocumentStructure({ documentStructure, .
|
|
|
80
98
|
while (iterationCount < MAX_ITERATIONS) {
|
|
81
99
|
iterationCount++;
|
|
82
100
|
|
|
83
|
-
// Print current document structure in a user-friendly format
|
|
84
|
-
console.log(`\n${"=".repeat(50)}`);
|
|
85
|
-
console.log("Current Document Structure");
|
|
86
|
-
console.log("=".repeat(50));
|
|
87
|
-
|
|
88
|
-
const { rootNodes, printNode } = formatDocumentStructure(currentStructure);
|
|
89
|
-
|
|
90
|
-
if (rootNodes.length === 0) {
|
|
91
|
-
console.log("No document structure found.");
|
|
92
|
-
} else {
|
|
93
|
-
rootNodes.forEach((node) => printNode(node));
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
console.log(`${"=".repeat(50)}\n`);
|
|
97
|
-
|
|
98
101
|
// Ask for feedback
|
|
99
102
|
const feedback = await options.prompts.input({
|
|
100
103
|
message:
|
|
101
104
|
"How would you like to improve the structure?\n" +
|
|
102
|
-
" • Rename, reorganize, add, or remove sections\n" +
|
|
103
|
-
" • Adjust content outlines for clarity\n\n" +
|
|
105
|
+
" • Rename, reorganize, add, or remove sections\n\n" +
|
|
104
106
|
" Press Enter to finish reviewing:",
|
|
105
107
|
});
|
|
106
108
|
|
|
@@ -152,6 +154,9 @@ export default async function userReviewDocumentStructure({ documentStructure, .
|
|
|
152
154
|
console.warn("Your feedback was applied but not saved as a preference.");
|
|
153
155
|
}
|
|
154
156
|
}
|
|
157
|
+
|
|
158
|
+
// Print current document structure in a user-friendly format
|
|
159
|
+
printDocumentStructure(currentStructure);
|
|
155
160
|
} catch (error) {
|
|
156
161
|
console.error("Error processing your feedback:");
|
|
157
162
|
console.error(`Type: ${error.name}`);
|
package/agents/init/index.mjs
CHANGED
|
@@ -393,17 +393,11 @@ export function generateYAML(input) {
|
|
|
393
393
|
let yaml = "# Project information for documentation publishing\n";
|
|
394
394
|
|
|
395
395
|
// Serialize the project info section safely with string quoting
|
|
396
|
-
const projectSection = yamlStringify(
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
},
|
|
402
|
-
{
|
|
403
|
-
quotingType: '"',
|
|
404
|
-
defaultStringType: "QUOTE_DOUBLE",
|
|
405
|
-
},
|
|
406
|
-
).trim();
|
|
396
|
+
const projectSection = yamlStringify({
|
|
397
|
+
projectName: config.projectName,
|
|
398
|
+
projectDesc: config.projectDesc,
|
|
399
|
+
projectLogo: config.projectLogo,
|
|
400
|
+
}).trim();
|
|
407
401
|
|
|
408
402
|
yaml += `${projectSection}\n\n`;
|
|
409
403
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aigne/doc-smith",
|
|
3
|
-
"version": "0.8.10-beta.
|
|
3
|
+
"version": "0.8.10-beta.3",
|
|
4
4
|
"description": "AI-driven documentation generation tool built on the AIGNE Framework",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -12,13 +12,13 @@
|
|
|
12
12
|
"author": "Arcblock <blocklet@arcblock.io> https://github.com/blocklet",
|
|
13
13
|
"license": "Elastic-2.0",
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@aigne/aigne-hub": "^0.9.
|
|
16
|
-
"@aigne/anthropic": "^0.13.
|
|
17
|
-
"@aigne/cli": "^1.
|
|
18
|
-
"@aigne/core": "^1.60.
|
|
19
|
-
"@aigne/gemini": "^0.13.
|
|
20
|
-
"@aigne/openai": "^0.15.
|
|
21
|
-
"@aigne/publish-docs": "^0.
|
|
15
|
+
"@aigne/aigne-hub": "^0.9.5",
|
|
16
|
+
"@aigne/anthropic": "^0.13.4",
|
|
17
|
+
"@aigne/cli": "^1.48.1",
|
|
18
|
+
"@aigne/core": "^1.60.3",
|
|
19
|
+
"@aigne/gemini": "^0.13.4",
|
|
20
|
+
"@aigne/openai": "^0.15.4",
|
|
21
|
+
"@aigne/publish-docs": "^0.11.0",
|
|
22
22
|
"@terrastruct/d2": "^0.1.33",
|
|
23
23
|
"chalk": "^5.5.0",
|
|
24
24
|
"debug": "^4.4.1",
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
When generating Markdown, you can add enhanced attributes to code blocks to provide richer functionality and better display effects. These attributes allow you to specify **titles**, **icons**, and more for code blocks.
|
|
5
5
|
|
|
6
|
-
**
|
|
6
|
+
**Please use these enhanced attributes as much as possible to improve display effects**
|
|
7
7
|
|
|
8
8
|
### Attribute Definition
|
|
9
9
|
|
|
@@ -76,8 +76,8 @@ class ShoppingCart {
|
|
|
76
76
|
**Example 1**
|
|
77
77
|
|
|
78
78
|
There are two errors in this example:
|
|
79
|
-
- Language name should not include suffixes
|
|
80
|
-
- Title does not need a key specified
|
|
79
|
+
- Language name should not include suffixes like ',no_run' in the example
|
|
80
|
+
- Title does not need a key specified; just configure the value directly
|
|
81
81
|
|
|
82
82
|
```rust,no_run title="main.rs" icon=logos:rust
|
|
83
83
|
use tokio::runtime::Runtime;
|
|
@@ -37,12 +37,38 @@ Attribute Rules:
|
|
|
37
37
|
|
|
38
38
|
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.
|
|
39
39
|
|
|
40
|
+
### 2.1. `<x-field-group>` Field Group Component
|
|
41
|
+
|
|
42
|
+
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.
|
|
43
|
+
|
|
44
|
+
Syntax:
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
<x-field-group>
|
|
48
|
+
<x-field data-name="field1" data-type="string" data-desc="First field description"></x-field>
|
|
49
|
+
<x-field data-name="field2" data-type="number" data-desc="Second field description"></x-field>
|
|
50
|
+
<x-field data-name="field3" data-type="boolean" data-desc="Third field description"></x-field>
|
|
51
|
+
</x-field-group>
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Attribute Rules:
|
|
55
|
+
|
|
56
|
+
- No attributes required
|
|
57
|
+
- Must contain multiple `<x-field>` elements
|
|
58
|
+
- Only `<x-field>` elements are allowed as children
|
|
59
|
+
- Cannot be nested inside other `<x-field>` or `<x-field-group>` elements
|
|
60
|
+
- Used only at the top level for grouping related fields
|
|
61
|
+
|
|
62
|
+
### 2.2. `<x-field>` Individual Field Component
|
|
63
|
+
|
|
40
64
|
Syntax:
|
|
41
65
|
|
|
42
66
|
```
|
|
43
67
|
<x-field data-name="field_name" data-type="string" data-default="default_value" data-required="true" data-deprecated="false" data-desc="Field description">
|
|
44
68
|
<!-- For complex types, children can only be other x-field elements -->
|
|
45
69
|
<x-field data-name="nested_field" data-type="string" data-desc="Nested field description"></x-field>
|
|
70
|
+
<!-- Optional: Use x-field-desc for rich text descriptions with inline markdown -->
|
|
71
|
+
<x-field-desc markdown>This field supports **bold text**, `inline code`, and other inline markdown formatting.</x-field-desc>
|
|
46
72
|
</x-field>
|
|
47
73
|
```
|
|
48
74
|
|
|
@@ -53,48 +79,117 @@ Attribute Rules:
|
|
|
53
79
|
- `data-default` (optional): Default value for the field
|
|
54
80
|
- `data-required` (optional): Whether the field is required ("true" or "false")
|
|
55
81
|
- `data-deprecated` (optional): Whether the field is deprecated ("true" or "false")
|
|
56
|
-
- `data-desc` (optional):
|
|
57
|
-
- Children: For complex types (object, array), children can
|
|
82
|
+
- `data-desc` (optional): Simple description of the field (plain text only)
|
|
83
|
+
- Children: For complex types (object, array), children can contain multiple `<x-field>` elements and optionally one `<x-field-desc>` element. For simple types, children can be empty or contain one `<x-field-desc>` element.
|
|
84
|
+
|
|
85
|
+
Child Elements:
|
|
86
|
+
|
|
87
|
+
- `<x-field-desc>` (optional): Rich text description supporting inline markdown formatting
|
|
88
|
+
- `markdown` (required): **MUST** be set to "markdown" - this attribute is mandatory and cannot be omitted
|
|
89
|
+
- Supports **bold text**, `inline code`, *italic text*, and other inline markdown
|
|
90
|
+
- Cannot contain block-level elements (no code blocks, headers, lists)
|
|
91
|
+
- **Mutually exclusive with `data-desc`**: Use either `data-desc` attribute OR `<x-field-desc>` element, not both
|
|
92
|
+
- Only one `<x-field-desc>` element per `<x-field>` is allowed
|
|
93
|
+
- **Validation**: `<x-field-desc>` without `markdown` attribute will be rejected
|
|
58
94
|
|
|
59
95
|
Nesting Rules:
|
|
60
96
|
|
|
61
97
|
- Maximum nesting depth: 5 levels (to avoid overly complex structures)
|
|
62
|
-
-
|
|
63
|
-
-
|
|
64
|
-
- **
|
|
65
|
-
-
|
|
66
|
-
-
|
|
98
|
+
- **Top-level organization**: Use `<x-field-group>` to group related `<x-field>` elements at the top level
|
|
99
|
+
- **Field component children**: Children elements must only be `<x-field>` and `<x-field-desc>` components
|
|
100
|
+
- **Group component children**: `<x-field-group>` can only contain `<x-field>` elements
|
|
101
|
+
- **Mutually exclusive descriptions**: Use either `data-desc` attribute OR `<x-field-desc>` element, not both
|
|
102
|
+
- **Child element limits**:
|
|
103
|
+
- For simple types: children can be empty or contain exactly one `<x-field-desc>` element
|
|
104
|
+
- For complex types: children can contain multiple `<x-field>` elements and optionally one `<x-field-desc>` element
|
|
105
|
+
- **Always use opening/closing tags format**: `<x-field ...></x-field>` and `<x-field-group>...</x-field-group>` for all types
|
|
106
|
+
- **Mandatory markdown attribute**: Every `<x-field-desc>` element **MUST** include `markdown` attribute - elements without this attribute will be rejected
|
|
107
|
+
- **Grouping rules**:
|
|
108
|
+
- `<x-field-group>` can only be used at the top level
|
|
109
|
+
- Cannot be nested inside `<x-field>` or other `<x-field-group>` elements
|
|
110
|
+
- Must contain multiple `<x-field>` elements
|
|
111
|
+
- For simple types (string, number, boolean), children can be empty or contain one `<x-field-desc>`: `<x-field ...></x-field>` or `<x-field ...><x-field-desc markdown>...</x-field-desc></x-field>`
|
|
112
|
+
- For complex types (object, array), children contain nested `<x-field>` elements and optionally one `<x-field-desc>` element
|
|
67
113
|
|
|
68
114
|
**Usage Rules:**
|
|
69
115
|
|
|
70
116
|
- **Context types must use `<x-field>` instead of tables** for consistent formatting
|
|
117
|
+
- **Mandatory markdown attribute**: Every `<x-field-desc>` element must include `markdown` attribute
|
|
118
|
+
|
|
119
|
+
**Error Examples:**
|
|
120
|
+
|
|
121
|
+
❌ **INCORRECT** - Missing `markdown` attribute:
|
|
122
|
+
```
|
|
123
|
+
<x-field data-name="api_key" data-type="string" data-required="true">
|
|
124
|
+
<x-field-desc>Your **API key** for authentication.</x-field-desc>
|
|
125
|
+
</x-field>
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
✅ **CORRECT** - With required `markdown` attribute:
|
|
129
|
+
```
|
|
130
|
+
<x-field data-name="api_key" data-type="string" data-required="true">
|
|
131
|
+
<x-field-desc markdown>Your **API key** for authentication.</x-field-desc>
|
|
132
|
+
</x-field>
|
|
133
|
+
```
|
|
71
134
|
|
|
72
135
|
Example:
|
|
73
136
|
|
|
74
137
|
```
|
|
75
|
-
<!-- Single field -->
|
|
138
|
+
<!-- Single field with simple description (using data-desc) -->
|
|
76
139
|
<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>
|
|
77
140
|
|
|
78
|
-
<!--
|
|
79
|
-
<x-field data-name="
|
|
80
|
-
<x-field
|
|
81
|
-
|
|
141
|
+
<!-- Single field with rich text description (using x-field-desc) -->
|
|
142
|
+
<x-field data-name="api_key" data-type="string" data-required="true">
|
|
143
|
+
<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>
|
|
144
|
+
</x-field>
|
|
82
145
|
|
|
83
|
-
<!--
|
|
84
|
-
<x-field
|
|
146
|
+
<!-- Multiple related fields grouped together (Props, Parameters, Returns, Context) -->
|
|
147
|
+
<x-field-group>
|
|
148
|
+
<x-field data-name="name" data-type="string" data-required="true" data-desc="The name of the product."></x-field>
|
|
149
|
+
<x-field data-name="description" data-type="string" data-required="false" data-desc="An optional description for the product."></x-field>
|
|
150
|
+
<x-field data-name="type" data-type="string" data-required="false" data-desc="The type of product (e.g., 'service', 'good')."></x-field>
|
|
151
|
+
<x-field data-name="price" data-type="number" data-required="true" data-default="0">
|
|
152
|
+
<x-field-desc markdown>Product price in **USD**. Must be a positive number with up to 2 decimal places.</x-field-desc>
|
|
153
|
+
</x-field>
|
|
154
|
+
</x-field-group>
|
|
155
|
+
|
|
156
|
+
<!-- Multiple field groups for different contexts -->
|
|
157
|
+
<x-field-group>
|
|
158
|
+
<x-field data-name="username" data-type="string" data-required="true" data-desc="User login name"></x-field>
|
|
159
|
+
<x-field data-name="email" data-type="string" data-required="true" data-desc="User email address"></x-field>
|
|
160
|
+
<x-field data-name="password" data-type="string" data-required="true" data-desc="User password"></x-field>
|
|
161
|
+
</x-field-group>
|
|
162
|
+
|
|
163
|
+
<x-field-group>
|
|
164
|
+
<x-field data-name="host" data-type="string" data-required="true" data-default="localhost" data-desc="Database host address"></x-field>
|
|
165
|
+
<x-field data-name="port" data-type="number" data-required="true" data-default="5432" data-desc="Database port number"></x-field>
|
|
166
|
+
<x-field data-name="ssl" data-type="boolean" data-required="false" data-default="false" data-desc="Enable SSL connection"></x-field>
|
|
167
|
+
</x-field-group>
|
|
168
|
+
|
|
169
|
+
<!-- Complex nested object with rich descriptions -->
|
|
170
|
+
<x-field data-name="session" data-type="object" data-required="true">
|
|
171
|
+
<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>
|
|
85
172
|
<x-field data-name="auth" data-type="object" data-required="true" data-desc="User authentication information">
|
|
86
173
|
<x-field data-name="token" data-type="object" data-required="true" data-desc="Access token information">
|
|
87
|
-
<x-field data-name="access_token" data-type="string" data-required="true" data-default="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
|
|
88
|
-
|
|
174
|
+
<x-field data-name="access_token" data-type="string" data-required="true" data-default="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...">
|
|
175
|
+
<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>
|
|
176
|
+
</x-field>
|
|
177
|
+
<x-field data-name="refresh_token" data-type="string" data-required="false" data-default="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...">
|
|
178
|
+
<x-field-desc markdown>Used to obtain new `access_token` when the current one expires. Valid for **30 days**.</x-field-desc>
|
|
179
|
+
</x-field>
|
|
89
180
|
<x-field data-name="expires_at" data-type="number" data-required="true" data-default="1704067200" data-desc="Token expiration timestamp (Unix timestamp)"></x-field>
|
|
90
181
|
</x-field>
|
|
91
182
|
<x-field data-name="user" data-type="object" data-required="true" data-desc="User basic information">
|
|
92
183
|
<x-field data-name="profile" data-type="object" data-required="true" data-desc="User profile information">
|
|
93
184
|
<x-field data-name="name" data-type="string" data-required="true" data-default="John Doe" data-desc="User name"></x-field>
|
|
94
|
-
<x-field data-name="email" data-type="string" data-required="true" data-default="john.doe@example.com"
|
|
185
|
+
<x-field data-name="email" data-type="string" data-required="true" data-default="john.doe@example.com">
|
|
186
|
+
<x-field-desc markdown>Primary email address used for **login** and **notifications**. Must be a valid email format.</x-field-desc>
|
|
187
|
+
</x-field>
|
|
95
188
|
<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>
|
|
96
189
|
</x-field>
|
|
97
|
-
<x-field data-name="permissions" data-type="array" data-required="true" data-default='["read", "write", "admin"]'
|
|
190
|
+
<x-field data-name="permissions" data-type="array" data-required="true" data-default='["read", "write", "admin"]'>
|
|
191
|
+
<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>
|
|
192
|
+
</x-field>
|
|
98
193
|
</x-field>
|
|
99
194
|
</x-field>
|
|
100
195
|
</x-field>
|
|
@@ -118,7 +213,7 @@ Attribute Rules:
|
|
|
118
213
|
- data-columns (optional): Number of columns, integer (e.g., 2, 3). Default is 2.
|
|
119
214
|
- Must contain multiple <x-card> elements internally.
|
|
120
215
|
- Consistency requirement: All <x-card> elements within the same <x-cards> must maintain visual consistency:
|
|
121
|
-
-
|
|
216
|
+
- It's recommended to always provide data-icon for each card.
|
|
122
217
|
- Or all cards should have data-image.
|
|
123
218
|
- Avoid mixing (some with icons, some with only images).
|
|
124
219
|
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
<d2_official_example>
|
|
2
|
+
Here are examples from the official D2 documentation with good visual effects.
|
|
3
|
+
When generating charts in practice, you can refer to these official examples to enhance the expressiveness of your charts.
|
|
2
4
|
|
|
3
5
|
- Bank Securities
|
|
4
6
|
```d2
|
|
@@ -706,3 +708,5 @@
|
|
|
706
708
|
```
|
|
707
709
|
| {near: bottom-center}
|
|
708
710
|
```
|
|
711
|
+
|
|
712
|
+
</d2_official_example>
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
<d2_generate_constraints>
|
|
1
2
|
# D2 Diagram Generation Expert Guide
|
|
2
3
|
|
|
3
4
|
## Preamble: LLM Role and Core Objective
|
|
4
5
|
|
|
5
|
-
You are an expert
|
|
6
|
+
You are an expert software architect and a master of the D2 (Declarative Diagramming) language. Your primary function is to translate abstract descriptions of software systems, components, and processes into precise, readable, and visually effective D2 diagram code.
|
|
6
7
|
|
|
7
8
|
Your core directive is to produce D2 code that is not only syntactically correct but also semantically meaningful and adheres to the highest standards of technical diagramming. The generated output must follow all instructions, constraints, and best practices detailed in this document. You will operate in a zero-tolerance mode for syntactical errors, especially concerning predefined keyword values. The fundamental principle is the separation of concerns: the logical structure of the diagram must be defined independently of its visual styling. The following chapters are structured to enforce this principle.
|
|
8
9
|
|
|
@@ -1090,3 +1091,5 @@ Session.t2 -> Lua: "Trigger OnPlayerTurn"
|
|
|
1090
1091
|
User.t2 <- Session.t2
|
|
1091
1092
|
```
|
|
1092
1093
|
|
|
1094
|
+
|
|
1095
|
+
</d2_generate_constraints>
|