@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
@@ -8,37 +8,12 @@ NOTICE: There are additional data source contents not displayed. When operating
8
8
  </data_sources>
9
9
 
10
10
  {% if userContext.openAPISpec %}
11
- <openapi>
12
-
13
- **Goal:** Use the provided OpenAPI (Swagger) specification to design how the OpenAPI content and the overall document should be structured together.
14
-
15
- **OpenAPI File Content:**
16
- <openapi_doc>
11
+ <openapi_spec_content>
12
+ ## OpenAPI Spec Content
17
13
 
18
14
  {{ userContext.openAPISpec }}
19
15
 
20
- </openapi_doc>
21
-
22
- ---
23
-
24
- ### **Documentation Requirements and Constraints**
25
-
26
- 1. **Section structure and titles:**
27
- * Create a dedicated top-level section for the OpenAPI content.
28
- * The section title must be professional and user friendly; **never** include terms such as OpenAPI, Swagger, or file formats. Recommended titles include **"API Interface Reference"** or **"Interface Reference"**.
29
-
30
- 2. **Content hierarchy and presentation:**
31
- * **Ideal state (single-level page):** Prefer to present all API endpoints within **one Markdown file (one page)**.
32
- * **Split criteria (two-level pages):** Only when the number of endpoints is too large for a single file should you split by OpenAPI tags or logical modules, creating individual Markdown files per module.
33
- * **Forced file hierarchy constraint:** Whether using one or two levels, the generated API reference files (Markdown) may contain **no more than two levels.**
34
- * **Example (two-level structure):** `/api-reference.md` (index) -> `/api/user.md`, `/api/order.md` (module pages)
35
- * **Disallow any third level or deeper structure:** for example, `/api/v1/user/get.md`.
36
-
37
- 3. **Mandatory API description constraints (deduplication rule):**
38
- * **Ensure that for the entire document (including preface, overview, etc.), any introduction to the project APIs appears only within this OpenAPI-generated "API reference" section.**
39
- * **Never** repeat or extend the API list elsewhere in the document (for example, "Quick Start" or "Architecture Overview" sections).
40
-
41
- </openapi>
16
+ </openapi_spec_content>
42
17
  {% endif %}
43
18
 
44
19
  <document_info>
@@ -50,7 +25,7 @@ projectDesc: |
50
25
  {% endif %}
51
26
  </document_info>
52
27
 
53
- <last_document_structure>
28
+ <previous_document_structure>
54
29
 
55
30
  {% if originalDocumentStructure %}
56
31
  {{ originalDocumentStructure | yaml.stringify }}
@@ -60,19 +35,18 @@ projectDesc: |
60
35
  No previous document structure provided. generate a new structure based on the data sources!
61
36
  {% endif %}
62
37
 
63
- </last_document_structure>
64
-
38
+ </previous_document_structure>
65
39
 
66
40
  {% include "../../common/document-structure/user-locale-rules.md" %}
67
41
 
68
42
  {% include "../../common/document-structure/user-preferences.md" %}
69
43
 
70
- <last_document_structure_rule>
71
- If a previous structural plan (last_document_structure) is provided, follow these rules:
72
- 1. **Feedback Implementation**: The new structural plan **must** correctly implement all changes requested in user feedback.
73
- 2. **Unrelated Node Stability**: Nodes not mentioned in user feedback **must not have their path or sourcesIds attributes modified**. `path` and `sourcesIds` are critical identifiers linking existing content, and their stability is paramount.
74
- Ideally, other attributes (such as `title`, `description`) should also remain stable, unless these changes are directly caused by a requested modification or result from DataSource updates.
75
- </last_document_structure_rule>
44
+ <previous_document_structure_rule>
45
+ If a previous structural plan (`<previous_document_structure>`) is provided, follow these rules:
46
+ 1. **Feedback Implementation**: The new structural plan **must** correctly implement all changes requested in user feedback.
47
+ 2. **Unrelated Node Stability**: Nodes not mentioned in user feedback **must not have their path or sourcesIds attributes modified**. `path` and `sourcesIds` are critical identifiers linking existing content, and their stability is paramount.
48
+ - Ideally, other attributes (such as `title`, `description`) should also remain stable, unless these changes are directly caused by a requested modification or result from DataSource updates.
49
+ </previous_document_structure_rule>
76
50
 
77
51
  {% if documentStructure %}
78
52
  <review_document_structure>
@@ -109,7 +83,8 @@ Sub-structures must meet the following requirements:
109
83
  {% endif %}
110
84
 
111
85
  <instructions>
112
- Your task is to **analyze, refine, and adjust** the existing document structure (`last_document_structure`) based on the partial code repository content currently provided, generating a structural update plan.
86
+
87
+ Your task is to **analyze, refine, and adjust** the existing document structure (`<previous_document_structure>`) based on the partial code repository content currently provided, generating a structural update plan.
113
88
  You are not creating a structure from scratch, but rather **performing intelligent updates based on understanding the existing structure** to make the document structure more accurately reflect the latest code content, architectural changes, and logical relationships.
114
89
 
115
90
  ## When using `<data_sources>` data sources, please note the following:
