@aigne/doc-smith 0.7.1 → 0.8.0
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/.github/workflows/ci.yml +9 -1
- package/CHANGELOG.md +15 -0
- package/README.md +5 -0
- package/agents/check-detail-result.mjs +7 -0
- package/agents/check-detail.mjs +3 -1
- package/agents/detail-regenerator.yaml +3 -0
- package/agents/find-items-by-paths.mjs +9 -1
- package/agents/input-generator.mjs +3 -3
- package/agents/load-sources.mjs +2 -1
- package/agents/save-docs.mjs +1 -5
- package/codecov.yml +15 -0
- package/package.json +1 -1
- package/prompts/content-detail-generator.md +1 -0
- package/prompts/document/custom-components.md +36 -12
- package/tests/check-detail-result.test.mjs +656 -17
- package/tests/conflict-resolution.test.mjs +118 -0
- package/tests/input-generator.test.mjs +594 -1
- package/tests/kroki-utils.test.mjs +588 -0
- package/tests/load-sources.test.mjs +362 -2
- package/tests/mermaid-validation.test.mjs +541 -0
- package/tests/save-docs.test.mjs +1 -1
- package/tests/utils.test.mjs +2020 -2
- package/utils/conflict-detector.mjs +0 -59
- package/utils/file-utils.mjs +5 -0
- package/utils/kroki-utils.mjs +4 -0
- package/utils/markdown-checker.mjs +3 -3
- package/utils/mermaid-validator.mjs +0 -13
- package/utils/utils.mjs +11 -5
- package/tests/all-validation-cases.test.mjs +0 -686
package/.github/workflows/ci.yml
CHANGED
|
@@ -4,6 +4,9 @@ env:
|
|
|
4
4
|
NODE_OPTIONS: "--max_old_space_size=6144"
|
|
5
5
|
|
|
6
6
|
on:
|
|
7
|
+
push:
|
|
8
|
+
branches:
|
|
9
|
+
- main
|
|
7
10
|
pull_request:
|
|
8
11
|
branches:
|
|
9
12
|
- main
|
|
@@ -43,4 +46,9 @@ jobs:
|
|
|
43
46
|
run: pnpm lint
|
|
44
47
|
|
|
45
48
|
- name: Test
|
|
46
|
-
run: pnpm test:coverage
|
|
49
|
+
run: pnpm test:coverage
|
|
50
|
+
|
|
51
|
+
- name: Upload coverage reports to Codecov
|
|
52
|
+
uses: codecov/codecov-action@v5
|
|
53
|
+
with:
|
|
54
|
+
token: ${{ secrets.CODECOV_TOKEN }}
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.8.0](https://github.com/AIGNE-io/aigne-doc-smith/compare/v0.7.2...v0.8.0) (2025-09-03)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* **tests:** add comprehensive workflow test coverage ([#76](https://github.com/AIGNE-io/aigne-doc-smith/issues/76)) ([d5f6062](https://github.com/AIGNE-io/aigne-doc-smith/commit/d5f6062311f36dc5b6394ae0768583fb8f3853a4))
|
|
9
|
+
* update custom component guidelines with formatting restrictions ([#79](https://github.com/AIGNE-io/aigne-doc-smith/issues/79)) ([76158de](https://github.com/AIGNE-io/aigne-doc-smith/commit/76158de236696e68c63c057f5ea4b8458a15e787))
|
|
10
|
+
|
|
11
|
+
## [0.7.2](https://github.com/AIGNE-io/aigne-doc-smith/compare/v0.7.1...v0.7.2) (2025-09-01)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Miscellaneous Chores
|
|
15
|
+
|
|
16
|
+
* release 0.7.2 ([c3be232](https://github.com/AIGNE-io/aigne-doc-smith/commit/c3be2323e885cf5d11d654629fe30cc3720f79d3))
|
|
17
|
+
|
|
3
18
|
## [0.7.1](https://github.com/AIGNE-io/aigne-doc-smith/compare/v0.7.0...v0.7.1) (2025-08-31)
|
|
4
19
|
|
|
5
20
|
|
package/README.md
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
[](https://star-history.com/#AIGNE-io/aigne-doc-smith)
|
|
2
|
+
[](https://github.com/AIGNE-io/aigne-doc-smith/issues)
|
|
3
|
+
[](https://codecov.io/gh/AIGNE-io/aigne-doc-smith)
|
|
4
|
+
[](https://www.npmjs.com/package/@aigne/doc-smith)
|
|
5
|
+
|
|
1
6
|
# AIGNE DocSmith
|
|
2
7
|
|
|
3
8
|
AIGNE DocSmith is a powerful, AI-driven documentation generation tool built on the [AIGNE Framework](https://www.aigne.io/en/framework). It automates the creation of detailed, structured, and multi-language documentation directly from your source code.
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { checkMarkdown } from "../utils/markdown-checker.mjs";
|
|
2
2
|
|
|
3
3
|
export default async function checkDetailResult({ structurePlan, reviewContent, docsDir }) {
|
|
4
|
+
if (!reviewContent || reviewContent.trim() === "") {
|
|
5
|
+
return {
|
|
6
|
+
isApproved: false,
|
|
7
|
+
detailFeedback: "Review content is empty",
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
|
|
4
11
|
let isApproved = true;
|
|
5
12
|
const detailFeedback = [];
|
|
6
13
|
|
package/agents/check-detail.mjs
CHANGED
|
@@ -81,8 +81,9 @@ export default async function checkDetail(
|
|
|
81
81
|
|
|
82
82
|
// If file exists, check content validation
|
|
83
83
|
let contentValidationFailed = false;
|
|
84
|
+
let validationResult = {};
|
|
84
85
|
if (detailGenerated && fileContent && structurePlan) {
|
|
85
|
-
|
|
86
|
+
validationResult = await checkDetailResult({
|
|
86
87
|
structurePlan,
|
|
87
88
|
reviewContent: fileContent,
|
|
88
89
|
docsDir,
|
|
@@ -121,6 +122,7 @@ export default async function checkDetail(
|
|
|
121
122
|
sourceIds,
|
|
122
123
|
originalStructurePlan,
|
|
123
124
|
structurePlan,
|
|
125
|
+
detailFeedback: contentValidationFailed ? validationResult.detailFeedback : "",
|
|
124
126
|
});
|
|
125
127
|
|
|
126
128
|
return {
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from "../utils/docs-finder-utils.mjs";
|
|
8
8
|
|
|
9
9
|
export default async function selectedDocs(
|
|
10
|
-
{ docs, structurePlanResult, boardId, docsDir, isTranslate, feedback, locale },
|
|
10
|
+
{ docs, structurePlanResult, boardId, docsDir, isTranslate, feedback, locale, reset = false },
|
|
11
11
|
options,
|
|
12
12
|
) {
|
|
13
13
|
let foundItems = [];
|
|
@@ -101,6 +101,14 @@ export default async function selectedDocs(
|
|
|
101
101
|
// Add feedback to all results if provided
|
|
102
102
|
foundItems = addFeedbackToItems(foundItems, userFeedback);
|
|
103
103
|
|
|
104
|
+
// if reset is true, set content to null for all items
|
|
105
|
+
if (reset) {
|
|
106
|
+
foundItems = foundItems.map((item) => ({
|
|
107
|
+
...item,
|
|
108
|
+
content: null,
|
|
109
|
+
}));
|
|
110
|
+
}
|
|
111
|
+
|
|
104
112
|
return {
|
|
105
113
|
selectedDocs: foundItems,
|
|
106
114
|
feedback: userFeedback,
|
|
@@ -2,7 +2,7 @@ import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
|
2
2
|
import { dirname, join } from "node:path";
|
|
3
3
|
import chalk from "chalk";
|
|
4
4
|
import { stringify as yamlStringify } from "yaml";
|
|
5
|
-
import { getFilteredOptions
|
|
5
|
+
import { getFilteredOptions } from "../utils/conflict-detector.mjs";
|
|
6
6
|
import {
|
|
7
7
|
DEPTH_RECOMMENDATION_LOGIC,
|
|
8
8
|
DOCUMENT_STYLES,
|
|
@@ -63,7 +63,7 @@ export default async function init(
|
|
|
63
63
|
if (input.length === 0) {
|
|
64
64
|
return "Please select at least one purpose.";
|
|
65
65
|
}
|
|
66
|
-
return
|
|
66
|
+
return true;
|
|
67
67
|
},
|
|
68
68
|
});
|
|
69
69
|
|
|
@@ -111,7 +111,7 @@ export default async function init(
|
|
|
111
111
|
if (input.length === 0) {
|
|
112
112
|
return "Please select at least one audience.";
|
|
113
113
|
}
|
|
114
|
-
return
|
|
114
|
+
return true;
|
|
115
115
|
},
|
|
116
116
|
});
|
|
117
117
|
|
package/agents/load-sources.mjs
CHANGED
|
@@ -19,6 +19,7 @@ export default async function loadSources({
|
|
|
19
19
|
boardId,
|
|
20
20
|
useDefaultPatterns = true,
|
|
21
21
|
lastGitHead,
|
|
22
|
+
reset = false,
|
|
22
23
|
} = {}) {
|
|
23
24
|
let files = Array.isArray(sources) ? [...sources] : [];
|
|
24
25
|
|
|
@@ -190,7 +191,7 @@ export default async function loadSources({
|
|
|
190
191
|
|
|
191
192
|
// Get the last output result of the specified path
|
|
192
193
|
let content;
|
|
193
|
-
if (docPath) {
|
|
194
|
+
if (docPath && !reset) {
|
|
194
195
|
let fileFullName;
|
|
195
196
|
|
|
196
197
|
// First try direct path matching (original format)
|
package/agents/save-docs.mjs
CHANGED
|
@@ -149,11 +149,7 @@ async function cleanupInvalidFiles(structurePlan, docsDir, translateLanguages, l
|
|
|
149
149
|
message: `Deleted invalid file: ${file}`,
|
|
150
150
|
});
|
|
151
151
|
} catch (err) {
|
|
152
|
-
|
|
153
|
-
path: file,
|
|
154
|
-
success: false,
|
|
155
|
-
error: `Failed to delete ${file}: ${err.message}`,
|
|
156
|
-
});
|
|
152
|
+
console.warn(`Failed to delete invalid file: ${file}, error: ${err.message}`);
|
|
157
153
|
}
|
|
158
154
|
}
|
|
159
155
|
|
package/codecov.yml
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
coverage:
|
|
2
|
+
status:
|
|
3
|
+
project: #add everything under here, more options at https://docs.codecov.com/docs/commit-status
|
|
4
|
+
default:
|
|
5
|
+
# basic
|
|
6
|
+
target: auto #default
|
|
7
|
+
threshold: 0%
|
|
8
|
+
base: auto
|
|
9
|
+
comment:
|
|
10
|
+
layout: "header, changes, diff, flags, files"
|
|
11
|
+
behavior: default
|
|
12
|
+
require_changes: false
|
|
13
|
+
require_base: false
|
|
14
|
+
require_head: true
|
|
15
|
+
hide_project_coverage: false
|
package/package.json
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
<custom_component>
|
|
1
2
|
When generating document details, you can use the following custom components at appropriate locations based on their descriptions and functionality to enhance document presentation:
|
|
2
3
|
- `<x-card>`
|
|
3
4
|
- `<x-cards>`
|
|
@@ -24,7 +25,11 @@ Attribute Rules:
|
|
|
24
25
|
- data-href (optional): Navigation link for clicking the card or button.
|
|
25
26
|
- data-horizontal (optional): Whether to use horizontal layout.
|
|
26
27
|
- data-cta (optional): Button text (call to action).
|
|
27
|
-
- Body content:
|
|
28
|
+
- Body content:
|
|
29
|
+
- Must be written within <x-card>...</x-card> children.
|
|
30
|
+
- **Markdown format rendering is not supported**
|
|
31
|
+
- **Code block rendering is not supported**
|
|
32
|
+
- Only supports plain text format without styling
|
|
28
33
|
|
|
29
34
|
|
|
30
35
|
### 2. `<x-cards>` Card List Component
|
|
@@ -49,32 +54,51 @@ Attribute Rules:
|
|
|
49
54
|
- Or all cards should have data-image.
|
|
50
55
|
- Avoid mixing (some with icons, some with only images).
|
|
51
56
|
|
|
52
|
-
|
|
53
|
-
|
|
57
|
+
<good_example>
|
|
58
|
+
Use plain text without any styling
|
|
59
|
+
<x-card data-title="alarm()" data-icon="lucide:alarm-clock"> SIGALRM: Sent when a real-time timer has expired. </x-card>
|
|
54
60
|
|
|
55
61
|
Single card:
|
|
56
|
-
|
|
57
|
-
```
|
|
58
62
|
<x-card data-title="Horizontal card" data-icon="lucide:atom" data-horizontal="true">
|
|
59
63
|
This is an example of a horizontal card.
|
|
60
64
|
</x-card>
|
|
61
|
-
```
|
|
62
65
|
|
|
63
66
|
Card list (all using icons, recommended approach):
|
|
64
|
-
|
|
65
|
-
```
|
|
66
67
|
<x-cards data-columns="3">
|
|
67
68
|
<x-card data-title="Feature 1" data-icon="lucide:rocket">Description of Feature 1.</x-card>
|
|
68
69
|
<x-card data-title="Feature 2" data-icon="lucide:bolt">Description of Feature 2.</x-card>
|
|
69
70
|
<x-card data-title="Feature 3" data-icon="material-symbols:rocket-outline">Description of Feature 3.</x-card>
|
|
70
71
|
</x-cards>
|
|
71
|
-
```
|
|
72
72
|
|
|
73
73
|
Card list (all using images):
|
|
74
|
-
|
|
75
|
-
```
|
|
76
74
|
<x-cards data-columns="2">
|
|
77
75
|
<x-card data-title="Card A" data-image="https://picsum.photos/id/10/300/300">Content A</x-card>
|
|
78
76
|
<x-card data-title="Card B" data-image="https://picsum.photos/id/11/300/300">Content B</x-card>
|
|
79
77
|
</x-cards>
|
|
80
|
-
|
|
78
|
+
</good_example>
|
|
79
|
+
|
|
80
|
+
<bad_example>
|
|
81
|
+
|
|
82
|
+
`x-card` component body does not support markdown formatting inline code block
|
|
83
|
+
<x-card data-title="alarm()" data-icon="lucide:alarm-clock"> `SIGALRM`: Sent when a real-time timer has expired. </x-card>
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
`x-card` component body does not support code blocks
|
|
87
|
+
<x-card data-title="ctrl_break()" data-icon="lucide:keyboard">
|
|
88
|
+
Creates a listener for "ctrl-break" events.
|
|
89
|
+
```rust,no_run
|
|
90
|
+
use tokio::signal::windows::ctrl_break;
|
|
91
|
+
|
|
92
|
+
#[tokio::main]
|
|
93
|
+
async fn main() -> std::io::Result<()> {
|
|
94
|
+
let mut stream = ctrl_break()?;
|
|
95
|
+
stream.recv().await;
|
|
96
|
+
println!("got ctrl-break");
|
|
97
|
+
Ok(())
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
</x-card>
|
|
101
|
+
|
|
102
|
+
</bad_example>
|
|
103
|
+
|
|
104
|
+
</custom_component>
|