@aigne/doc-smith 0.8.15-beta.8 → 0.8.15

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 (68) hide show
  1. package/CHANGELOG.md +73 -0
  2. package/agents/evaluate/document-structure.yaml +3 -1
  3. package/agents/evaluate/document.yaml +3 -1
  4. package/agents/evaluate/index.yaml +1 -3
  5. package/agents/generate/check-diagram.mjs +1 -1
  6. package/agents/generate/generate-structure.yaml +25 -71
  7. package/agents/generate/index.yaml +1 -2
  8. package/agents/generate/{merge-d2-diagram.yaml → merge-diagram.yaml} +7 -6
  9. package/agents/generate/update-document-structure.yaml +51 -45
  10. package/agents/generate/user-review-document-structure.mjs +3 -26
  11. package/agents/generate/utils/merge-document-structures.mjs +8 -32
  12. package/agents/init/check.mjs +1 -1
  13. package/agents/init/index.mjs +52 -2
  14. package/agents/init/validate.mjs +16 -0
  15. package/agents/publish/publish-docs.mjs +16 -10
  16. package/agents/schema/document-execution-structure.yaml +1 -1
  17. package/agents/schema/document-structure-item.yaml +1 -1
  18. package/agents/schema/document-structure-refine-item.yaml +20 -0
  19. package/agents/schema/document-structure.yaml +4 -2
  20. package/agents/update/batch-generate-document.yaml +1 -1
  21. package/agents/update/check-generate-diagram.mjs +84 -0
  22. package/agents/update/generate-diagram.yaml +0 -1
  23. package/agents/update/generate-document.yaml +4 -4
  24. package/agents/update/handle-document-update.yaml +9 -1
  25. package/agents/update/pre-check-generate-diagram.yaml +44 -0
  26. package/agents/update/update-document-detail.yaml +64 -58
  27. package/agents/update/update-single-document.yaml +1 -2
  28. package/agents/update/user-review-document.mjs +8 -6
  29. package/agents/utils/analyze-feedback-intent.yaml +29 -0
  30. package/agents/utils/choose-docs.mjs +16 -6
  31. package/agents/utils/find-item-by-path.mjs +4 -2
  32. package/agents/utils/load-sources.mjs +6 -6
  33. package/agents/utils/map-reasoning-effort-level.mjs +15 -0
  34. package/agents/utils/save-sidebar.mjs +12 -33
  35. package/agents/utils/{transform-detail-datasources.mjs → transform-detail-data-sources.mjs} +3 -3
  36. package/aigne.yaml +14 -3
  37. package/package.json +10 -9
  38. package/prompts/common/document/content-rules-core.md +6 -6
  39. package/prompts/common/document/openapi-usage-rules.md +36 -0
  40. package/prompts/common/document/role-and-personality.md +1 -2
  41. package/prompts/common/document-structure/conflict-resolution-guidance.md +2 -2
  42. package/prompts/common/document-structure/document-structure-rules.md +8 -8
  43. package/prompts/common/document-structure/output-constraints.md +3 -3
  44. package/prompts/detail/custom/custom-code-block.md +36 -1
  45. package/prompts/detail/custom/{custom-components.md → custom-components-usage-rules.md} +29 -7
  46. package/prompts/detail/d2-diagram/pre-check.md +23 -0
  47. package/prompts/detail/d2-diagram/rules.md +44 -29
  48. package/prompts/detail/d2-diagram/system-prompt.md +0 -14
  49. package/prompts/detail/d2-diagram/user-prompt.md +10 -1
  50. package/prompts/detail/generate/document-rules.md +3 -3
  51. package/prompts/detail/generate/system-prompt.md +2 -8
  52. package/prompts/detail/generate/user-prompt.md +13 -60
  53. package/prompts/detail/update/system-prompt.md +3 -8
  54. package/prompts/detail/update/user-prompt.md +9 -5
  55. package/prompts/evaluate/document.md +0 -4
  56. package/prompts/structure/check-document-structure.md +4 -4
  57. package/prompts/structure/generate/system-prompt.md +0 -1
  58. package/prompts/structure/generate/user-prompt.md +21 -18
  59. package/prompts/structure/review/structure-review-system.md +24 -16
  60. package/prompts/structure/update/system-prompt.md +0 -13
  61. package/prompts/structure/update/user-prompt.md +6 -5
  62. package/prompts/translate/translate-document.md +3 -3
  63. package/prompts/utils/analyze-feedback-intent.md +55 -0
  64. package/utils/constants/index.mjs +38 -0
  65. package/utils/deploy.mjs +3 -1
  66. package/utils/docs-finder-utils.mjs +37 -3
  67. package/utils/file-utils.mjs +97 -0
  68. package/utils/load-config.mjs +19 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,78 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.8.15](https://github.com/AIGNE-io/aigne-doc-smith/compare/v0.8.15-beta.16...v0.8.15) (2025-11-07)
4
+
5
+ ## [0.8.15-beta.16](https://github.com/AIGNE-io/aigne-doc-smith/compare/v0.8.15-beta.15...v0.8.15-beta.16) (2025-11-07)
6
+
7
+
8
+ ### Features
9
+
10
+ * support customize diagramming quantity ([#277](https://github.com/AIGNE-io/aigne-doc-smith/issues/277)) ([9d9fa6a](https://github.com/AIGNE-io/aigne-doc-smith/commit/9d9fa6a1f344c93df187f2dc502c5479e304e0f4))
11
+
12
+ ## [0.8.15-beta.15](https://github.com/AIGNE-io/aigne-doc-smith/compare/v0.8.15-beta.14...v0.8.15-beta.15) (2025-11-07)
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * add two-tier thinking effort configuration system ([#273](https://github.com/AIGNE-io/aigne-doc-smith/issues/273)) ([b72d066](https://github.com/AIGNE-io/aigne-doc-smith/commit/b72d066698bae253a9ee2dfa231bf73cd59d7529))
18
+
19
+ ## [0.8.15-beta.14](https://github.com/AIGNE-io/aigne-doc-smith/compare/v0.8.15-beta.13...v0.8.15-beta.14) (2025-11-06)
20
+
21
+
22
+ ### Features
23
+
24
+ * add reasoning effort configuration for customizable AI model settings ([#270](https://github.com/AIGNE-io/aigne-doc-smith/issues/270)) ([9f15638](https://github.com/AIGNE-io/aigne-doc-smith/commit/9f156387120e8705bf16cf611d7f8f39995c36b3))
25
+ * **cli:** enhance auth with short link responses and detailed error reporting for publishing ([#269](https://github.com/AIGNE-io/aigne-doc-smith/issues/269)) ([31cc252](https://github.com/AIGNE-io/aigne-doc-smith/commit/31cc25236667236dfe91543acdd7e8cccff659c5))
26
+
27
+
28
+ ### Bug Fixes
29
+
30
+ * use default reasoning effort for existing config ([#272](https://github.com/AIGNE-io/aigne-doc-smith/issues/272)) ([2fc9c89](https://github.com/AIGNE-io/aigne-doc-smith/commit/2fc9c89e383c1c5446f2109a2846e831d1e1e871))
31
+
32
+ ## [0.8.15-beta.13](https://github.com/AIGNE-io/aigne-doc-smith/compare/v0.8.15-beta.12...v0.8.15-beta.13) (2025-11-05)
33
+
34
+
35
+ ### Bug Fixes
36
+
37
+ * make paid deployment more smooth stable ([#266](https://github.com/AIGNE-io/aigne-doc-smith/issues/266)) ([ce8c00a](https://github.com/AIGNE-io/aigne-doc-smith/commit/ce8c00ab3eb045c482e07dc3c4e3bd149e754a06))
38
+ * validate docsDir on init and ensure latest doc on view after publish ([#267](https://github.com/AIGNE-io/aigne-doc-smith/issues/267)) ([e45864d](https://github.com/AIGNE-io/aigne-doc-smith/commit/e45864da4a7fb5b09af2bbffdb7ca93abd74397c))
39
+
40
+ ## [0.8.15-beta.12](https://github.com/AIGNE-io/aigne-doc-smith/compare/v0.8.15-beta.11...v0.8.15-beta.12) (2025-11-05)
41
+
42
+
43
+ ### Features
44
+
45
+ * tune token consumption for update ops with intent analysis ([#264](https://github.com/AIGNE-io/aigne-doc-smith/issues/264)) ([8c53d28](https://github.com/AIGNE-io/aigne-doc-smith/commit/8c53d288346ae622e8841866db1b6fbed9d5023d))
46
+
47
+ ## [0.8.15-beta.11](https://github.com/AIGNE-io/aigne-doc-smith/compare/v0.8.15-beta.10...v0.8.15-beta.11) (2025-11-04)
48
+
49
+
50
+ ### Features
51
+
52
+ * warn on invalid sources and tuning translate messages ([#241](https://github.com/AIGNE-io/aigne-doc-smith/issues/241)) ([bd786ca](https://github.com/AIGNE-io/aigne-doc-smith/commit/bd786cad8b0c6fa837511fdc2982c83b7f0095dd))
53
+
54
+
55
+ ### Bug Fixes
56
+
57
+ * avoid useless diagram generate ([#245](https://github.com/AIGNE-io/aigne-doc-smith/issues/245)) ([de7600f](https://github.com/AIGNE-io/aigne-doc-smith/commit/de7600fb5839be9d1f0743adc34fd08c4c11729d))
58
+ * iterate on chunk of datasource to generate structure ([#242](https://github.com/AIGNE-io/aigne-doc-smith/issues/242)) ([0b4db2a](https://github.com/AIGNE-io/aigne-doc-smith/commit/0b4db2a8cac77d6f4a1c197374b9dadbe078346b))
59
+
60
+ ## [0.8.15-beta.10](https://github.com/AIGNE-io/aigne-doc-smith/compare/v0.8.15-beta.9...v0.8.15-beta.10) (2025-11-03)
61
+
62
+
63
+ ### Bug Fixes
64
+
65
+ * remove empty xml tag in prompt ([#239](https://github.com/AIGNE-io/aigne-doc-smith/issues/239)) ([1ec771e](https://github.com/AIGNE-io/aigne-doc-smith/commit/1ec771eb8855bca3730f732a1b68404275633787))
66
+ * standardized variable names and xml tag usage ([#237](https://github.com/AIGNE-io/aigne-doc-smith/pull/237))([00f18b9](https://github.com/AIGNE-io/aigne-doc-smith/commit/00f18b95ba21cd376e369eefb102d2d258e95529))
67
+
68
+ ## [0.8.15-beta.9](https://github.com/AIGNE-io/aigne-doc-smith/compare/v0.8.15-beta.8...v0.8.15-beta.9) (2025-11-03)
69
+
70
+
71
+ ### Bug Fixes
72
+
73
+ * optimize the draw diagram process ([#234](https://github.com/AIGNE-io/aigne-doc-smith/issues/234)) ([7bdc0d9](https://github.com/AIGNE-io/aigne-doc-smith/commit/7bdc0d939df05b9d31e06ea0f0285ed0eafe74ae))
74
+ * simplify document structure merging and add deletion support ([#235](https://github.com/AIGNE-io/aigne-doc-smith/issues/235)) ([7f10242](https://github.com/AIGNE-io/aigne-doc-smith/commit/7f1024294bde241f41034d3e01a542451030cbdc))
75
+
3
76
  ## [0.8.15-beta.8](https://github.com/AIGNE-io/aigne-doc-smith/compare/v0.8.15-beta.7...v0.8.15-beta.8) (2025-11-01)
4
77
 
5
78
 
@@ -2,7 +2,9 @@ name: evaluateDocumentStructure
2
2
  description: Evaluates the results generated by the document-structure agent to ensure they meet expectations, especially in scenarios with previous generation results and user feedback.
3
3
  instructions:
4
4
  url: ../../prompts/evaluate/document-structure.md
5
- model: openai/gpt-5
5
+ model:
6
+ model: openai/gpt-5
7
+ temperature: 1
6
8
  # model: anthropic/claude-opus-4-0
7
9
  task_render_mode: collapse
8
10
  task_title: Evaluate the structure of the documentation
@@ -2,7 +2,9 @@ name: evaluateDocument
2
2
  description: Evaluates the quality of generated document content, ensuring compliance with user-configured goals, audiences, and knowledge level requirements.
3
3
  instructions:
4
4
  url: ../../prompts/evaluate/document.md
5
- model: openai/gpt-5
5
+ model:
6
+ model: openai/gpt-5
7
+ temperature: 1
6
8
  # model: anthropic/claude-opus-4-0
7
9
  task_render_mode: collapse
8
10
  task_title: Evaluate document for '{{ title }}'
@@ -16,9 +16,7 @@ skills:
16
16
  $merge([
17
17
  $,
18
18
  {
19
- "documentStructure": originalDocumentStructure,
20
- "datasources": "",
21
- "datasourcesList": ""
19
+ "documentStructure": originalDocumentStructure
22
20
  }
23
21
  ])
24
22
  - ./document-structure.yaml
@@ -9,7 +9,7 @@ export default async function checkD2DiagramIsValid({ diagramSourceCode }) {
9
9
  } catch (err) {
10
10
  return {
11
11
  isValid: false,
12
- error: err.message,
12
+ diagramError: err.message,
13
13
  };
14
14
  }
15
15
  }
@@ -4,11 +4,9 @@ description: Generate the structure and organization of your documentation
4
4
  skills:
5
5
  - type: team
6
6
  name: generateStructureWorker
7
- iterate_on: datasources
7
+ iterate_on: dataSources
8
8
  skills:
9
9
  - type: ai
10
- model:
11
- reasoning_effort: 500
12
10
  instructions:
13
11
  - role: system
14
12
  url: ../../prompts/structure/generate/system-prompt.md
@@ -26,7 +24,7 @@ skills:
26
24
  locale:
27
25
  type: string
28
26
  description: Primary language for documentation (e.g., zh, en, ja)
29
- datasources:
27
+ dataSourceChunk:
30
28
  type: string
31
29
  description: Project content and context to help generate documentation structure
32
30
  targetAudience:
@@ -50,7 +48,7 @@ skills:
50
48
  default: general
51
49
  required:
52
50
  - rules
53
- - datasources
51
+ - dataSourceChunk
54
52
  output_schema:
55
53
  type: object
56
54
  properties:
@@ -60,31 +58,10 @@ skills:
60
58
  projectDesc:
61
59
  type: string
62
60
  description: Brief project description generated from content analysis (under 50 words)
63
- add:
61
+ structures:
64
62
  type: array
65
- description: List of document structure items to add, null or empty array means no addition
66
- items:
67
- type: object
68
- properties:
69
- index:
70
- type: integer
71
- description: Position to insert the new item, null means append to the end
72
- item: ../schema/document-structure-item.yaml
73
- required:
74
- - item
75
- update:
76
- type: array
77
- description: List of document structure items to update, replace the item with the same path, null or empty array means no update
78
- items:
79
- type: object
80
- properties:
81
- path:
82
- type: string
83
- description: Path of the document structure item to update or replace
84
- item: ../schema/document-structure-item.yaml
85
- required:
86
- - path
87
- - item
63
+ description: List of document structure items to add or update
64
+ items: ../schema/document-structure-item.yaml
88
65
 
89
66
  - ./utils/merge-document-structures.mjs
90
67
 
@@ -92,9 +69,10 @@ skills:
92
69
  name: aggregateDocumentStructure
93
70
  process: |
94
71
  return {
95
- documentStructure: options.context.userContext.originalDocumentStructure.map(i => ({
72
+ documentStructure: options.context.userContext.originalDocumentStructure.map((i, index) => ({
96
73
  ...i,
97
74
  id: i.title.toLowerCase().replace(/\s+/g, '-'),
75
+ index
98
76
  })),
99
77
  projectName: options.context.userContext.projectName,
100
78
  projectDesc: options.context.userContext.projectDesc,
@@ -102,37 +80,18 @@ skills:
102
80
 
103
81
  - type: ai
104
82
  name: refineStructure
105
- model:
106
- reasoning_effort: 500
107
83
  instructions:
108
84
  - role: system
109
85
  url: ../../prompts/structure/review/structure-review-system.md
110
86
  output_schema:
111
87
  type: object
112
88
  properties:
113
- refinedStructure:
89
+ structures:
114
90
  type: array
115
- description: Optimized document structure array
116
- items:
117
- type: object
118
- description: Document structure item representing a node in the document hierarchy
119
- properties:
120
- id:
121
- type: string
122
- description: Unique identifier for the document structure item
123
- newIndex:
124
- type: integer
125
- description: Used for ordering purposes, indicates the new position index of the document structure item
126
- newPath:
127
- type: string
128
- description: The new path of the document structure item if it has been changed, otherwise can be omitted
129
- newParentPath:
130
- type: string
131
- description: The new parentPath of the document structure item if it has been changed, otherwise can be omitted
132
- required:
133
- - id
91
+ description: Document structure items that need to be updated or changed
92
+ items: ../schema/document-structure-refine-item.yaml
134
93
  required:
135
- - refinedStructure
94
+ - structures
136
95
 
137
96
  - type: function
138
97
  name: finalizeDocumentStructure
@@ -140,23 +99,18 @@ skills:
140
99
  return {
141
100
  projectName: input.projectName,
142
101
  projectDesc: input.projectDesc,
143
- documentStructure: input.documentStructure
144
- .map((item) => {
145
- const refined = input.refinedStructure?.find(i => i.id === item.id)
102
+ documentStructure: input.structures.map(refinedItem => {
103
+ // Find original item to get sourceIds and other fields
104
+ const originalItem = input.documentStructure.find(orig => orig.id === refinedItem.id)
105
+
106
+ const newItem = {
107
+ title: refinedItem.title,
108
+ description: refinedItem.description,
109
+ path: refinedItem.path,
110
+ parentId: refinedItem.parentPath || null, // Convert parentPath to parentId
111
+ sourceIds: originalItem?.sourceIds || [],
112
+ }
146
113
 
147
- return {
148
- ...item,
149
- index: refined?.newIndex || item.index,
150
- path: refined?.newPath || item.path,
151
- parentId: refined?.newParentPath || item.parentPath,
152
- }
153
- })
154
- .sort((a, b) => a.index - b.index)
155
- .map(i => {
156
- const newItem = { ...i }
157
- delete newItem.index
158
- delete newItem.id
159
- delete newItem.parentPath
160
- return newItem
161
- }),
114
+ return newItem
115
+ })
162
116
  }
@@ -38,8 +38,7 @@ skills:
38
38
  'translates': [$map(translateLanguages, function($lang) { {"language": $lang} })]
39
39
  }
40
40
  ])
41
- }),
42
- "datasources": ""
41
+ })
43
42
  }
44
43
  ])
45
44
  - ../utils/format-document-structure.mjs
@@ -1,14 +1,15 @@
1
- name: mergeD2DiagramToDocument
2
- description: Merge D2 Diagram source code into document
1
+ name: mergeDiagramToDocument
2
+ description: Merge Diagram source code into document
3
3
  instructions: |
4
4
  You are an AI assistant that helps to merge d2 diagram into document.
5
5
 
6
- <datasources>
6
+ <detail_data_source>
7
7
  {{ content }}
8
- </datasources>
9
- <datasources>
8
+ </detail_data_source>
9
+
10
+ <diagram_source_code>
10
11
  {{ diagramSourceCode }}
11
- </datasources>
12
+ </diagram_source_code>
12
13
 
13
14
  Given the source content of a document and the D2 diagram source code, your task is to:
14
15
  - **Keep the original content as soon as possible.**
@@ -1,48 +1,54 @@
1
- type: ai
1
+ type: team
2
2
  name: updateDocumentStructure
3
3
  description: Update documentation structure based on user feedback and intentions using structure modification tools
4
- instructions:
5
- - role: system
6
- url: ../../prompts/structure/update/system-prompt.md
7
- - role: user
8
- url: ../../prompts/structure/update/user-prompt.md
9
- input_schema:
10
- type: object
11
- properties:
12
- documentStructure: ../schema/document-structure.yaml
13
- rules:
14
- type: string
15
- description: User configuration rules
16
- locale:
17
- type: string
18
- description: User language, e.g. zh, en
19
- datasources:
20
- type: string
21
- description: Context for documentation structure
22
- glossary:
23
- type: string
24
- description: Glossary of terms
25
- feedback:
26
- type: string
27
- description: User feedback for structure modifications
28
- userPreferences:
29
- type: string
30
- description: Your saved preferences for structure and documentation style
31
- required:
32
- - documentStructure
33
- - feedback
34
- output_key: message
35
- afs:
36
- modules:
37
- - module: system-fs
38
- options:
39
- mount: /sources
40
- path: .
41
- description: |
42
- Codebase of the project to be documented used as context for document generation,
43
- should search and read as needed while generating document content
44
4
  skills:
45
- - ./document-structure-tools/add-document.mjs
46
- - ./document-structure-tools/delete-document.mjs
47
- - ./document-structure-tools/update-document.mjs
48
- - ./document-structure-tools/move-document.mjs
5
+ - url: ../utils/analyze-feedback-intent.yaml
6
+ - type: ai
7
+ instructions:
8
+ - role: system
9
+ url: ../../prompts/structure/update/system-prompt.md
10
+ - role: user
11
+ url: ../../prompts/structure/update/user-prompt.md
12
+ input_schema:
13
+ type: object
14
+ properties:
15
+ documentStructure: ../schema/document-structure.yaml
16
+ rules:
17
+ type: string
18
+ description: User configuration rules
19
+ locale:
20
+ type: string
21
+ description: User language, e.g. zh, en
22
+ dataSourceChunk:
23
+ type: string
24
+ description: Context for documentation structure
25
+ glossary:
26
+ type: string
27
+ description: Glossary of terms
28
+ feedback:
29
+ type: string
30
+ description: User feedback for structure modifications
31
+ userPreferences:
32
+ type: string
33
+ description: Your saved preferences for structure and documentation style
34
+ needDataSources:
35
+ type: boolean
36
+ description: Whether data sources are needed for content modifications
37
+ required:
38
+ - documentStructure
39
+ - feedback
40
+ output_key: message
41
+ afs:
42
+ modules:
43
+ - module: system-fs
44
+ options:
45
+ mount: /sources
46
+ path: .
47
+ description: |
48
+ Codebase of the project to be documented used as context for document generation,
49
+ should search and read as needed while generating document content
50
+ skills:
51
+ - ./document-structure-tools/add-document.mjs
52
+ - ./document-structure-tools/delete-document.mjs
53
+ - ./document-structure-tools/update-document.mjs
54
+ - ./document-structure-tools/move-document.mjs
@@ -1,32 +1,9 @@
1
1
  import { getActiveRulesForScope } from "../../utils/preferences-utils.mjs";
2
2
  import { recordUpdate } from "../../utils/history-utils.mjs";
3
+ import { buildDocumentTree } from "../../utils/docs-finder-utils.mjs";
3
4
 
4
5
  function formatDocumentStructure(structure) {
5
- // Create a map of nodes for easy lookup
6
- const nodeMap = new Map();
7
- const rootNodes = [];
8
-
9
- // First pass: create node map
10
- structure.forEach((node) => {
11
- nodeMap.set(node.path, {
12
- ...node,
13
- children: [],
14
- });
15
- });
16
-
17
- // Build the tree structure
18
- structure.forEach((node) => {
19
- if (node.parentId) {
20
- const parent = nodeMap.get(node.parentId);
21
- if (parent) {
22
- parent.children.push(nodeMap.get(node.path));
23
- } else {
24
- rootNodes.push(nodeMap.get(node.path));
25
- }
26
- } else {
27
- rootNodes.push(nodeMap.get(node.path));
28
- }
29
- });
6
+ const { rootNodes } = buildDocumentTree(structure);
30
7
 
31
8
  function printNode(node, depth = 0) {
32
9
  const INDENT_SPACES = " ";
@@ -140,7 +117,7 @@ export default async function userReviewDocumentStructure({ documentStructure, .
140
117
  // Call refineDocumentStructure agent with feedback
141
118
  await options.context.invoke(refineAgent, {
142
119
  ...rest,
143
- datasources: rest.datasources[0].datasources,
120
+ dataSourceChunk: rest.dataSources[0].dataSourceChunk,
144
121
  feedback: feedback.trim(),
145
122
  documentStructure: currentStructure,
146
123
  userPreferences,
@@ -11,44 +11,20 @@ export default async function mergeDocumentStructures(input, options) {
11
11
 
12
12
  options.context.userContext.originalDocumentStructure ??= [];
13
13
 
14
- const structure = options.context.userContext.originalDocumentStructure;
14
+ const originalStructures = [...options.context.userContext.originalDocumentStructure];
15
15
 
16
- if (input.add) {
17
- for (const { index, item } of input.add) {
18
- if (index != null && index >= 0 && index < structure.length) {
19
- structure.splice(index, 0, item);
16
+ if (input.structures) {
17
+ for (const item of input.structures) {
18
+ const index = originalStructures.findIndex((s) => s.path === item.path);
19
+ if (index !== -1) {
20
+ originalStructures[index] = item;
20
21
  } else {
21
- structure.push(item);
22
+ originalStructures.push(item);
22
23
  }
23
24
  }
24
25
  }
25
26
 
26
- if (input.update) {
27
- for (const upd of input.update) {
28
- const idx = structure.findIndex((i) => i.path === upd.path);
29
- if (idx !== -1) {
30
- structure[idx] = upd.item;
31
- }
32
- }
33
- }
34
-
35
- if (input.delete) {
36
- for (const del of input.delete) {
37
- const idx = structure.findIndex((i) => i.path === del.path);
38
- if (idx !== -1) {
39
- structure.splice(idx, 1);
40
- }
41
- }
42
- }
43
-
44
- options.context.userContext.originalDocumentStructure = structure.map((i, index) => {
45
- delete i.index;
46
-
47
- return {
48
- index,
49
- ...i,
50
- };
51
- });
27
+ options.context.userContext.originalDocumentStructure = originalStructures;
52
28
 
53
29
  return {};
54
30
  }
@@ -6,7 +6,7 @@ export default async function checkNeedGenerate({ docsDir, locale, documentExecu
6
6
 
7
7
  if (mainLanguageFiles.length === 0) {
8
8
  console.log(
9
- `No documents found in the docs directory. Please run ${chalk.yellow("`aigne doc generate`")} to generate the documents`,
9
+ `No documents found in the docs directory. You can generate them with ${chalk.yellow("`aigne doc generate`")}`,
10
10
  );
11
11
  process.exit(0);
12
12
  }
@@ -4,6 +4,8 @@ import chalk from "chalk";
4
4
  import { stringify as yamlStringify } from "yaml";
5
5
  import { getFilteredOptions } from "../../utils/conflict-detector.mjs";
6
6
  import {
7
+ DEFAULT_REASONING_EFFORT_LEVEL,
8
+ DEFAULT_THINKING_EFFORT_LEVEL,
7
9
  DEPTH_RECOMMENDATION_LOGIC,
8
10
  DOCUMENT_STYLES,
9
11
  DOCUMENTATION_DEPTH,
@@ -21,6 +23,8 @@ import {
21
23
  validatePath,
22
24
  } from "../../utils/utils.mjs";
23
25
  import { isRemoteFile } from "../../utils/file-utils.mjs";
26
+ import { validateDocDir } from "./validate.mjs";
27
+ import mapReasoningEffortLevel from "../utils/map-reasoning-effort-level.mjs";
24
28
 
25
29
  const _PRESS_ENTER_TO_FINISH = "Press Enter to finish";
26
30
 
@@ -31,7 +35,23 @@ const _PRESS_ENTER_TO_FINISH = "Press Enter to finish";
31
35
  * @param {string} params.fileName - The name of the file.
32
36
  * @returns {Promise<Object>}
33
37
  */
34
- export default async function init(
38
+ export default async function init(input, options) {
39
+ const config = await _init(input, options);
40
+
41
+ // Set thinking effort (lite/standard/pro) and map to reasoningEffort
42
+ options.context.userContext.thinkingEffort =
43
+ config.thinking?.effort || DEFAULT_THINKING_EFFORT_LEVEL;
44
+
45
+ // Set global reasoningEffort based on thinkingEffort
46
+ options.context.userContext.reasoningEffort = mapReasoningEffortLevel(
47
+ { level: DEFAULT_REASONING_EFFORT_LEVEL },
48
+ options,
49
+ )?.reasoningEffort;
50
+
51
+ return config;
52
+ }
53
+
54
+ async function _init(
35
55
  {
36
56
  outputPath = ".aigne/doc-smith",
37
57
  fileName = "config.yaml",
@@ -64,7 +84,19 @@ export default async function init(
64
84
  // Only skip if file exists AND has non-empty content
65
85
  if (configContent && configContent.trim() !== "") {
66
86
  // load config from file
67
- return loadConfig({ config: filePath, appUrl });
87
+ const config = await loadConfig({ config: filePath, appUrl });
88
+ const isValid = validateDocDir(config.docsDir);
89
+ if (typeof isValid === "string") {
90
+ console.log(
91
+ `${chalk.red("Invalid docsDir")}: ${isValid}\nPlease check your configuration.`,
92
+ );
93
+ process.exit(1);
94
+ }
95
+ if (!isValid) {
96
+ console.log(`${chalk.red("Invalid docsDir")}, please check your configuration.`);
97
+ process.exit(1);
98
+ }
99
+ return config;
68
100
  }
69
101
  }
70
102
 
@@ -241,6 +273,7 @@ export default async function init(
241
273
  const docsDirInput = await options.prompts.input({
242
274
  message: `📁 [7/9]: Where should we save your documentation?`,
243
275
  default: `${outputPath}/docs`,
276
+ validate: validateDocDir,
244
277
  });
245
278
  input.docsDir = docsDirInput.trim() || `${outputPath}/docs`;
246
279
 
@@ -424,6 +457,10 @@ export function generateYAML(input) {
424
457
  projectDesc: input.projectDesc || "",
425
458
  projectLogo: input.projectLogo || "",
426
459
 
460
+ thinking: {
461
+ effort: input.thinking?.effort || DEFAULT_THINKING_EFFORT_LEVEL,
462
+ },
463
+
427
464
  // Documentation configuration
428
465
  documentPurpose: input.documentPurpose || [],
429
466
  targetAudienceTypes: input.targetAudienceTypes || [],
@@ -459,6 +496,19 @@ export function generateYAML(input) {
459
496
 
460
497
  yaml += `${projectSection}\n\n`;
461
498
 
499
+ const modelSection = yamlStringify({
500
+ thinking: config.thinking,
501
+ }).trim();
502
+
503
+ yaml += `\
504
+ # AI Thinking Configuration
505
+ # thinking.effort: Determines the depth of reasoning and cognitive effort the AI uses when responding, available options:
506
+ # - lite: Fast responses with basic reasoning
507
+ # - standard: Balanced speed and reasoning capability
508
+ # - pro: In-depth reasoning with longer response times
509
+ ${modelSection}
510
+ \n`;
511
+
462
512
  // Add documentation configuration with comments
463
513
  yaml += "# =============================================================================\n";
464
514
  yaml += "# Documentation Configuration\n";
@@ -0,0 +1,16 @@
1
+ import path from "node:path";
2
+ export function validateDocDir(input) {
3
+ const currentDir = process.cwd();
4
+ const targetDir = path.resolve(input);
5
+ const relativePath = path.relative(currentDir, targetDir);
6
+ if (relativePath.length === 0) {
7
+ return `Can't use current directory: ${targetDir}`;
8
+ }
9
+ if (relativePath.startsWith("..")) {
10
+ return `Can't use directory outside current directory: ${targetDir}`;
11
+ }
12
+ if (path.isAbsolute(relativePath)) {
13
+ return `Can't use absolute path: ${targetDir}`;
14
+ }
15
+ return true;
16
+ }