@aigne/doc-smith 0.8.11-beta.3 → 0.8.11-beta.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 (43) hide show
  1. package/.aigne/doc-smith/config.yaml +1 -3
  2. package/.release-please-manifest.json +1 -1
  3. package/CHANGELOG.md +21 -0
  4. package/agents/clear/index.yaml +1 -0
  5. package/agents/evaluate/index.yaml +1 -0
  6. package/agents/generate/check-d2-diagram-valid.mjs +26 -0
  7. package/agents/generate/generate-d2-diagram.yaml +23 -0
  8. package/agents/generate/merge-d2-diagram.yaml +39 -0
  9. package/agents/init/index.mjs +42 -11
  10. package/agents/publish/index.yaml +1 -0
  11. package/agents/publish/publish-docs.mjs +17 -20
  12. package/agents/translate/index.yaml +1 -0
  13. package/agents/update/generate-document.yaml +25 -0
  14. package/agents/update/index.yaml +1 -0
  15. package/agents/update/update-single-document.yaml +1 -0
  16. package/agents/utils/choose-docs.mjs +22 -11
  17. package/package.json +2 -2
  18. package/prompts/detail/{d2-chart/rules.md → d2-diagram/rules-system.md} +41 -5
  19. package/prompts/detail/d2-diagram/rules-user.md +4 -0
  20. package/prompts/detail/document-rules.md +2 -3
  21. package/prompts/detail/generate-document.md +8 -2
  22. package/prompts/detail/update-document.md +1 -3
  23. package/prompts/translate/code-block.md +16 -0
  24. package/prompts/translate/translate-document.md +116 -20
  25. package/tests/agents/init/init.test.mjs +147 -19
  26. package/tests/agents/publish/publish-docs.test.mjs +99 -0
  27. package/tests/agents/utils/check-detail-result.test.mjs +2 -15
  28. package/tests/agents/utils/choose-docs.test.mjs +2 -9
  29. package/tests/utils/auth-utils.test.mjs +1 -1
  30. package/tests/utils/d2-utils.test.mjs +4 -4
  31. package/tests/utils/deploy.test.mjs +3 -10
  32. package/tests/utils/docs-finder-utils.test.mjs +12 -0
  33. package/tests/utils/kroki-utils.test.mjs +5 -5
  34. package/tests/utils/preferences-utils.test.mjs +5 -3
  35. package/tests/utils/save-value-to-config.test.mjs +3 -1
  36. package/utils/auth-utils.mjs +4 -0
  37. package/utils/constants/index.mjs +3 -0
  38. package/utils/d2-utils.mjs +11 -6
  39. package/utils/deploy.mjs +4 -20
  40. package/utils/docs-finder-utils.mjs +12 -1
  41. package/utils/kroki-utils.mjs +5 -4
  42. package/utils/markdown-checker.mjs +0 -20
  43. /package/prompts/detail/{d2-chart → d2-diagram}/official-examples.md +0 -0
@@ -67,8 +67,6 @@ docsDir: ./docs # Directory to save generated documentation
67
67
  sourcesPath: # Source code paths to analyze
68
68
  - ./
69
69
  lastGitHead: f3f14b93e6b2e6beb42b2f368c2560ab050dfd03
70
- appUrl: https://docsmith.aigne.io
71
70
  # ⚠️ Warning: boardId is auto-generated by system, please do not edit manually
72
71
  boardId: "docsmith"
73
- # Checkout ID for document deployment service
74
- checkoutId: ""
72
+ appUrl: https://docsmith.aigne.io
@@ -1,3 +1,3 @@
1
1
  {
2
- ".": "0.8.11-beta.3"
2
+ ".": "0.8.11-beta.5"
3
3
  }
