@aigne/doc-smith 0.9.8-alpha.3 → 0.9.8-alpha.5
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/CLAUDE.md +43 -0
- package/README.md +94 -250
- package/aigne.yaml +5 -146
- package/doc-smith/SKILL.md +117 -0
- package/doc-smith/references/changeset_schema.md +118 -0
- package/doc-smith/references/document_structure_schema.md +139 -0
- package/doc-smith/references/document_update_guide.md +193 -0
- package/doc-smith/references/structure_confirmation_guide.md +133 -0
- package/doc-smith/references/structure_planning_guide.md +146 -0
- package/doc-smith/references/user_intent_guide.md +172 -0
- package/doc-smith.yaml +114 -0
- package/main-system-prompt.md +56 -0
- package/package.json +3 -69
- package/scripts/README.md +90 -0
- package/scripts/install.sh +86 -0
- package/scripts/uninstall.sh +52 -0
- package/CHANGELOG.md +0 -994
- package/LICENSE +0 -93
- package/agentic-agents/common/base-info.md +0 -53
- package/agentic-agents/common/completer.md +0 -54
- package/agentic-agents/common/planner.md +0 -168
- package/agentic-agents/common/worker.md +0 -93
- package/agentic-agents/create/index.yaml +0 -129
- package/agentic-agents/create/objective.md +0 -44
- package/agentic-agents/create/set-custom-prompt.mjs +0 -27
- package/agentic-agents/detail/index.yaml +0 -95
- package/agentic-agents/detail/objective.md +0 -9
- package/agentic-agents/detail/set-custom-prompt.mjs +0 -88
- package/agentic-agents/predict-resources/index.yaml +0 -44
- package/agentic-agents/predict-resources/instructions.md +0 -61
- package/agentic-agents/structure/design-rules.md +0 -39
- package/agentic-agents/structure/index.yaml +0 -86
- package/agentic-agents/structure/objective.md +0 -14
- package/agentic-agents/structure/review-criteria.md +0 -55
- package/agentic-agents/structure/set-custom-prompt.mjs +0 -78
- package/agentic-agents/utils/init-workspace-cache.mjs +0 -171
- package/agentic-agents/utils/load-base-sources.mjs +0 -20
- package/agentic-agents/workspace-cache-sharing-design.md +0 -671
- package/agents/chat/chat-system.md +0 -38
- package/agents/chat/index.mjs +0 -59
- package/agents/chat/skills/generate-document.yaml +0 -15
- package/agents/chat/skills/list-documents.mjs +0 -15
- package/agents/chat/skills/update-document.yaml +0 -24
- package/agents/clear/choose-contents.mjs +0 -192
- package/agents/clear/clear-auth-tokens.mjs +0 -88
- package/agents/clear/clear-deployment-config.mjs +0 -49
- package/agents/clear/clear-document-config.mjs +0 -36
- package/agents/clear/clear-document-structure.mjs +0 -102
- package/agents/clear/clear-generated-docs.mjs +0 -142
- package/agents/clear/clear-media-description.mjs +0 -129
- package/agents/clear/index.yaml +0 -26
- package/agents/create/analyze-diagram-type-llm.yaml +0 -160
- package/agents/create/analyze-diagram-type.mjs +0 -297
- package/agents/create/check-document-structure.yaml +0 -30
- package/agents/create/check-need-generate-structure.mjs +0 -105
- package/agents/create/document-structure-tools/add-document.mjs +0 -85
- package/agents/create/document-structure-tools/delete-document.mjs +0 -116
- package/agents/create/document-structure-tools/move-document.mjs +0 -109
- package/agents/create/document-structure-tools/update-document.mjs +0 -84
- package/agents/create/generate-diagram-image.yaml +0 -60
- package/agents/create/generate-structure.yaml +0 -117
- package/agents/create/index.yaml +0 -49
- package/agents/create/refine-document-structure.yaml +0 -12
- package/agents/create/replace-d2-with-image.mjs +0 -625
- package/agents/create/update-document-structure.yaml +0 -54
- package/agents/create/user-add-document/add-documents-to-structure.mjs +0 -90
- package/agents/create/user-add-document/find-documents-to-add-links.yaml +0 -47
- package/agents/create/user-add-document/index.yaml +0 -46
- package/agents/create/user-add-document/prepare-documents-to-translate.mjs +0 -22
- package/agents/create/user-add-document/print-add-document-summary.mjs +0 -63
- package/agents/create/user-add-document/review-documents-with-new-links.mjs +0 -110
- package/agents/create/user-remove-document/find-documents-with-invalid-links.mjs +0 -78
- package/agents/create/user-remove-document/index.yaml +0 -40
- package/agents/create/user-remove-document/prepare-documents-to-translate.mjs +0 -22
- package/agents/create/user-remove-document/print-remove-document-summary.mjs +0 -53
- package/agents/create/user-remove-document/remove-documents-from-structure.mjs +0 -99
- package/agents/create/user-remove-document/review-documents-with-invalid-links.mjs +0 -115
- package/agents/create/user-review-document-structure.mjs +0 -140
- package/agents/create/utils/init-current-content.mjs +0 -34
- package/agents/create/utils/merge-document-structures.mjs +0 -30
- package/agents/evaluate/code-snippet.mjs +0 -97
- package/agents/evaluate/document-structure.yaml +0 -67
- package/agents/evaluate/document.yaml +0 -82
- package/agents/evaluate/generate-report.mjs +0 -85
- package/agents/evaluate/index.yaml +0 -46
- package/agents/history/index.yaml +0 -6
- package/agents/history/view.mjs +0 -78
- package/agents/init/check.mjs +0 -16
- package/agents/init/index.mjs +0 -275
- package/agents/init/validate.mjs +0 -16
- package/agents/localize/choose-language.mjs +0 -107
- package/agents/localize/index.yaml +0 -58
- package/agents/localize/record-translation-history.mjs +0 -23
- package/agents/localize/translate-document.yaml +0 -24
- package/agents/localize/translate-multilingual.yaml +0 -51
- package/agents/media/batch-generate-media-description.yaml +0 -46
- package/agents/media/generate-media-description.yaml +0 -50
- package/agents/media/load-media-description.mjs +0 -256
- package/agents/prefs/index.mjs +0 -203
- package/agents/publish/index.yaml +0 -26
- package/agents/publish/publish-docs.mjs +0 -356
- package/agents/publish/translate-meta.mjs +0 -103
- package/agents/schema/document-structure-item.yaml +0 -26
- package/agents/schema/document-structure-refine-item.yaml +0 -23
- package/agents/schema/document-structure.yaml +0 -29
- package/agents/update/batch-generate-document.yaml +0 -27
- package/agents/update/batch-update-document.yaml +0 -7
- package/agents/update/check-diagram-flag.mjs +0 -116
- package/agents/update/check-document.mjs +0 -162
- package/agents/update/check-generate-diagram.mjs +0 -106
- package/agents/update/check-sync-image-flag.mjs +0 -55
- package/agents/update/check-update-is-single.mjs +0 -53
- package/agents/update/document-tools/update-document-content.mjs +0 -303
- package/agents/update/generate-diagram.yaml +0 -63
- package/agents/update/generate-document.yaml +0 -70
- package/agents/update/handle-document-update.yaml +0 -103
- package/agents/update/index.yaml +0 -79
- package/agents/update/pre-check-generate-diagram.yaml +0 -44
- package/agents/update/save-and-translate-document.mjs +0 -76
- package/agents/update/sync-images-and-exit.mjs +0 -148
- package/agents/update/update-document-detail.yaml +0 -71
- package/agents/update/update-single/update-single-document-detail.mjs +0 -280
- package/agents/update/update-single-document.yaml +0 -7
- package/agents/update/user-review-document.mjs +0 -272
- package/agents/utils/action-success.mjs +0 -16
- package/agents/utils/analyze-document-feedback-intent.yaml +0 -32
- package/agents/utils/analyze-feedback-intent.mjs +0 -136
- package/agents/utils/analyze-structure-feedback-intent.yaml +0 -29
- package/agents/utils/check-detail-result.mjs +0 -38
- package/agents/utils/check-feedback-refiner.mjs +0 -81
- package/agents/utils/choose-docs.mjs +0 -293
- package/agents/utils/document-icon-generate.yaml +0 -52
- package/agents/utils/document-title-streamline.yaml +0 -48
- package/agents/utils/ensure-document-icons.mjs +0 -129
- package/agents/utils/exit.mjs +0 -6
- package/agents/utils/feedback-refiner.yaml +0 -50
- package/agents/utils/find-item-by-path.mjs +0 -114
- package/agents/utils/find-user-preferences-by-path.mjs +0 -37
- package/agents/utils/format-document-structure.mjs +0 -35
- package/agents/utils/generate-document-or-skip.mjs +0 -41
- package/agents/utils/handle-diagram-operations.mjs +0 -263
- package/agents/utils/load-all-document-content.mjs +0 -30
- package/agents/utils/load-document-all-content.mjs +0 -84
- package/agents/utils/load-sources.mjs +0 -405
- package/agents/utils/map-reasoning-effort-level.mjs +0 -15
- package/agents/utils/post-generate.mjs +0 -144
- package/agents/utils/read-current-document-content.mjs +0 -46
- package/agents/utils/save-doc-translation.mjs +0 -61
- package/agents/utils/save-doc.mjs +0 -88
- package/agents/utils/save-output.mjs +0 -26
- package/agents/utils/save-sidebar.mjs +0 -51
- package/agents/utils/skip-if-content-exists.mjs +0 -27
- package/agents/utils/streamline-document-titles-if-needed.mjs +0 -88
- package/agents/utils/transform-detail-data-sources.mjs +0 -45
- package/agents/utils/update-branding.mjs +0 -84
- package/assets/report-template/report.html +0 -198
- package/docs-mcp/analyze-content-relevance.yaml +0 -50
- package/docs-mcp/analyze-docs-relevance.yaml +0 -59
- package/docs-mcp/docs-search.yaml +0 -42
- package/docs-mcp/get-docs-detail.mjs +0 -41
- package/docs-mcp/get-docs-structure.mjs +0 -16
- package/docs-mcp/read-doc-content.mjs +0 -119
- package/prompts/common/document/content-rules-core.md +0 -20
- package/prompts/common/document/markdown-syntax-rules.md +0 -65
- package/prompts/common/document/media-file-list-usage-rules.md +0 -18
- package/prompts/common/document/openapi-usage-rules.md +0 -189
- package/prompts/common/document/role-and-personality.md +0 -16
- package/prompts/common/document/user-preferences.md +0 -9
- package/prompts/common/document-structure/conflict-resolution-guidance.md +0 -16
- package/prompts/common/document-structure/document-icon-generate.md +0 -116
- package/prompts/common/document-structure/document-structure-rules.md +0 -43
- package/prompts/common/document-structure/document-title-streamline.md +0 -86
- package/prompts/common/document-structure/glossary.md +0 -7
- package/prompts/common/document-structure/intj-traits.md +0 -5
- package/prompts/common/document-structure/openapi-usage-rules.md +0 -28
- package/prompts/common/document-structure/output-constraints.md +0 -18
- package/prompts/common/document-structure/user-locale-rules.md +0 -10
- package/prompts/common/document-structure/user-preferences.md +0 -9
- package/prompts/detail/custom/admonition-usage-rules.md +0 -94
- package/prompts/detail/custom/code-block-usage-rules.md +0 -163
- package/prompts/detail/custom/custom-components/x-card-usage-rules.md +0 -63
- package/prompts/detail/custom/custom-components/x-cards-usage-rules.md +0 -83
- package/prompts/detail/custom/custom-components/x-field-desc-usage-rules.md +0 -120
- package/prompts/detail/custom/custom-components/x-field-group-usage-rules.md +0 -80
- package/prompts/detail/custom/custom-components/x-field-usage-rules.md +0 -189
- package/prompts/detail/custom/custom-components-usage-rules.md +0 -18
- package/prompts/detail/diagram/generate-image-system.md +0 -135
- package/prompts/detail/diagram/generate-image-user.md +0 -32
- package/prompts/detail/diagram/guide.md +0 -29
- package/prompts/detail/diagram/official-examples.md +0 -712
- package/prompts/detail/diagram/pre-check.md +0 -23
- package/prompts/detail/diagram/role-and-personality.md +0 -2
- package/prompts/detail/diagram/rules.md +0 -46
- package/prompts/detail/diagram/system-prompt.md +0 -1139
- package/prompts/detail/diagram/user-prompt.md +0 -43
- package/prompts/detail/generate/detail-example.md +0 -457
- package/prompts/detail/generate/document-rules.md +0 -45
- package/prompts/detail/generate/system-prompt.md +0 -61
- package/prompts/detail/generate/user-prompt.md +0 -99
- package/prompts/detail/jsx/rules.md +0 -6
- package/prompts/detail/update/system-prompt.md +0 -121
- package/prompts/detail/update/user-prompt.md +0 -41
- package/prompts/evaluate/document-structure.md +0 -93
- package/prompts/evaluate/document.md +0 -149
- package/prompts/media/media-description/system-prompt.md +0 -43
- package/prompts/media/media-description/user-prompt.md +0 -17
- package/prompts/structure/check-document-structure.md +0 -93
- package/prompts/structure/document-rules.md +0 -21
- package/prompts/structure/find-documents-to-add-links.md +0 -52
- package/prompts/structure/generate/system-prompt.md +0 -13
- package/prompts/structure/generate/user-prompt.md +0 -137
- package/prompts/structure/review/structure-review-system.md +0 -81
- package/prompts/structure/structure-example.md +0 -89
- package/prompts/structure/structure-getting-started.md +0 -10
- package/prompts/structure/update/system-prompt.md +0 -93
- package/prompts/structure/update/user-prompt.md +0 -43
- package/prompts/translate/admonition.md +0 -20
- package/prompts/translate/code-block.md +0 -33
- package/prompts/translate/glossary.md +0 -6
- package/prompts/translate/translate-document.md +0 -305
- package/prompts/utils/analyze-document-feedback-intent.md +0 -54
- package/prompts/utils/analyze-structure-feedback-intent.md +0 -43
- package/prompts/utils/feedback-refiner.md +0 -105
- package/types/document-schema.mjs +0 -55
- package/types/document-structure-schema.mjs +0 -261
- package/utils/auth-utils.mjs +0 -275
- package/utils/blocklet.mjs +0 -104
- package/utils/check-document-has-diagram.mjs +0 -95
- package/utils/conflict-detector.mjs +0 -149
- package/utils/constants/index.mjs +0 -620
- package/utils/constants/linter.mjs +0 -102
- package/utils/d2-utils.mjs +0 -198
- package/utils/debug.mjs +0 -3
- package/utils/delete-diagram-images.mjs +0 -99
- package/utils/deploy.mjs +0 -86
- package/utils/docs-finder-utils.mjs +0 -623
- package/utils/evaluate/report-utils.mjs +0 -132
- package/utils/extract-api.mjs +0 -32
- package/utils/file-utils.mjs +0 -960
- package/utils/history-utils.mjs +0 -203
- package/utils/icon-map.mjs +0 -26
- package/utils/image-compress.mjs +0 -75
- package/utils/kroki-utils.mjs +0 -173
- package/utils/linter/index.mjs +0 -50
- package/utils/load-config.mjs +0 -107
- package/utils/markdown/index.mjs +0 -26
- package/utils/markdown-checker.mjs +0 -694
- package/utils/mermaid-validator.mjs +0 -140
- package/utils/mermaid-worker-pool.mjs +0 -250
- package/utils/mermaid-worker.mjs +0 -233
- package/utils/openapi/index.mjs +0 -28
- package/utils/preferences-utils.mjs +0 -175
- package/utils/request.mjs +0 -10
- package/utils/store/index.mjs +0 -45
- package/utils/sync-diagram-to-translations.mjs +0 -262
- package/utils/upload-files.mjs +0 -231
- package/utils/utils.mjs +0 -1354
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import { DIAGRAM_PLACEHOLDER, d2CodeBlockRegex, diagramImageStartRegex } from "./d2-utils.mjs";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Check if document content contains diagram-related content
|
|
5
|
-
* @param {string} content - Document content to check
|
|
6
|
-
* @returns {boolean} - True if document contains d2 code blocks, DIAGRAM_PLACEHOLDER, or diagram images
|
|
7
|
-
*/
|
|
8
|
-
export function hasDiagramContent(content) {
|
|
9
|
-
if (!content || typeof content !== "string") {
|
|
10
|
-
return false;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
// Check for DIAGRAM_PLACEHOLDER
|
|
14
|
-
if (content.includes(DIAGRAM_PLACEHOLDER)) {
|
|
15
|
-
return true;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// Check for D2 code blocks
|
|
19
|
-
const d2Matches = Array.from(content.matchAll(d2CodeBlockRegex));
|
|
20
|
-
if (d2Matches.length > 0) {
|
|
21
|
-
return true;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// Check for existing diagram images (DIAGRAM_IMAGE_START markers)
|
|
25
|
-
const imageMatches = Array.from(content.matchAll(diagramImageStartRegex));
|
|
26
|
-
if (imageMatches.length > 0) {
|
|
27
|
-
return true;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return false;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Get diagram type labels for a document
|
|
35
|
-
* @param {string} content - Document content to analyze
|
|
36
|
-
* @returns {string[]} - Array of diagram type labels (e.g., ["D2", "AI Image", "Placeholder"])
|
|
37
|
-
*/
|
|
38
|
-
export function getDiagramTypeLabels(content) {
|
|
39
|
-
if (!content || typeof content !== "string") {
|
|
40
|
-
return [];
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const labels = [];
|
|
44
|
-
|
|
45
|
-
// Check for D2 code blocks
|
|
46
|
-
const d2Matches = Array.from(content.matchAll(d2CodeBlockRegex));
|
|
47
|
-
if (d2Matches.length > 0) {
|
|
48
|
-
labels.push("⛔️ D2");
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// Check for existing diagram images (AI-generated images)
|
|
52
|
-
const imageMatches = Array.from(content.matchAll(diagramImageStartRegex));
|
|
53
|
-
if (imageMatches.length > 0) {
|
|
54
|
-
labels.push("🍌 Image");
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// Check for DIAGRAM_PLACEHOLDER
|
|
58
|
-
if (content.includes(DIAGRAM_PLACEHOLDER)) {
|
|
59
|
-
labels.push("Placeholder");
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return labels;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Format diagram type labels as a suffix string
|
|
67
|
-
* @param {string[]} labels - Array of diagram type labels
|
|
68
|
-
* @returns {string} - Formatted suffix string (e.g., " [D2, AI Image]")
|
|
69
|
-
*/
|
|
70
|
-
export function formatDiagramTypeSuffix(labels) {
|
|
71
|
-
if (!labels || labels.length === 0) {
|
|
72
|
-
return "";
|
|
73
|
-
}
|
|
74
|
-
return ` [${labels.join(", ")}]`;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Check if document content contains banana images (AI-generated images)
|
|
79
|
-
* Only checks for DIAGRAM_IMAGE_START markers, excludes D2 code blocks and placeholders
|
|
80
|
-
* @param {string} content - Document content to check
|
|
81
|
-
* @returns {boolean} - True if document contains banana images
|
|
82
|
-
*/
|
|
83
|
-
export function hasBananaImages(content) {
|
|
84
|
-
if (!content || typeof content !== "string") {
|
|
85
|
-
return false;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// Check for existing diagram images (DIAGRAM_IMAGE_START markers)
|
|
89
|
-
const imageMatches = Array.from(content.matchAll(diagramImageStartRegex));
|
|
90
|
-
if (imageMatches.length > 0) {
|
|
91
|
-
return true;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
return false;
|
|
95
|
-
}
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CONFLICT_RESOLUTION_RULES,
|
|
3
|
-
CONFLICT_RULES,
|
|
4
|
-
RESOLUTION_STRATEGIES,
|
|
5
|
-
} from "./constants/index.mjs";
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Get filtered options based on cross-question conflict rules
|
|
9
|
-
* @param {string} targetQuestion - Target question type to filter
|
|
10
|
-
* @param {Object} currentSelections - Current user selections across all questions
|
|
11
|
-
* @param {Object} allOptions - All available options for the target question
|
|
12
|
-
* @returns {Object} Filtered options
|
|
13
|
-
*/
|
|
14
|
-
export function getFilteredOptions(targetQuestion, currentSelections, allOptions) {
|
|
15
|
-
const crossRules = CONFLICT_RULES.crossConflicts;
|
|
16
|
-
const filteredOptions = { ...allOptions };
|
|
17
|
-
const appliedFilters = [];
|
|
18
|
-
|
|
19
|
-
crossRules.forEach((rule) => {
|
|
20
|
-
// Check if we should apply this rule for filtering the target question
|
|
21
|
-
const shouldApplyRule = (() => {
|
|
22
|
-
// Check if this rule applies to the target question
|
|
23
|
-
const conflictingForTarget = rule.conflictingOptions[targetQuestion];
|
|
24
|
-
if (!conflictingForTarget) {
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// Check if current selections match the conditions that would trigger filtering
|
|
29
|
-
const nonTargetConditions = Object.entries(rule.conditions).filter(
|
|
30
|
-
([key]) => key !== targetQuestion,
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
if (nonTargetConditions.length === 0) {
|
|
34
|
-
return false;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const matchesNonTargetConditions = nonTargetConditions.every(([key, values]) => {
|
|
38
|
-
const selection = currentSelections[key];
|
|
39
|
-
if (!selection) return false;
|
|
40
|
-
|
|
41
|
-
// Extract values if selection contains objects
|
|
42
|
-
const selectionArray = Array.isArray(selection) ? selection : [selection];
|
|
43
|
-
const selectionValues = selectionArray.map((item) =>
|
|
44
|
-
typeof item === "object" && item.value ? item.value : item,
|
|
45
|
-
);
|
|
46
|
-
|
|
47
|
-
return values.some((value) => selectionValues.includes(value));
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
return matchesNonTargetConditions;
|
|
51
|
-
})();
|
|
52
|
-
|
|
53
|
-
if (shouldApplyRule && rule.action === "filter") {
|
|
54
|
-
// Filter out conflicting options for the target question
|
|
55
|
-
const conflictingForTarget = rule.conflictingOptions[targetQuestion];
|
|
56
|
-
|
|
57
|
-
if (conflictingForTarget) {
|
|
58
|
-
conflictingForTarget.forEach((conflictOption) => {
|
|
59
|
-
if (filteredOptions[conflictOption]) {
|
|
60
|
-
delete filteredOptions[conflictOption];
|
|
61
|
-
appliedFilters.push({
|
|
62
|
-
removedOption: conflictOption,
|
|
63
|
-
reason: rule.reason,
|
|
64
|
-
severity: rule.severity,
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
return {
|
|
73
|
-
filteredOptions,
|
|
74
|
-
appliedFilters,
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Detect conflicts in user configuration selections that can be resolved through documentation structure
|
|
80
|
-
* @param {Object} config - User configuration
|
|
81
|
-
* @returns {Array} Array of detected conflicts with resolution strategies
|
|
82
|
-
*/
|
|
83
|
-
export function detectResolvableConflicts(config) {
|
|
84
|
-
const conflicts = [];
|
|
85
|
-
|
|
86
|
-
// Check each question type for conflicts
|
|
87
|
-
Object.entries(CONFLICT_RESOLUTION_RULES).forEach(([questionType, rules]) => {
|
|
88
|
-
const selectedValues = config[questionType];
|
|
89
|
-
|
|
90
|
-
if (!selectedValues || !Array.isArray(selectedValues) || selectedValues.length < 2) {
|
|
91
|
-
return; // Skip if not multi-select or less than 2 items
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
// Extract values from the selected items (handle both string arrays and object arrays)
|
|
95
|
-
const selectedValueStrings = selectedValues.map((item) =>
|
|
96
|
-
typeof item === "object" && item.value ? item.value : item,
|
|
97
|
-
);
|
|
98
|
-
|
|
99
|
-
// Check each conflict rule
|
|
100
|
-
rules.forEach((rule) => {
|
|
101
|
-
// Check if all conflict items are selected
|
|
102
|
-
const hasConflict = rule.conflictItems.every((item) => selectedValueStrings.includes(item));
|
|
103
|
-
|
|
104
|
-
if (hasConflict) {
|
|
105
|
-
conflicts.push({
|
|
106
|
-
type: questionType,
|
|
107
|
-
items: rule.conflictItems,
|
|
108
|
-
strategy: rule.strategy,
|
|
109
|
-
description: rule.description,
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
return conflicts;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Generate conflict resolution rules based on detected conflicts
|
|
120
|
-
* @param {Array} conflicts - Array of detected conflicts
|
|
121
|
-
* @returns {string} Conflict resolution instructions
|
|
122
|
-
*/
|
|
123
|
-
export function generateConflictResolutionRules(conflicts) {
|
|
124
|
-
if (conflicts.length === 0) return "";
|
|
125
|
-
|
|
126
|
-
const rules = ["=== Conflict Resolution Guidelines ==="];
|
|
127
|
-
|
|
128
|
-
conflicts.forEach((conflict) => {
|
|
129
|
-
const strategy = RESOLUTION_STRATEGIES[conflict.strategy];
|
|
130
|
-
if (strategy) {
|
|
131
|
-
rules.push(strategy(conflict.items));
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
rules.push("");
|
|
136
|
-
rules.push("Conflict Resolution Principles:");
|
|
137
|
-
rules.push(
|
|
138
|
-
"1. Meet diverse needs through intelligent structural design, not by simply concatenating information.",
|
|
139
|
-
);
|
|
140
|
-
rules.push("2. Create clear navigation paths for different purposes and audiences.");
|
|
141
|
-
rules.push(
|
|
142
|
-
"3. Ensure a reasonable content hierarchy that avoids information duplication and contradiction.",
|
|
143
|
-
);
|
|
144
|
-
rules.push(
|
|
145
|
-
"4. Prioritize the user experience by enabling users to quickly find the information they need.",
|
|
146
|
-
);
|
|
147
|
-
|
|
148
|
-
return rules.join("\n");
|
|
149
|
-
}
|