@aigne/doc-smith 0.7.2 → 0.8.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.
- package/.github/workflows/ci.yml +3 -0
- package/CHANGELOG.md +20 -0
- package/README.md +5 -0
- package/agents/check-detail-result.mjs +7 -0
- 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 +9 -1
- package/package.json +1 -1
- package/prompts/document/custom-components.md +36 -12
- package/prompts/document/d2-chart/rules.md +955 -46
- package/prompts/document/d2-chart/shape-rules.md +182 -0
- package/prompts/document/detail-generator.md +1 -1
- 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/constants.mjs +3 -23
- 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
|
@@ -2,10 +2,128 @@ import { describe, expect, test } from "bun:test";
|
|
|
2
2
|
import {
|
|
3
3
|
detectResolvableConflicts,
|
|
4
4
|
generateConflictResolutionRules,
|
|
5
|
+
getFilteredOptions,
|
|
5
6
|
} from "../utils/conflict-detector.mjs";
|
|
6
7
|
import { processConfigFields } from "../utils/utils.mjs";
|
|
7
8
|
|
|
8
9
|
describe("conflict resolution", () => {
|
|
10
|
+
describe("getFilteredOptions", () => {
|
|
11
|
+
test("should filter experiencedUsers when documentPurpose is getStarted", () => {
|
|
12
|
+
const allOptions = {
|
|
13
|
+
completeBeginners: "Complete beginners",
|
|
14
|
+
domainFamiliar: "Domain familiar",
|
|
15
|
+
experiencedUsers: "Experienced users",
|
|
16
|
+
emergencyTroubleshooting: "Emergency troubleshooting",
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const currentSelections = {
|
|
20
|
+
documentPurpose: ["getStarted"],
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const result = getFilteredOptions("readerKnowledgeLevel", currentSelections, allOptions);
|
|
24
|
+
|
|
25
|
+
expect(result.filteredOptions).not.toHaveProperty("experiencedUsers");
|
|
26
|
+
expect(result.appliedFilters).toHaveLength(1);
|
|
27
|
+
expect(result.appliedFilters[0].removedOption).toBe("experiencedUsers");
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
test("should filter completeBeginners when documentPurpose is findAnswers", () => {
|
|
31
|
+
const allOptions = {
|
|
32
|
+
completeBeginners: "Complete beginners",
|
|
33
|
+
domainFamiliar: "Domain familiar",
|
|
34
|
+
experiencedUsers: "Experienced users",
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const currentSelections = {
|
|
38
|
+
documentPurpose: ["findAnswers"],
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const result = getFilteredOptions("readerKnowledgeLevel", currentSelections, allOptions);
|
|
42
|
+
|
|
43
|
+
expect(result.filteredOptions).not.toHaveProperty("completeBeginners");
|
|
44
|
+
expect(result.appliedFilters).toHaveLength(1);
|
|
45
|
+
expect(result.appliedFilters[0].removedOption).toBe("completeBeginners");
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
test("should filter emergencyTroubleshooting when documentPurpose is understandSystem", () => {
|
|
49
|
+
const allOptions = {
|
|
50
|
+
completeBeginners: "Complete beginners",
|
|
51
|
+
emergencyTroubleshooting: "Emergency troubleshooting",
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const currentSelections = {
|
|
55
|
+
documentPurpose: ["understandSystem"],
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const result = getFilteredOptions("readerKnowledgeLevel", currentSelections, allOptions);
|
|
59
|
+
|
|
60
|
+
expect(result.filteredOptions).not.toHaveProperty("emergencyTroubleshooting");
|
|
61
|
+
expect(result.appliedFilters).toHaveLength(1);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
test("should filter experiencedUsers when targetAudienceTypes includes endUsers", () => {
|
|
65
|
+
const allOptions = {
|
|
66
|
+
completeBeginners: "Complete beginners",
|
|
67
|
+
experiencedUsers: "Experienced users",
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const currentSelections = {
|
|
71
|
+
targetAudienceTypes: ["endUsers"],
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const result = getFilteredOptions("readerKnowledgeLevel", currentSelections, allOptions);
|
|
75
|
+
|
|
76
|
+
expect(result.filteredOptions).not.toHaveProperty("experiencedUsers");
|
|
77
|
+
expect(result.appliedFilters).toHaveLength(1);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
test("should return original options when no conflicts", () => {
|
|
81
|
+
const allOptions = {
|
|
82
|
+
option1: "Option 1",
|
|
83
|
+
option2: "Option 2",
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const currentSelections = {};
|
|
87
|
+
|
|
88
|
+
const result = getFilteredOptions("unknownType", currentSelections, allOptions);
|
|
89
|
+
|
|
90
|
+
expect(result.filteredOptions).toEqual(allOptions);
|
|
91
|
+
expect(result.appliedFilters).toHaveLength(0);
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
test("should handle object selections with value property", () => {
|
|
95
|
+
const allOptions = {
|
|
96
|
+
experiencedUsers: "Experienced users",
|
|
97
|
+
domainFamiliar: "Domain familiar",
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
const currentSelections = {
|
|
101
|
+
documentPurpose: [{ value: "getStarted", label: "Get Started" }],
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
const result = getFilteredOptions("readerKnowledgeLevel", currentSelections, allOptions);
|
|
105
|
+
|
|
106
|
+
expect(result.filteredOptions).not.toHaveProperty("experiencedUsers");
|
|
107
|
+
expect(result.appliedFilters).toHaveLength(1);
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
test("should handle multiple conditions in cross-conflict rules", () => {
|
|
111
|
+
const allOptions = {
|
|
112
|
+
emergencyTroubleshooting: "Emergency troubleshooting",
|
|
113
|
+
domainFamiliar: "Domain familiar",
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
const currentSelections = {
|
|
117
|
+
targetAudienceTypes: ["decisionMakers"],
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
const result = getFilteredOptions("readerKnowledgeLevel", currentSelections, allOptions);
|
|
121
|
+
|
|
122
|
+
expect(result.filteredOptions).not.toHaveProperty("emergencyTroubleshooting");
|
|
123
|
+
expect(result.appliedFilters).toHaveLength(1);
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
|
|
9
127
|
describe("detectResolvableConflicts", () => {
|
|
10
128
|
test("should detect document purpose conflicts", () => {
|
|
11
129
|
const config = {
|