@aigne/doc-smith 0.4.5 → 0.6.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/CHANGELOG.md +26 -0
- package/agents/batch-translate.yaml +3 -0
- package/agents/check-detail-result.mjs +2 -1
- package/agents/check-detail.mjs +1 -0
- package/agents/check-feedback-refiner.mjs +79 -0
- package/agents/check-structure-plan.mjs +16 -0
- package/agents/detail-generator-and-translate.yaml +3 -0
- package/agents/detail-regenerator.yaml +3 -0
- package/agents/docs-generator.yaml +3 -0
- package/agents/feedback-refiner.yaml +48 -0
- package/agents/find-items-by-paths.mjs +5 -1
- package/agents/find-user-preferences-by-path.mjs +37 -0
- package/agents/input-generator.mjs +8 -9
- package/agents/load-sources.mjs +63 -9
- package/agents/manage-prefs.mjs +203 -0
- package/agents/publish-docs.mjs +3 -1
- package/agents/retranslate.yaml +3 -0
- package/agents/structure-planning.yaml +3 -0
- package/aigne.yaml +4 -0
- package/package.json +10 -9
- package/prompts/content-detail-generator.md +13 -1
- package/prompts/document/detail-generator.md +1 -0
- package/prompts/feedback-refiner.md +84 -0
- package/prompts/structure-planning.md +8 -0
- package/prompts/translator.md +8 -0
- package/tests/{test-all-validation-cases.mjs → all-validation-cases.test.mjs} +60 -137
- package/tests/check-detail-result.test.mjs +90 -77
- package/tests/load-sources.test.mjs +103 -291
- package/tests/preferences-utils.test.mjs +369 -0
- package/tests/{test-save-docs.mjs → save-docs.test.mjs} +29 -47
- package/tests/save-value-to-config.test.mjs +165 -288
- package/utils/auth-utils.mjs +1 -1
- package/utils/constants.mjs +22 -10
- package/utils/markdown-checker.mjs +89 -9
- package/utils/preferences-utils.mjs +175 -0
- package/utils/utils.mjs +3 -3
|
@@ -1,92 +1,105 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test";
|
|
1
2
|
import checkDetailResult from "../agents/check-detail-result.mjs";
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
if (!condition) {
|
|
6
|
-
throw new Error(`Assertion failed: ${message}`);
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
async function testApproveValidContent() {
|
|
11
|
-
console.log("Testing: should approve valid content");
|
|
4
|
+
describe("checkDetailResult", () => {
|
|
5
|
+
test("should approve valid content", async () => {
|
|
12
6
|
const structurePlan = [{ path: "/getting-started" }];
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
7
|
+
const reviewContent =
|
|
8
|
+
"This is a test with a [valid link](/getting-started).\n\nThis has proper structure with multiple lines.";
|
|
9
|
+
const result = await checkDetailResult({ structurePlan, reviewContent });
|
|
10
|
+
expect(result.isApproved).toBe(true);
|
|
11
|
+
expect(result.detailFeedback).toBe("");
|
|
12
|
+
});
|
|
19
13
|
|
|
20
|
-
async
|
|
21
|
-
console.log("Testing: should reject content with a dead link");
|
|
14
|
+
test("should reject content with a dead link", async () => {
|
|
22
15
|
const structurePlan = [{ path: "/getting-started" }];
|
|
23
|
-
const
|
|
24
|
-
const result = await checkDetailResult({ structurePlan,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
16
|
+
const reviewContent = "This contains a [dead link](/dead-link).";
|
|
17
|
+
const result = await checkDetailResult({ structurePlan, reviewContent });
|
|
18
|
+
expect(result.isApproved).toBe(false);
|
|
19
|
+
expect(result.detailFeedback).toContain("Found a dead link");
|
|
20
|
+
});
|
|
29
21
|
|
|
30
|
-
async
|
|
31
|
-
console.log("Testing: should reject content with incorrect table separator");
|
|
22
|
+
test("should accept valid table format", async () => {
|
|
32
23
|
const structurePlan = [];
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
);
|
|
40
|
-
console.log("✅ Test passed: should reject content with incorrect table separator");
|
|
41
|
-
}
|
|
24
|
+
const reviewContent =
|
|
25
|
+
"| Header | Header |\n|--------|--------|\n| Cell | Cell |\n\nThis table is properly formatted.";
|
|
26
|
+
const result = await checkDetailResult({ structurePlan, reviewContent });
|
|
27
|
+
expect(result.isApproved).toBe(true);
|
|
28
|
+
expect(result.detailFeedback).toBe("");
|
|
29
|
+
});
|
|
42
30
|
|
|
43
|
-
async
|
|
44
|
-
console.log("Testing: should approve content with an external link");
|
|
31
|
+
test("should approve content with an external link", async () => {
|
|
45
32
|
const structurePlan = [];
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
33
|
+
const reviewContent =
|
|
34
|
+
"This is a [valid external link](https://example.com).\n\nThis has proper multi-line structure.";
|
|
35
|
+
const result = await checkDetailResult({ structurePlan, reviewContent });
|
|
36
|
+
expect(result.isApproved).toBe(true);
|
|
37
|
+
expect(result.detailFeedback).toBe("");
|
|
38
|
+
});
|
|
52
39
|
|
|
53
|
-
async
|
|
54
|
-
console.log("Testing: should reject content with multiple issues");
|
|
40
|
+
test("should reject content with multiple issues", async () => {
|
|
55
41
|
const structurePlan = [{ path: "/getting-started" }];
|
|
56
|
-
const
|
|
57
|
-
const result = await checkDetailResult({ structurePlan,
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
result.detailFeedback.includes("incorrect table separator"),
|
|
62
|
-
"Should report incorrect table separator",
|
|
63
|
-
);
|
|
64
|
-
console.log("✅ Test passed: should reject content with multiple issues");
|
|
65
|
-
}
|
|
42
|
+
const reviewContent = "This has a [dead link](/dead-link).";
|
|
43
|
+
const result = await checkDetailResult({ structurePlan, reviewContent });
|
|
44
|
+
expect(result.isApproved).toBe(false);
|
|
45
|
+
expect(result.detailFeedback).toContain("dead link");
|
|
46
|
+
});
|
|
66
47
|
|
|
67
|
-
async
|
|
68
|
-
console.log("Testing: should approve content with image syntax");
|
|
48
|
+
test("should approve content with external image syntax", async () => {
|
|
69
49
|
const structurePlan = [];
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
50
|
+
const reviewContent =
|
|
51
|
+
"This is an image .\n\nThis has proper structure.";
|
|
52
|
+
const result = await checkDetailResult({ structurePlan, reviewContent });
|
|
53
|
+
expect(result.isApproved).toBe(true);
|
|
54
|
+
expect(result.detailFeedback).toBe("");
|
|
55
|
+
});
|
|
76
56
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
await
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
} catch (error) {
|
|
87
|
-
console.error("❌ Test failed:", error.message);
|
|
88
|
-
process.exit(1);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
57
|
+
test("should approve content with valid local image path", async () => {
|
|
58
|
+
const structurePlan = [];
|
|
59
|
+
const reviewContent =
|
|
60
|
+
"This is a valid image .\n\nThis has proper structure.";
|
|
61
|
+
const docsDir = "/Users/lban/arcblock/code/aigne-doc-smith";
|
|
62
|
+
const result = await checkDetailResult({ structurePlan, reviewContent, docsDir });
|
|
63
|
+
expect(result.isApproved).toBe(true);
|
|
64
|
+
expect(result.detailFeedback).toBe("");
|
|
65
|
+
});
|
|
91
66
|
|
|
92
|
-
|
|
67
|
+
test("should reject content with invalid local image path", async () => {
|
|
68
|
+
const structurePlan = [];
|
|
69
|
+
const reviewContent =
|
|
70
|
+
"This is an invalid image .\n\nThis has proper structure.";
|
|
71
|
+
const docsDir = "/Users/lban/arcblock/code/aigne-doc-smith";
|
|
72
|
+
const result = await checkDetailResult({ structurePlan, reviewContent, docsDir });
|
|
73
|
+
expect(result.isApproved).toBe(false);
|
|
74
|
+
expect(result.detailFeedback).toContain("Found invalid local image");
|
|
75
|
+
expect(result.detailFeedback).toContain("only valid media resources can be used");
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
test("should approve content with absolute image path that exists", async () => {
|
|
79
|
+
const structurePlan = [];
|
|
80
|
+
const reviewContent =
|
|
81
|
+
"This is an absolute image .\n\nThis has proper structure.";
|
|
82
|
+
const result = await checkDetailResult({ structurePlan, reviewContent });
|
|
83
|
+
expect(result.isApproved).toBe(true);
|
|
84
|
+
expect(result.detailFeedback).toBe("");
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
test("should reject content with absolute image path that doesn't exist", async () => {
|
|
88
|
+
const structurePlan = [];
|
|
89
|
+
const reviewContent =
|
|
90
|
+
"This is an invalid absolute image .\n\nThis has proper structure.";
|
|
91
|
+
const result = await checkDetailResult({ structurePlan, reviewContent });
|
|
92
|
+
expect(result.isApproved).toBe(false);
|
|
93
|
+
expect(result.detailFeedback).toContain("Found invalid local image");
|
|
94
|
+
expect(result.detailFeedback).toContain("only valid media resources can be used");
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
test("should approve content with external image URL", async () => {
|
|
98
|
+
const structurePlan = [];
|
|
99
|
+
const reviewContent =
|
|
100
|
+
"This is an external image .\n\nThis has proper structure.";
|
|
101
|
+
const result = await checkDetailResult({ structurePlan, reviewContent });
|
|
102
|
+
expect(result.isApproved).toBe(true);
|
|
103
|
+
expect(result.detailFeedback).toBe("");
|
|
104
|
+
});
|
|
105
|
+
});
|