@@ -132,7 +107,7 @@ IMPORTANT: You should avoid duplicating existing structure items. Only include i
132
107
  ## Behavior Rules
133
108
 
134
109
  1. **Understanding and Inheritance**
135
- - Fully understand the hierarchical logic, section divisions, and naming style in `<last_document_structure>`.
110
+ - Fully understand the hierarchical logic, section divisions, and naming style in `<previous_document_structure>`.
136
111
  - Perform incremental updates based on this foundation, not complete rewrites.
137
112
  - Preserve existing reasonable structures, only modify or extend when there is clear justification.
138
113
 
@@ -8,6 +8,7 @@ export const documentItemSchema = z.object({
8
8
  path: z.string().startsWith("/", 'Path must start with "/"'),
9
9
  parentId: z.string().nullish(),
10
10
  sourceIds: z.array(z.string()).min(1, "At least one source ID is required"),
11
+ icon: z.string().optional(), // Lucide icon name (e.g., lucide:book) for root-level documents
11
12
  });
12
13
 
13
14
  // Documentation structure schema - represents the entire documentation structure array
@@ -1,7 +1,9 @@
1
1
  import { existsSync } from "node:fs";
2
2
  import { mkdir, readFile, writeFile } from "node:fs/promises";
3
- import { dirname, join } from "node:path";
4
- import { fileURLToPath } from "node:url";
3
+ import { dirname, join, resolve } from "node:path";
4
+ import { fileURLToPath, pathToFileURL } from "node:url";
5
+ import terminalLink from "terminal-link";
6
+
5
7
  import { toRelativePath } from "../utils.mjs";
6
8
 
7
9
  /**
@@ -115,6 +117,8 @@ export async function copyHtmlReportTemplate(targetDir, data) {
115
117
  * @returns {string} Success message with links
116
118
  */
117
119
  export function generateReportSuccessMessage(jsonReportPath, htmlReportPath) {
120
+ const openHtmlPath = resolve(htmlReportPath);
121
+ const openUrl = pathToFileURL(openHtmlPath);
118
122
  return `# ✅ Documentation Evaluation Report Generated Successfully!
119
123
 
120
124
  Generated evaluation report and saved to:
@@ -125,7 +129,7 @@ Generated evaluation report and saved to:
125
129
 
126
130
  Open in your browser to view detailed analysis:
127
131
 
128
- \`${htmlReportPath}\`
132
+ \`${terminalLink(openUrl, openUrl)}\`
129
133
 
130
134
  `;
131
135
  }
@@ -1,27 +0,0 @@
1
- type: team
2
- name: docs_fs_actor
3
- description: File system operations for documentation management
4
- skills:
5
- - url: ../init/index.mjs
6
- default_input:
7
- skipIfExists: true
8
- - url: ./fs.mjs
9
- default_input:
10
- rootDir:
11
- $get: docsDir
12
- input_schema:
13
- type: object
14
- properties:
15
- action:
16
- type: "string"
17
- enum: ["read_file", "write_file", "delete_file", "list_directory"]
18
- description:
19
- "The file system action to perform, available actions are: read_file, write_file, delete_file, list_directory"
20
- path:
21
- type: "string"
22
- description: "The path to the file or directory to operate on"
23
- content:
24
- type: "string"
25
- description: "The content to write to the file, required for write_file action"
26
- required: ["action", "path"]
27
- task_render_mode: hide
@@ -1,60 +0,0 @@
1
- import { mkdir, readdir, readFile, rm, writeFile } from "node:fs/promises";
2
- import { dirname, join } from "node:path";
3
-
4
- export default async function fs({ rootDir, action, path, content }) {
5
- if (!rootDir) throw new Error("Root directory is not specified");
6
-
7
- path = join(rootDir, path);
8
-
9
- switch (action) {
10
- case "read_file":
11
- return {
12
- status: "ok",
13
- path,
14
- content: await readFile(path, "utf-8"),
15
- };
16
- case "write_file": {
17
- await mkdir(dirname(path), { recursive: true });
18
- await writeFile(path, content || "");
19
- return {
20
- status: "ok",
21
- path,
22
- content,
23
- };
24
- }
25
- case "delete_file":
26
- await rm(path, { recursive: true, force: true });
27
- return {
28
- status: "ok",
29
- path,
30
- };
31
- case "list_directory":
32
- return {
33
- status: "ok",
34
- entries: await readdir(path, { withFileTypes: true }).then((list) =>
35
- list.map((entry) => ({
36
- path: join(entry.parentPath, entry.name),
37
- isDirectory: entry.isDirectory(),
38
- })),
39
- ),
40
- };
41
- }
42
- }
43
-
44
- fs.input_schema = {
45
- type: "object",
46
- properties: {
47
- action: {
48
- type: "string",
49
- enum: ["read_file", "write_file", "delete_file", "list_directory"],
50
- description:
51
- "The file system action to perform, available actions are: read_file, write_file, delete_file, list_directory",
52
- },
53
- path: { type: "string", description: "The path to the file or directory to operate on" },
54
- content: {
55
- type: "string",
56
- description: "The content to write to the file, required for write_file action",
57
- },
58
- },
59
- required: ["action", "path"],
60
- };
File without changes