package/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.8.11-beta.5](https://github.com/AIGNE-io/aigne-doc-smith/compare/v0.8.11-beta.4...v0.8.11-beta.5) (2025-10-01)
4
+
5
+
6
+ ### Features
7
+
8
+ * add user role requirement for publish and custom rule support ([#151](https://github.com/AIGNE-io/aigne-doc-smith/issues/151)) ([95866f9](https://github.com/AIGNE-io/aigne-doc-smith/commit/95866f9fcb2ca697da42e950e9011b29913726d4))
9
+ * split d2 diagram generate as independent tool ([#152](https://github.com/AIGNE-io/aigne-doc-smith/issues/152)) ([8e9b811](https://github.com/AIGNE-io/aigne-doc-smith/commit/8e9b811dc6108bb19ab8a1853afb4cab92af1d62))
10
+
11
+ ## [0.8.11-beta.4](https://github.com/AIGNE-io/aigne-doc-smith/compare/v0.8.11-beta.3...v0.8.11-beta.4) (2025-09-30)
12
+
13
+
14
+ ### Features
15
+
16
+ * add check-only option for agents with selection input ([#147](https://github.com/AIGNE-io/aigne-doc-smith/issues/147)) ([3340988](https://github.com/AIGNE-io/aigne-doc-smith/commit/3340988e67ffef7e1087d560930b3cf98c860693))
17
+
18
+
19
+ ### Bug Fixes
20
+
21
+ * improve error handling in choose-docs utility ([#145](https://github.com/AIGNE-io/aigne-doc-smith/issues/145)) ([7052ffc](https://github.com/AIGNE-io/aigne-doc-smith/commit/7052ffc106817144bff815422dced7faa4dfc3e8))
22
+ * translation prompt tuned; translate comments only in code blocks ([#149](https://github.com/AIGNE-io/aigne-doc-smith/issues/149)) ([30ce2c0](https://github.com/AIGNE-io/aigne-doc-smith/commit/30ce2c0e43c01b6588b4ada84aafecfd83c1b23b))
23
+
3
24
  ## [0.8.11-beta.3](https://github.com/AIGNE-io/aigne-doc-smith/compare/v0.8.11-beta.2...v0.8.11-beta.3) (2025-09-29)
4
25
 
5
26
 
@@ -7,6 +7,7 @@ skills:
7
7
  - url: ../init/index.mjs
8
8
  default_input:
9
9
  skipIfExists: true
10
+ checkOnly: true
10
11
  - ./choose-contents.mjs
11
12
  input_schema:
12
13
  type: object
@@ -5,6 +5,7 @@ skills:
5
5
  - url: ../init/index.mjs
6
6
  default_input:
7
7
  skipIfExists: true
8
+ checkOnly: true
8
9
  - ../utils/load-sources.mjs
9
10
  - ../utils/format-document-structure.mjs
10
11
  - type: transform
@@ -0,0 +1,26 @@
1
+ import { checkContent } from "../../utils/d2-utils.mjs";
2
+
3
+ export default async function checkD2DiagramIsValid({ d2DiagramSourceCode }) {
4
+ try {
5
+ await checkContent({ content: d2DiagramSourceCode });
6
+ return {
7
+ isValid: true,
8
+ };
9
+ } catch (err) {
10
+ return {
11
+ isValid: false,
12
+ error: err.message,
13
+ };
14
+ }
15
+ }
16
+
17
+ checkD2DiagramIsValid.input_schema = {
18
+ type: "object",
19
+ properties: {
20
+ d2DiagramSourceCode: {
21
+ type: "string",
22
+ description: "Source code of d2 diagram",
23
+ },
24
+ },
25
+ required: ["d2DiagramSourceCode"],
26
+ };
@@ -0,0 +1,23 @@
1
+ name: drawD2Diagram
2
+ description: Generate a D2 diagram from document content.
3
+ instructions:
4
+ - role: system
5
+ url: ../../prompts/detail/d2-diagram/rules-system.md
6
+ - role: user
7
+ url: ../../prompts/detail/d2-diagram/rules-user.md
8
+ input_schema:
9
+ type: object
10
+ properties:
11
+ documentContent:
12
+ type: string
13
+ description: Source code of current document (without the D2 diagram)
14
+ required:
15
+ - documentContent
16
+ output_schema:
17
+ type: object
18
+ properties:
19
+ d2DiagramSourceCode:
20
+ type: string
21
+ description: Source code to draw D2 diagram
22
+ required:
23
+ - d2DiagramSourceCode
@@ -0,0 +1,39 @@
1
+ name: mergeD2DiagramToDocument
2
+ description: Merge D2 Diagram source code into document
3
+ instructions: |
4
+ You are an AI assistant that helps to merge d2 diagram into document.
5
+
6
+ <datasources>
7
+ {{ content }}
8
+ </datasources>
9
+ <datasources>
10
+ {{ d2DiagramSourceCode }}
11
+ </datasources>
12
+
13
+ Given the source content of a document and the D2 diagram source code, your task is to:
14
+ - **Keep the original content as soon as possible.**
15
+ - D2 diagram source code should wrap by ```d2 and ``` in markdown format.
16
+ - Should find proper position to insert the D2 diagram in the document, usually after the first paragraph or after the section that describes the diagram.
17
+ - If there is no suitable position, append it to the end of the document.
18
+ - If there is no D2 diagram source code, return the original document content without any changes.
19
+ input_schema:
20
+ type: object
21
+ properties:
22
+ content:
23
+ type: string
24
+ description: Source content of the document
25
+ d2DiagramSourceCode:
26
+ type: string
27
+ description: Source content of D2 Diagram
28
+ required:
29
+ - content
30
+ - d2DiagramSourceCode
31
+ output_schema:
32
+ type: object
33
+ properties:
34
+ content:
35
+ type: string
36
+ description: Merged content of the document with D2 diagram
37
+ required:
38
+ - content
39
+
@@ -32,9 +32,32 @@ const _PRESS_ENTER_TO_FINISH = "Press Enter to finish";
32
32
  * @returns {Promise<Object>}
33
33
  */
34
34
  export default async function init(
35
- { outputPath = ".aigne/doc-smith", fileName = "config.yaml", skipIfExists = false, appUrl },
35
+ {
36
+ outputPath = ".aigne/doc-smith",
37
+ fileName = "config.yaml",
38
+ skipIfExists = false,
39
+ appUrl,
40
+ checkOnly = false,
41
+ },
36
42
  options,
37
43
  ) {
44
+ // Check if we're in checkOnly mode
45
+ if (checkOnly) {
46
+ const filePath = join(outputPath, fileName);
47
+ const configContent = await readFile(filePath, "utf8").catch(() => null);
48
+
49
+ if (!configContent || configContent.trim() === "") {
50
+ console.log(`⚠️ No configuration found.`);
51
+ console.log(
52
+ `🚀 Run ${chalk.cyan("aigne doc init")} to set up your documentation configuration.`,
53
+ );
54
+ process.exit(0);
55
+ }
56
+
57
+ // Config exists, load and return it
58
+ return loadConfig({ config: filePath, appUrl });
59
+ }
60
+
38
61
  if (skipIfExists) {
39
62
  const filePath = join(outputPath, fileName);
40
63
  const configContent = await readFile(filePath, "utf8").catch(() => null);
@@ -53,7 +76,7 @@ export default async function init(
53
76
 
54
77
  // 1. Primary purpose - what's the main outcome you want readers to achieve?
55
78
  const purposeChoices = await options.prompts.checkbox({
56
- message: "📝 [1/8]: What should your documentation help readers achieve?",
79
+ message: "📝 [1/9]: What should your documentation help readers achieve?",
57
80
  choices: Object.entries(DOCUMENT_STYLES)
58
81
  .filter(([key]) => key !== "custom") // Remove custom option for multiselect
59
82
  .map(([key, style]) => ({
@@ -101,7 +124,7 @@ export default async function init(
101
124
 
102
125
  // 2. Target audience - who will be reading this most often?
103
126
  const audienceChoices = await options.prompts.checkbox({
104
- message: "👥 [2/8]: Who will be reading your documentation?",
127
+ message: "👥 [2/9]: Who will be reading your documentation?",
105
128
  choices: Object.entries(TARGET_AUDIENCES)
106
129
  .filter(([key]) => key !== "custom") // Remove custom option for multiselect
107
130
  .map(([key, audience]) => ({
@@ -120,7 +143,15 @@ export default async function init(
120
143
  // Save target audience choices as keys
121
144
  input.targetAudienceTypes = audienceChoices;
122
145
 
123
- // 3. Reader knowledge level - what do readers typically know when they arrive?
146
+ // 3. Custom rules - any specific requirements for the documentation?
147
+ const rulesInput = await options.prompts.input({
148
+ message:
149
+ "📋 [3/9]: Any custom rules or requirements for your documentation? (Optional, press Enter to skip)",
150
+ default: "",
151
+ });
152
+ input.rules = rulesInput.trim();
153
+
154
+ // 4. Reader knowledge level - what do readers typically know when they arrive?
124
155
  // Determine default based on selected purposes using mapping
125
156
  const mappedPurpose = prioritizedPurposes.find(
126
157
  (purpose) => PURPOSE_TO_KNOWLEDGE_MAPPING[purpose],
@@ -135,7 +166,7 @@ export default async function init(
135
166
  );
136
167
 
137
168
  const knowledgeChoice = await options.prompts.select({
138
- message: "🧠 [3/8]: How much do readers already know about your project?",
169
+ message: "🧠 [4/9]: How much do readers already know about your project?",
139
170
  choices: Object.entries(filteredKnowledgeOptions).map(([key, level]) => ({
140
171
  name: `${level.name}`,
141
172
  description: level.description,
@@ -180,7 +211,7 @@ export default async function init(
180
211
  );
181
212
 
182
213
  const depthChoice = await options.prompts.select({
183
- message: "📊 [4/8]: How detailed should your documentation be?",
214
+ message: "📊 [5/9]: How detailed should your documentation be?",
184
215
  choices: Object.entries(filteredDepthOptions).map(([key, depth]) => ({
185
216
  name: `${depth.name}`,
186
217
  description: depth.description,
@@ -198,7 +229,7 @@ export default async function init(
198
229
 
199
230
  // Let user select primary language from supported list
200
231
  const primaryLanguageChoice = await options.prompts.select({
201
- message: "🌐 [5/8]: What's your main documentation language?",
232
+ message: "🌐 [6/9]: What's your main documentation language?",
202
233
  choices: SUPPORTED_LANGUAGES.map((lang) => ({
203
234
  name: `${lang.label} - ${lang.sample}`,
204
235
  value: lang.code,
@@ -215,7 +246,7 @@ export default async function init(
215
246
  );
216
247
 
217
248
  const translateLanguageChoices = await options.prompts.checkbox({
218
- message: "🔄 [6/8]: Which languages should we translate to?",
249
+ message: "🔄 [7/9]: Which languages should we translate to?",
219
250
  choices: availableTranslationLanguages.map((lang) => ({
220
251
  name: `${lang.label} - ${lang.sample}`,
221
252
  value: lang.code,
@@ -226,13 +257,13 @@ export default async function init(
226
257
 
227
258
  // 7. Documentation directory
228
259
  const docsDirInput = await options.prompts.input({
229
- message: `📁 [7/8]: Where should we save your documentation?`,
260
+ message: `📁 [8/9]: Where should we save your documentation?`,
230
261
  default: `${outputPath}/docs`,
231
262
  });
232
263
  input.docsDir = docsDirInput.trim() || `${outputPath}/docs`;
233
264
 
234
265
  // 8. Content sources
235
- console.log("\n🔍 [8/8]: Content Sources");
266
+ console.log("\n🔍 [9/9]: Content Sources");
236
267
  console.log(
237
268
  "What folders/files should we analyze for documentation? (e.g., ./src, ./docs, ./README.md)",
238
269
  );
@@ -377,7 +408,7 @@ export function generateYAML(input) {
377
408
  documentationDepth: input.documentationDepth || "",
378
409
 
379
410
  // Custom rules and target audience (empty for user to fill)
380
- rules: "",
411
+ rules: input.rules || "",
381
412
  targetAudience: "",
382
413
 
383
414
  // Language settings
@@ -8,6 +8,7 @@ skills:
8
8
  - url: ../init/index.mjs
9
9
  default_input:
10
10
  skipIfExists: true
11
+ checkOnly: true
11
12
  - publish-docs.mjs
12
13
  input_schema:
13
14
  type: object
@@ -5,13 +5,17 @@ import chalk from "chalk";
5
5
  import fs from "fs-extra";
6
6
 
7
7
  import { getAccessToken } from "../../utils/auth-utils.mjs";
8
- import { DISCUSS_KIT_STORE_URL, TMP_DIR, TMP_DOCS_DIR } from "../../utils/constants/index.mjs";
8
+ import {
9
+ DEFAULT_APP_URL,
10
+ DISCUSS_KIT_STORE_URL,
11
+ DOC_SMITH_DIR,
12
+ TMP_DIR,
13
+ TMP_DOCS_DIR,
14
+ } from "../../utils/constants/index.mjs";
9
15
  import { beforePublishHook, ensureTmpDir } from "../../utils/d2-utils.mjs";
10
16
  import { deploy } from "../../utils/deploy.mjs";
11
17
  import { getGithubRepoUrl, loadConfigFromFile, saveValueToConfig } from "../../utils/utils.mjs";
12
18
 
13
- const DEFAULT_APP_URL = "https://docsmith.aigne.io";
14
-
15
19
  export default async function publishDocs(
16
20
  { docsDir: rawDocsDir, appUrl, boardId, projectName, projectDesc, projectLogo },
17
21
  options,
@@ -19,9 +23,7 @@ export default async function publishDocs(
19
23
  // move work dir to tmp-dir
20
24
  await ensureTmpDir();
21
25
 
22
- const hasDocSmithBaseUrl = !!process.env.DOC_SMITH_BASE_URL;
23
-
24
- const docsDir = join(".aigne", "doc-smith", TMP_DIR, TMP_DOCS_DIR);
26
+ const docsDir = join(DOC_SMITH_DIR, TMP_DIR, TMP_DOCS_DIR);
25
27
  await fs.rm(docsDir, { recursive: true, force: true });
26
28
  await fs.mkdir(docsDir, {
27
29
  recursive: true,
@@ -61,22 +63,18 @@ export default async function publishDocs(
61
63
  name: `${chalk.blue("Your existing website")} - Integrate and publish directly on your current site (setup required)`,
62
64
  value: "custom",
63
65
  },
64
- ...(hasCachedCheckoutId && hasDocSmithBaseUrl
66
+ ...(hasCachedCheckoutId
65
67
  ? [
66
68
  {
67
- name: `${chalk.yellow("Resume previous website setup")} - ${chalk.green("Already paid.")} Continue where you left off. Your payment is already processed.`,
69
+ name: `${chalk.yellow("Resume previous website setup")} - ${chalk.green("Already paid.")} Continue where you left off. Your payment has already been processed.`,
68
70
  value: "new-instance-continue",
69
71
  },
70
72
  ]
71
73
  : []),
72
- ...(hasDocSmithBaseUrl
73
- ? [
74
- {
75
- name: `${chalk.blue("New website")} - ${chalk.yellow("Paid service.")} We'll help you set up a brand-new website with custom domain and hosting. Great if you want a professional presence.`,
76
- value: "new-instance",
77
- },
78
- ]
79
- : []),
74
+ {
75
+ name: `${chalk.blue("New website")} - ${chalk.yellow("Paid service.")} We'll help you set up a brand-new website with custom domain and hosting. Great if you want a professional presence.`,
76
+ value: "new-instance",
77
+ },
80
78
  ],
81
79
  });
82
80
 
@@ -100,7 +98,7 @@ export default async function publishDocs(
100
98
  });
101
99
  // Ensure appUrl has protocol
102
100
  appUrl = userInput.includes("://") ? userInput : `https://${userInput}`;
103
- } else if (hasDocSmithBaseUrl && ["new-instance", "new-instance-continue"].includes(choice)) {
101
+ } else if (["new-instance", "new-instance-continue"].includes(choice)) {
104
102
  // Deploy a new Discuss Kit service
105
103
  try {
106
104
  let id = "";
@@ -118,8 +116,7 @@ export default async function publishDocs(
118
116
  token = ltToken;
119
117
  } catch (error) {
120
118
  const errorMsg = error?.message || "Unknown error occurred";
121
- console.error(`${chalk.red("❌ Failed to publish to website:")} ${errorMsg}`);
122
- return { message: `❌ Publish failed: ${errorMsg}` };
119
+ return { message: `${chalk.red("❌ Failed to publish to website:")} ${errorMsg}` };
123
120
  }
124
121
  }
125
122
  }
@@ -168,7 +165,7 @@ export default async function publishDocs(
168
165
  boardDesc: projectInfo.description,
169
166
  boardCover: projectInfo.icon,
170
167
  mediaFolder: rawDocsDir,
171
- cacheFilePath: join(".aigne", "doc-smith", "upload-cache.yaml"),
168
+ cacheFilePath: join(DOC_SMITH_DIR, "upload-cache.yaml"),
172
169
  boardMeta,
173
170
  });
174
171
 
@@ -5,6 +5,7 @@ skills:
5
5
  - url: ../init/index.mjs
6
6
  default_input:
7
7
  skipIfExists: true
8
+ checkOnly: true
8
9
  - ../utils/load-sources.mjs
9
10
  - type: transform
10
11
  task_render_mode: hide
@@ -48,3 +48,28 @@ output_schema:
48
48
  type: string
49
49
  required:
50
50
  - content
51
+ skills:
52
+ - type: team
53
+ task_render_mode: collapse
54
+ name: generateD2DiagramContent
55
+ skills:
56
+ - ../generate/generate-d2-diagram.yaml
57
+ reflection:
58
+ reviewer: ../generate/check-d2-diagram-valid.mjs
59
+ is_approved: isValid
60
+ max_iterations: 5
61
+ return_last_on_max_iterations: true
62
+ input_schema:
63
+ type: object
64
+ properties:
65
+ documentContent:
66
+ type: string
67
+ description: Source code of current document (without the D2 diagram)
68
+ required:
69
+ - documentContent
70
+ output_schema:
71
+ type: object
72
+ properties:
73
+ d2DiagramSourceCode:
74
+ type: string
75
+ description: Source code for the D2 diagram
@@ -7,6 +7,7 @@ skills:
7
7
  - url: ../init/index.mjs
8
8
  default_input:
9
9
  skipIfExists: true
10
+ checkOnly: true
10
11
  - ../utils/load-sources.mjs
11
12
  - type: transform
12
13
  task_render_mode: hide
@@ -1,6 +1,7 @@
1
1
  type: team
2
2
  name: updateSingleDocument
3
3
  skills:
4
+ - ../utils/transform-detail-datasources.mjs
4
5
  - ../update/user-review-document.mjs
5
6
  - type: transform
6
7
  task_render_mode: hide
@@ -34,18 +34,33 @@ export default async function chooseDocs(
34
34
  );
35
35
 
36
36
  if (mainLanguageFiles.length === 0) {
37
- throw new Error("No documents found in the docs directory");
37
+ throw new Error(
38
+ "No documents found in the docs directory. Please run `aigne docs generate` to generate the documents",
39
+ );
38
40
  }
39
41
 
42
+ // Convert files to choices with titles
43
+ const choices = mainLanguageFiles.map((file) => {
44
+ // Convert filename to flat path to find corresponding document structure item
45
+ const flatName = file.replace(/\.md$/, "").replace(/\.\w+(-\w+)?$/, "");
46
+ const docItem = documentExecutionStructure.find((item) => {
47
+ const itemFlattenedPath = item.path.replace(/^\//, "").replace(/\//g, "-");
48
+ return itemFlattenedPath === flatName;
49
+ });
50
+
51
+ // Use title if available, otherwise fall back to filename
52
+ const displayName = docItem?.title || file;
53
+
54
+ return {
55
+ name: displayName,
56
+ value: file,
57
+ };
58
+ });
59
+
40
60
  // Let user select multiple files
41
61
  selectedFiles = await options.prompts.checkbox({
42
62
  message: getActionText(isTranslate, "Select documents to {action}:"),
43
63
  source: (term) => {
44
- const choices = mainLanguageFiles.map((file) => ({
45
- name: file,
46
- value: file,
47
- }));
48
-
49
64
  if (!term) return choices;
50
65
 
51
66
  return choices.filter((choice) => choice.name.toLowerCase().includes(term.toLowerCase()));
@@ -65,12 +80,8 @@ export default async function chooseDocs(
65
80
  // Process selected files and convert to found items
66
81
  foundItems = await processSelectedFiles(selectedFiles, documentExecutionStructure, docsDir);
67
82
  } catch (error) {
68
- console.error(error);
69
83
  throw new Error(
70
- getActionText(
71
- isTranslate,
72
- "Please provide a docs parameter to specify which documents to {action}",
73
- ),
84
+ getActionText(isTranslate, `\nFailed to select documents to {action}: ${error.message}`),
74
85
  );
75
86
  }
76
87
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aigne/doc-smith",
3
- "version": "0.8.11-beta.3",
3
+ "version": "0.8.11-beta.5",
4
4
  "description": "AI-driven documentation generation tool built on the AIGNE Framework",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -19,7 +19,7 @@
19
19
  "@aigne/gemini": "^0.14.0",
20
20
  "@aigne/openai": "^0.16.0",
21
21
  "@aigne/publish-docs": "^0.11.0",
22
- "@blocklet/payment-broker-client": "^1.20.20",
22
+ "@blocklet/payment-broker-client": "^1.21.5",
23
23
  "@terrastruct/d2": "^0.1.33",
24
24
  "chalk": "^5.5.0",
25
25
  "cli-highlight": "^2.1.11",
@@ -1,12 +1,51 @@
1
- <d2_generate_constraints>
2
1
  # D2 Diagram Generation Expert Guide
3
2
 
4
3
  ## Preamble: LLM Role and Core Objective
5
4
 
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.
5
+ You are an AI diagram generator with the personality of an **ISTJ (The Logistician)**.
6
+ You are reliable, rule-abiding, and methodical. Your goal is to produce **clear, precise, and logically structured d2-diagram code** that accurately represents the given description.
7
7
 
8
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.
9
9
 
10
+ You value **order, consistency, and factual accuracy** over abstract or decorative styles.
11
+ Your diagrams should focus on **readability, structural correctness, and practical use in technical documentation**.
12
+
13
+ **ISTJ-style guiding principles for your diagram generation:**
14
+
15
+ 1. **Fact-Driven and Accurate:**
16
+ - Adhere strictly to the provided description and rules.
17
+ - Do not assume or add elements that are not explicitly described.
18
+
19
+ 2. **Structured and Orderly:**
20
+ - Organize diagram elements in a logical, hierarchical order (e.g., top-down for processes, left-to-right for data flows).
21
+ - Group related nodes consistently.
22
+ - Maintain clear flow and avoid unnecessary crossing lines.
23
+
24
+ 3. **Clarity and Precision:**
25
+ - Use simple, standard shapes and consistent node labeling.
26
+ - Ensure every arrow or connection has a clear meaning (e.g., data flow, control flow).
27
+ - Avoid ambiguous or decorative text.
28
+
29
+ 4. **Standards and Consistency:**
30
+ - Follow best practices for technical diagrams (e.g., rectangular boxes for processes, cylinders for data storage, labeled arrows for flows).
31
+ - Maintain consistent spacing, alignment, and sizing in the diagram code.
32
+
33
+ 5. **Practical and Maintainable:**
34
+ - Ensure the generated d2 code is concise, easy to edit, and reproducible.
35
+ - Provide comments in the d2 code (if necessary) to clarify sections or complex relationships.
36
+ - Avoid unnecessary stylistic complexity that may hinder future maintenance.
37
+
38
+ **Output Requirements:**
39
+ - Output only valid d2-diagram code.
40
+ - Do not include explanatory text outside of the code block.
41
+ - Ensure the diagram reflects a clean, professional, ISTJ-style technical drawing.
42
+ - output must be wrap with
43
+ ```md
44
+ \`\`\`d2\n...\n\`\`\`
45
+ ```
46
+
47
+
48
+
10
49
  ## Chapter 1: Core Instructions for D2 Diagram Generation
11
50
 
12
51
  This chapter establishes the foundational rules for generating the structure and logic of a D2 diagram. It prioritizes semantic correctness and adherence to diagramming principles over aesthetic concerns, which are addressed in Chapter 2.
@@ -1090,6 +1129,3 @@ Session.t2 -> Session.t2: "Update and remove status effects"
1090
1129
  Session.t2 -> Lua: "Trigger OnPlayerTurn"
1091
1130
  User.t2 <- Session.t2
1092
1131
  ```
1093
-
1094
-
1095
- </d2_generate_constraints>
@@ -0,0 +1,4 @@
1
+ Follow the given rules and ISTJ style from your system instructions.
2
+
3
+ Generate a d2-diagram that represents the following document content:
4
+ {{documentContent}}
@@ -19,9 +19,8 @@ Documentation Generation Rules:
19
19
  - When describing multiple properties of the same object, wrap the outermost `<x-field>` elements with `<x-field-group>` elements. Note that nested `<x-field>` elements do not need wrapping
20
20
  - All interface and method documentation must include **response data examples**
21
21
  - For simple list data, use Markdown tables to present information clearly and improve readability
22
- - Validate output Markdown for completeness, ensuring tables and d2 diagrams are properly formatted
23
- - **Content Integrity**: Generate complete, syntactically correct code blocks (d2, JSON, etc.). Perform self-validation to ensure all code blocks, lists, and tables are properly closed without truncation
24
- - **Code Block Atomicity**: Treat code blocks (e.g., ```d2 ... ```) as indivisible units. Generate them completely from opening marker (```d2) to closing marker (```) without interruption
22
+ - Validate output Markdown for completeness, ensuring tables are properly formatted
23
+ - **Content Integrity**: Generate complete, syntactically correct code blocks (JSON, etc.). Perform self-validation to ensure all code blocks, lists, and tables are properly closed without truncation
25
24
  - **Markdown Syntax Validation**: Ensure correct Markdown formatting, particularly table separators (e.g., `|---|---|---|`) that match column counts
26
25
  - Use README files for reference only—extract the most current and comprehensive information directly from source code
27
26
  - Omit tag information from document headers as it's processed programmatically
@@ -37,8 +37,14 @@ Custom component generation rules:
37
37
  Custom code block generation rules:
38
38
  {% include "custom/custom-code-block.md" %}
39
39
 
40
- D2 Diagram Generation Expert Guide:
41
- {% include "d2-chart/rules.md" %}
40
+ Diagram generate guide:
41
+ Evaluate for each document whether diagrams are necessary.
42
+ - Use diagrams to clarify complex concepts and diversify the presentation of the page.
43
+ - The document overview page must include an architecture diagram that illustrates the entire document structure.
44
+ - For the first page of each section, include a structural diagram of the current module when it adds clarity.
45
+ - For individual article pages, consider detailed flowcharts when the content or overall architecture warrants them.
46
+ - The number of diagrams is flexible, but aim for 0-3 diagrams as a practical range.
47
+
42
48
  </content_generation_rules>
43
49
 
44
50
  {% if glossary %}
@@ -70,8 +70,6 @@ Custom component optimization rules:
70
70
  Custom code block optimization rules:
71
71
  {% include "custom/custom-code-block.md" %}
72
72
 
73
- D2 Diagram optimization rules:
74
- {% include "d2-chart/rules.md" %}
75
73
  </content_optimization_rules>
76
74
 
77
75
  {% if glossary %}
@@ -95,7 +93,7 @@ parentId: {{parentId}}
95
93
  </current_document>
96
94
 
97
95
  <datasources>
98
- {{ datasources }}
96
+ {{ detailDataSources }}
99
97
 
100
98
  {{ additionalInformation }}
101
99
 
@@ -0,0 +1,16 @@
1
+ <code_block_rules>
2
+ The following formats are considered Code Blocks:
3
+ - Wrapped with ```
4
+ - Supports configurations: language, title, icon, where title and icon are optional
5
+ - content can be code, command line examples, text or any other content
6
+
7
+ <code_block_sample>
8
+ ```{language} [{title}] [icon={icon}]
9
+ {content}
10
+ ```
11
+ </code_block_sample>
12
+
13
+ Code Block Translation:
14
+ - For D2 code blocks, only translate labels
15
+ - For other language code blocks, **only translate comments starting with #, keep all other content unchanged without translation**
16
+ </code_block_rules>