@aigne/doc-smith 0.9.8-alpha.3 → 0.9.8-alpha.4
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 +2 -149
- 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,297 +0,0 @@
|
|
|
1
|
-
import { DIAGRAM_STYLES } from "../../utils/constants/index.mjs";
|
|
2
|
-
|
|
3
|
-
const DEFAULT_DIAGRAM_STYLE = "modern";
|
|
4
|
-
const DEFAULT_DIAGRAM_TYPE = "flowchart";
|
|
5
|
-
|
|
6
|
-
// Type-specific content requirements
|
|
7
|
-
const TYPE_REQUIREMENTS = {
|
|
8
|
-
architecture: `- Accurately represent the system architecture, components, services, and their relationships
|
|
9
|
-
- Show clear component boundaries and service interactions
|
|
10
|
-
- Include all key architectural elements (layers, modules, services, databases, APIs)
|
|
11
|
-
- Display data flow and communication patterns between components
|
|
12
|
-
- Use clear labels for each component and connection`,
|
|
13
|
-
flowchart: `- Accurately represent the process flow, steps, decisions, and workflow
|
|
14
|
-
- Show clear step-by-step progression with decision points
|
|
15
|
-
- Use standard flowchart symbols: rectangles for processes, diamonds for decisions, arrows for flows
|
|
16
|
-
- Include all key steps and decision branches
|
|
17
|
-
- Maintain logical flow direction (top-to-bottom or left-to-right)`,
|
|
18
|
-
guide: `- Show user journey, tutorial flow, or guided process
|
|
19
|
-
- Display clear progression from start to completion
|
|
20
|
-
- Include key milestones, checkpoints, or decision points
|
|
21
|
-
- Use clear visual cues to guide the viewer through the process
|
|
22
|
-
- Make it easy to follow and understand the path`,
|
|
23
|
-
intro: `- Provide a high-level overview or conceptual explanation
|
|
24
|
-
- Show main concepts, relationships, and key ideas
|
|
25
|
-
- Use clear visual hierarchy to emphasize important elements
|
|
26
|
-
- Make it accessible and easy to understand for newcomers
|
|
27
|
-
- Focus on big picture rather than detailed implementation`,
|
|
28
|
-
sequence: `- Show interactions over time between components or actors
|
|
29
|
-
- Display clear message flow and timing
|
|
30
|
-
- Include all participating entities and their interactions
|
|
31
|
-
- Show chronological order of events
|
|
32
|
-
- Use clear labels for messages and interactions`,
|
|
33
|
-
network: `- Show network structure, nodes, and connections
|
|
34
|
-
- Display routing paths and network topology
|
|
35
|
-
- Include all network components (routers, switches, servers, clients)
|
|
36
|
-
- Show connection types and data flow directions
|
|
37
|
-
- Use clear labels for network elements`,
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
// Style-specific requirements
|
|
41
|
-
const STYLE_REQUIREMENTS = {
|
|
42
|
-
modern: `- Modern, clean, professional diagram style
|
|
43
|
-
- Contemporary design elements with smooth lines
|
|
44
|
-
- Professional color scheme suitable for technical documentation
|
|
45
|
-
- Clear visual hierarchy and readable text
|
|
46
|
-
- Sleek and polished appearance`,
|
|
47
|
-
standard: `- Standard flowchart style with traditional symbols
|
|
48
|
-
- Conventional formatting and clear structure
|
|
49
|
-
- Rectangles for processes, diamonds for decisions, arrows for flows
|
|
50
|
-
- Clear, readable text labels
|
|
51
|
-
- Professional and familiar appearance`,
|
|
52
|
-
"hand-drawn": `- Hand-drawn, sketch-like style with natural, organic lines
|
|
53
|
-
- Slightly imperfect shapes for a casual, approachable appearance
|
|
54
|
-
- Natural line variations and hand-drawn aesthetics
|
|
55
|
-
- Friendly and informal visual style
|
|
56
|
-
- Avoid perfect geometric shapes`,
|
|
57
|
-
anthropomorphic: `- Anthropomorphic style with personified elements
|
|
58
|
-
- Vivid and lively imagery with characters or objects having human-like features
|
|
59
|
-
- Engaging and memorable visual elements
|
|
60
|
-
- Creative and expressive design
|
|
61
|
-
- Make abstract concepts more relatable through personification`,
|
|
62
|
-
flat: `- Flat design style with no shadows, gradients, or 3D effects
|
|
63
|
-
- Clean geometric shapes with bold colors
|
|
64
|
-
- Minimalist aesthetics with simple, flat surfaces
|
|
65
|
-
- Modern and clean appearance
|
|
66
|
-
- Avoid depth and dimensionality`,
|
|
67
|
-
minimalist: `- Minimalist style with the fewest possible elements
|
|
68
|
-
- Maximum clarity with simple shapes
|
|
69
|
-
- Ample white space and essential information only
|
|
70
|
-
- Clean and uncluttered appearance
|
|
71
|
-
- Focus on core message without distractions`,
|
|
72
|
-
"3d": `- 3D style with three-dimensional effects and perspective
|
|
73
|
-
- Depth, shadows, and realistic spatial relationships
|
|
74
|
-
- Three-dimensional appearance with volume and dimension
|
|
75
|
-
- Professional and modern 3D rendering
|
|
76
|
-
- Clear depth cues and perspective`,
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Analyze document content to determine diagram type and select appropriate style
|
|
81
|
-
* Uses LLM analysis to determine diagram type and style
|
|
82
|
-
* Supports extracting style and type preferences from user feedback
|
|
83
|
-
*/
|
|
84
|
-
export default async function analyzeDiagramType(
|
|
85
|
-
{
|
|
86
|
-
documentContent,
|
|
87
|
-
availableStyles = [],
|
|
88
|
-
defaultStyle,
|
|
89
|
-
diagramming,
|
|
90
|
-
locale = "en",
|
|
91
|
-
feedback = "",
|
|
92
|
-
},
|
|
93
|
-
options,
|
|
94
|
-
) {
|
|
95
|
-
// Extract defaultStyle from diagramming object if not provided directly
|
|
96
|
-
if (!defaultStyle && diagramming?.style) {
|
|
97
|
-
defaultStyle = diagramming.style;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
// Step 1: Use LLM to analyze and make final decision (LLM will analyze feedback directly)
|
|
101
|
-
const llmAgent = options.context?.agents?.["analyzeDiagramTypeLLM"];
|
|
102
|
-
let llmResult = null;
|
|
103
|
-
|
|
104
|
-
if (llmAgent) {
|
|
105
|
-
try {
|
|
106
|
-
// Build styleDescriptions object for template
|
|
107
|
-
// Include predefined styles as reference, but allow LLM to use any style
|
|
108
|
-
const styleDescriptions = {};
|
|
109
|
-
const stylesToUse =
|
|
110
|
-
availableStyles.length > 0 ? availableStyles : Object.keys(DIAGRAM_STYLES);
|
|
111
|
-
for (const style of stylesToUse) {
|
|
112
|
-
if (DIAGRAM_STYLES[style]) {
|
|
113
|
-
styleDescriptions[style] =
|
|
114
|
-
DIAGRAM_STYLES[style].description || DIAGRAM_STYLES[style].name;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
// Also include all predefined styles as reference even if not in availableStyles
|
|
118
|
-
// This helps LLM understand common style options but doesn't restrict it
|
|
119
|
-
for (const [style, styleInfo] of Object.entries(DIAGRAM_STYLES)) {
|
|
120
|
-
if (!styleDescriptions[style]) {
|
|
121
|
-
styleDescriptions[style] = styleInfo.description || styleInfo.name;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
const llmInput = {
|
|
126
|
-
documentContent,
|
|
127
|
-
availableStyles: stylesToUse,
|
|
128
|
-
styleDescriptions,
|
|
129
|
-
locale,
|
|
130
|
-
feedback: feedback || "",
|
|
131
|
-
defaultStyle: defaultStyle || null,
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
llmResult = await options.context.invoke(llmAgent, llmInput);
|
|
135
|
-
} catch (error) {
|
|
136
|
-
console.warn(`⚠️ LLM analysis failed: ${error.message}`);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
// Step 2: Determine diagram type
|
|
141
|
-
// Priority: LLM result (which already analyzed feedback) > default
|
|
142
|
-
const diagramType = llmResult?.diagramType || DEFAULT_DIAGRAM_TYPE;
|
|
143
|
-
|
|
144
|
-
// Step 3: Select style
|
|
145
|
-
// Trust LLM to always return a valid style (required in output_schema)
|
|
146
|
-
// LLM can return any style name, not limited to predefined styles
|
|
147
|
-
// Only use fallback if LLM completely failed
|
|
148
|
-
const diagramStyle = llmResult?.diagramStyle || defaultStyle || DEFAULT_DIAGRAM_STYLE;
|
|
149
|
-
|
|
150
|
-
// Note: We allow any style name from LLM, even if not in availableStyles
|
|
151
|
-
// This enables creative styles beyond predefined ones (e.g., 'watercolor', 'cyberpunk', 'isometric')
|
|
152
|
-
// If availableStyles is provided and not empty, it serves as a preference guide, not a strict restriction
|
|
153
|
-
|
|
154
|
-
// Step 4: Generate prompt requirements for image generation
|
|
155
|
-
const diagramTypeRequirements =
|
|
156
|
-
TYPE_REQUIREMENTS[diagramType] || TYPE_REQUIREMENTS[DEFAULT_DIAGRAM_TYPE];
|
|
157
|
-
const diagramStyleRequirements =
|
|
158
|
-
STYLE_REQUIREMENTS[diagramStyle] || STYLE_REQUIREMENTS[DEFAULT_DIAGRAM_STYLE];
|
|
159
|
-
|
|
160
|
-
// Generate negative prompt exclusions based on style
|
|
161
|
-
let negativePromptExclusions = "";
|
|
162
|
-
if (diagramStyle !== "anthropomorphic") {
|
|
163
|
-
negativePromptExclusions += ", anthropomorphic";
|
|
164
|
-
}
|
|
165
|
-
if (diagramStyle !== "hand-drawn") {
|
|
166
|
-
negativePromptExclusions += ", hand-drawn, sketch";
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
// Step 5: Extract document summary from LLM result
|
|
170
|
-
// The LLM creates a concise summary focusing on key elements for diagram generation
|
|
171
|
-
// This ensures both the analysis model and image generation model have consistent understanding
|
|
172
|
-
const documentSummary = llmResult?.documentSummary || documentContent;
|
|
173
|
-
|
|
174
|
-
// If LLM didn't provide a summary (fallback), use original content
|
|
175
|
-
// But prefer the LLM-generated summary as it's focused and aligned with the analysis
|
|
176
|
-
|
|
177
|
-
// Step 6: Determine aspect ratio from LLM result
|
|
178
|
-
// The LLM analyzes the content structure and recommends the best aspect ratio
|
|
179
|
-
// We trust the LLM's judgment as it has analyzed the actual content
|
|
180
|
-
// If LLM doesn't provide aspectRatio (shouldn't happen, but fallback for safety), use 4:3 as safe default
|
|
181
|
-
let aspectRatio = llmResult?.aspectRatio || "4:3";
|
|
182
|
-
|
|
183
|
-
// Validate that the aspectRatio is one of the supported values
|
|
184
|
-
const supportedRatios = ["1:1", "5:4", "4:3", "3:2", "16:9", "21:9"];
|
|
185
|
-
if (!supportedRatios.includes(aspectRatio)) {
|
|
186
|
-
console.warn(`Invalid aspectRatio "${aspectRatio}" from LLM, falling back to "4:3"`);
|
|
187
|
-
aspectRatio = "4:3";
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
// Step 7: Return document content and summary for image generation
|
|
191
|
-
return {
|
|
192
|
-
diagramType,
|
|
193
|
-
diagramStyle,
|
|
194
|
-
aspectRatio,
|
|
195
|
-
documentContent, // The full document content (kept for backward compatibility and additional context)
|
|
196
|
-
documentSummary, // The concise summary generated by LLM, focused on key elements for diagram generation
|
|
197
|
-
diagramTypeRequirements,
|
|
198
|
-
diagramStyleRequirements,
|
|
199
|
-
negativePromptExclusions,
|
|
200
|
-
};
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
analyzeDiagramType.input_schema = {
|
|
204
|
-
type: "object",
|
|
205
|
-
properties: {
|
|
206
|
-
documentContent: {
|
|
207
|
-
type: "string",
|
|
208
|
-
description: "The document content to analyze for diagram type and style selection",
|
|
209
|
-
},
|
|
210
|
-
availableStyles: {
|
|
211
|
-
type: "array",
|
|
212
|
-
description:
|
|
213
|
-
"List of available diagram styles configured by user (optional restriction). If empty, any style is allowed.",
|
|
214
|
-
items: {
|
|
215
|
-
type: "string",
|
|
216
|
-
},
|
|
217
|
-
},
|
|
218
|
-
defaultStyle: {
|
|
219
|
-
type: "string",
|
|
220
|
-
description:
|
|
221
|
-
"Default diagram style to use when no style is specified in feedback. Can be any style name, not limited to predefined styles.",
|
|
222
|
-
},
|
|
223
|
-
diagramming: {
|
|
224
|
-
type: "object",
|
|
225
|
-
description: "Diagramming configuration object (alternative way to pass style)",
|
|
226
|
-
properties: {
|
|
227
|
-
style: {
|
|
228
|
-
type: "string",
|
|
229
|
-
description: "Default diagram style",
|
|
230
|
-
},
|
|
231
|
-
},
|
|
232
|
-
},
|
|
233
|
-
locale: {
|
|
234
|
-
type: "string",
|
|
235
|
-
description: "Language for analysis",
|
|
236
|
-
default: "en",
|
|
237
|
-
},
|
|
238
|
-
feedback: {
|
|
239
|
-
type: "string",
|
|
240
|
-
description:
|
|
241
|
-
"User feedback that may contain style or type preferences (e.g., 'use anthropomorphic style', 'create architecture diagram')",
|
|
242
|
-
default: "",
|
|
243
|
-
},
|
|
244
|
-
},
|
|
245
|
-
required: ["documentContent"],
|
|
246
|
-
};
|
|
247
|
-
|
|
248
|
-
analyzeDiagramType.output_schema = {
|
|
249
|
-
type: "object",
|
|
250
|
-
properties: {
|
|
251
|
-
diagramType: {
|
|
252
|
-
type: "string",
|
|
253
|
-
description: "The detected diagram type",
|
|
254
|
-
},
|
|
255
|
-
diagramStyle: {
|
|
256
|
-
type: "string",
|
|
257
|
-
description: "The selected diagram style",
|
|
258
|
-
},
|
|
259
|
-
diagramTypeRequirements: {
|
|
260
|
-
type: "string",
|
|
261
|
-
description: "Content requirements for the diagram type",
|
|
262
|
-
},
|
|
263
|
-
diagramStyleRequirements: {
|
|
264
|
-
type: "string",
|
|
265
|
-
description: "Style requirements for the diagram style",
|
|
266
|
-
},
|
|
267
|
-
negativePromptExclusions: {
|
|
268
|
-
type: "string",
|
|
269
|
-
description: "Additional negative prompt exclusions based on style",
|
|
270
|
-
},
|
|
271
|
-
aspectRatio: {
|
|
272
|
-
type: "string",
|
|
273
|
-
description: "Aspect ratio for the diagram (must match content flow direction)",
|
|
274
|
-
enum: ["1:1", "5:4", "4:3", "3:2", "16:9", "21:9"],
|
|
275
|
-
},
|
|
276
|
-
documentContent: {
|
|
277
|
-
type: "string",
|
|
278
|
-
description:
|
|
279
|
-
"The full document content (kept for backward compatibility and additional context)",
|
|
280
|
-
},
|
|
281
|
-
documentSummary: {
|
|
282
|
-
type: "string",
|
|
283
|
-
description:
|
|
284
|
-
"A concise summary of the document content focusing on key elements needed for diagram generation. This summary is generated by the analysis LLM to ensure consistent understanding between analysis and image generation models.",
|
|
285
|
-
},
|
|
286
|
-
},
|
|
287
|
-
required: [
|
|
288
|
-
"diagramType",
|
|
289
|
-
"diagramStyle",
|
|
290
|
-
"aspectRatio",
|
|
291
|
-
"documentSummary",
|
|
292
|
-
"diagramTypeRequirements",
|
|
293
|
-
"diagramStyleRequirements",
|
|
294
|
-
"negativePromptExclusions",
|
|
295
|
-
"documentContent",
|
|
296
|
-
],
|
|
297
|
-
};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
name: checkDocumentStructure
|
|
2
|
-
description: Check the Documentation Structure to ensure it meets expectations, especially in scenarios with previous generation results and user feedback.
|
|
3
|
-
instructions:
|
|
4
|
-
url: ../../prompts/structure/check-document-structure.md
|
|
5
|
-
input_schema:
|
|
6
|
-
type: object
|
|
7
|
-
properties:
|
|
8
|
-
documentStructure:
|
|
9
|
-
$ref: ../schema/document-structure.yaml
|
|
10
|
-
description: Newly generated documentation structure.
|
|
11
|
-
originalDocumentStructure:
|
|
12
|
-
$ref: ../schema/document-structure.yaml
|
|
13
|
-
description: Previous generation's documentation structure for comparison. If it doesn't exist, the check passes by default.
|
|
14
|
-
feedback:
|
|
15
|
-
type: string
|
|
16
|
-
description: User feedback provided for the previous generation's results.
|
|
17
|
-
required:
|
|
18
|
-
- documentStructure
|
|
19
|
-
output_schema:
|
|
20
|
-
type: object
|
|
21
|
-
properties:
|
|
22
|
-
isValid:
|
|
23
|
-
type: boolean
|
|
24
|
-
description: Whether the check passes. true indicates pass, false indicates failure.
|
|
25
|
-
structureReviewFeedback:
|
|
26
|
-
type: string
|
|
27
|
-
description: Detailed explanation of the check results. If it fails, clearly specify which parts do not meet requirements.
|
|
28
|
-
required:
|
|
29
|
-
- isValid
|
|
30
|
-
- structureReviewFeedback
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { getActiveRulesForScope } from "../../utils/preferences-utils.mjs";
|
|
2
|
-
import { getProjectInfo, loadConfigFromFile, saveValueToConfig } from "../../utils/utils.mjs";
|
|
3
|
-
import streamlineDocumentTitlesIfNeeded from "../utils/streamline-document-titles-if-needed.mjs";
|
|
4
|
-
|
|
5
|
-
export default async function checkNeedGenerateStructure(
|
|
6
|
-
{ originalDocumentStructure, forceRegenerate, ...rest },
|
|
7
|
-
options,
|
|
8
|
-
) {
|
|
9
|
-
let finalFeedback = "";
|
|
10
|
-
|
|
11
|
-
// User requested regeneration
|
|
12
|
-
if (forceRegenerate) {
|
|
13
|
-
finalFeedback = `
|
|
14
|
-
User requested forced regeneration of documentation structure. Please regenerate based on the latest Data Sources and user requirements, **allowing any modifications**.
|
|
15
|
-
`;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
if (originalDocumentStructure && !forceRegenerate) {
|
|
19
|
-
return {
|
|
20
|
-
documentStructure: originalDocumentStructure,
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const generateStructureAgent = options.context.agents["generateStructureExp"];
|
|
25
|
-
|
|
26
|
-
const structureRules = getActiveRulesForScope("structure", []);
|
|
27
|
-
const globalRules = getActiveRulesForScope("global", []);
|
|
28
|
-
|
|
29
|
-
const allApplicableRules = [...structureRules, ...globalRules];
|
|
30
|
-
const ruleTexts = allApplicableRules.map((rule) => rule.rule);
|
|
31
|
-
|
|
32
|
-
const userPreferences = ruleTexts.length > 0 ? ruleTexts.join("\n\n") : "";
|
|
33
|
-
|
|
34
|
-
const result = await options.context.invoke(generateStructureAgent, {
|
|
35
|
-
...rest,
|
|
36
|
-
originalDocumentStructure,
|
|
37
|
-
userPreferences,
|
|
38
|
-
feedback: finalFeedback || "",
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
await streamlineDocumentTitlesIfNeeded({ documentStructure: result.documentStructure }, options);
|
|
42
|
-
options.context.userContext.streamlinedDocumentTitles = true;
|
|
43
|
-
|
|
44
|
-
let message = "";
|
|
45
|
-
|
|
46
|
-
// Check and save project information
|
|
47
|
-
if (result.projectName || result.projectDesc) {
|
|
48
|
-
try {
|
|
49
|
-
const currentConfig = await loadConfigFromFile();
|
|
50
|
-
const projectInfo = await getProjectInfo();
|
|
51
|
-
|
|
52
|
-
const userModifiedProjectName =
|
|
53
|
-
currentConfig?.projectName && currentConfig.projectName !== projectInfo.name;
|
|
54
|
-
const userModifiedProjectDesc =
|
|
55
|
-
currentConfig?.projectDesc && currentConfig.projectDesc !== projectInfo.description;
|
|
56
|
-
|
|
57
|
-
// Save AI-generated project info if not modified by the user and not from GitHub
|
|
58
|
-
if (!userModifiedProjectName && !userModifiedProjectDesc) {
|
|
59
|
-
let hasUpdated = false;
|
|
60
|
-
// Don't update if the current info is from GitHub
|
|
61
|
-
if (
|
|
62
|
-
result.projectName &&
|
|
63
|
-
result.projectName !== projectInfo.name &&
|
|
64
|
-
!projectInfo.fromGitHub
|
|
65
|
-
) {
|
|
66
|
-
// Remove leading and trailing spaces (middle spaces are preserved and count toward limit)
|
|
67
|
-
const trimmedProjectName = result.projectName.trim();
|
|
68
|
-
await saveValueToConfig("projectName", trimmedProjectName);
|
|
69
|
-
message += `Project name: \`${trimmedProjectName}\``;
|
|
70
|
-
hasUpdated = true;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (
|
|
74
|
-
result.projectDesc &&
|
|
75
|
-
result.projectDesc !== projectInfo.description &&
|
|
76
|
-
!projectInfo.fromGitHub
|
|
77
|
-
) {
|
|
78
|
-
// Remove leading and trailing spaces (middle spaces are preserved and count toward limit)
|
|
79
|
-
const trimmedProjectDesc = result.projectDesc.trim();
|
|
80
|
-
await saveValueToConfig("projectDesc", trimmedProjectDesc);
|
|
81
|
-
message += `\nProject description: \`${trimmedProjectDesc}\``;
|
|
82
|
-
hasUpdated = true;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
if (hasUpdated) {
|
|
86
|
-
message = `\n## Project Information Updated\n\nSaved to \`.aigne/doc-smith/config.yaml\`:\n\n${message}\n\n`;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
} catch (error) {
|
|
90
|
-
console.warn("Failed to check/save project information:", error.message);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
return {
|
|
95
|
-
...result,
|
|
96
|
-
feedback: "", // clear feedback
|
|
97
|
-
projectInfoMessage: message,
|
|
98
|
-
originalDocumentStructure: originalDocumentStructure
|
|
99
|
-
? originalDocumentStructure
|
|
100
|
-
: JSON.parse(JSON.stringify(result.documentStructure || [])),
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
checkNeedGenerateStructure.taskTitle =
|
|
105
|
-
"Check if documentation structure needs to be generated or updated";
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getAddDocumentInputJsonSchema,
|
|
3
|
-
getAddDocumentOutputJsonSchema,
|
|
4
|
-
validateAddDocumentInput,
|
|
5
|
-
} from "../../../types/document-structure-schema.mjs";
|
|
6
|
-
import streamlineDocumentTitlesIfNeeded from "../../utils/streamline-document-titles-if-needed.mjs";
|
|
7
|
-
|
|
8
|
-
export default async function addDocument(input, options) {
|
|
9
|
-
// Validate input using Zod schema
|
|
10
|
-
const validation = validateAddDocumentInput(input);
|
|
11
|
-
if (!validation.success) {
|
|
12
|
-
const errorMessage = `Cannot add document: ${validation.error}`;
|
|
13
|
-
console.log(`⚠️ ${errorMessage}`);
|
|
14
|
-
return {
|
|
15
|
-
documentStructure: input.documentStructure,
|
|
16
|
-
error: { message: errorMessage },
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const { title, description, path, parentId, sourceIds } = validation.data;
|
|
21
|
-
let documentStructure = options?.context?.userContext?.currentStructure;
|
|
22
|
-
|
|
23
|
-
if (!documentStructure) {
|
|
24
|
-
documentStructure = input.documentStructure;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// Validate parent exists if parentId is provided
|
|
28
|
-
if (parentId && parentId !== "null") {
|
|
29
|
-
const parentExists = documentStructure.some((item) => item.path === parentId);
|
|
30
|
-
if (!parentExists) {
|
|
31
|
-
const errorMessage = `Cannot add document: Parent document '${parentId}' not found.`;
|
|
32
|
-
console.log(`⚠️ ${errorMessage}`);
|
|
33
|
-
return {
|
|
34
|
-
documentStructure,
|
|
35
|
-
error: { message: errorMessage },
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// Check if document with same path already exists
|
|
41
|
-
const existingDocument = documentStructure.find((item) => item.path === path);
|
|
42
|
-
if (existingDocument) {
|
|
43
|
-
const errorMessage = `Cannot add document: A document with path '${path}' already exists. Choose a different path.`;
|
|
44
|
-
console.log(`⚠️ ${errorMessage}`);
|
|
45
|
-
return {
|
|
46
|
-
documentStructure,
|
|
47
|
-
error: { message: errorMessage },
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// Create new document object
|
|
52
|
-
const newDocument = {
|
|
53
|
-
title,
|
|
54
|
-
description,
|
|
55
|
-
path,
|
|
56
|
-
parentId: parentId || null,
|
|
57
|
-
sourceIds: [...sourceIds], // Create a copy of the array
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
// Streamline document titles if needed (will streamline the new document if title > 18 characters)
|
|
61
|
-
await streamlineDocumentTitlesIfNeeded({ documentStructure: [newDocument] }, options);
|
|
62
|
-
|
|
63
|
-
// Add the document to the structure
|
|
64
|
-
const updatedStructure = [...documentStructure, newDocument];
|
|
65
|
-
|
|
66
|
-
const successMessage = `addDocument executed successfully.
|
|
67
|
-
Successfully added document '${title}' with path '${path}'.
|
|
68
|
-
Check if the latest version of documentStructure meets user feedback, if so, just return 'success'.`;
|
|
69
|
-
|
|
70
|
-
// update shared document structure
|
|
71
|
-
if (options?.context?.userContext) {
|
|
72
|
-
options.context.userContext.currentStructure = updatedStructure;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
return {
|
|
76
|
-
documentStructure: updatedStructure,
|
|
77
|
-
message: successMessage,
|
|
78
|
-
addedDocument: newDocument,
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
addDocument.taskTitle = "Add document";
|
|
83
|
-
addDocument.description = "Add a document to the documentation structure";
|
|
84
|
-
addDocument.inputSchema = getAddDocumentInputJsonSchema();
|
|
85
|
-
addDocument.outputSchema = getAddDocumentOutputJsonSchema();
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getDeleteDocumentInputJsonSchema,
|
|
3
|
-
getDeleteDocumentOutputJsonSchema,
|
|
4
|
-
validateDeleteDocumentInput,
|
|
5
|
-
} from "../../../types/document-structure-schema.mjs";
|
|
6
|
-
import { userContextAt } from "../../../utils/utils.mjs";
|
|
7
|
-
|
|
8
|
-
export default async function deleteDocument(input, options) {
|
|
9
|
-
// Validate input using Zod schema
|
|
10
|
-
const validation = validateDeleteDocumentInput(input);
|
|
11
|
-
if (!validation.success) {
|
|
12
|
-
const errorMessage = `Cannot delete document: ${validation.error}`;
|
|
13
|
-
console.log(`⚠️ ${errorMessage}`);
|
|
14
|
-
return {
|
|
15
|
-
documentStructure: input.documentStructure,
|
|
16
|
-
error: { message: errorMessage },
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const { path, recursive = false } = validation.data;
|
|
21
|
-
let documentStructure = options?.context?.userContext?.currentStructure;
|
|
22
|
-
|
|
23
|
-
if (!documentStructure) {
|
|
24
|
-
documentStructure = input.documentStructure;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const deletedPathsContext = userContextAt(options, "deletedPaths");
|
|
28
|
-
const deletedPaths = deletedPathsContext.get() || [];
|
|
29
|
-
|
|
30
|
-
// Check if path has already been deleted
|
|
31
|
-
if (recursive) {
|
|
32
|
-
if (deletedPaths.includes(path)) {
|
|
33
|
-
const message = `Skipping duplicate deletion. Document '${path}' has already been deleted.`;
|
|
34
|
-
return {
|
|
35
|
-
documentStructure,
|
|
36
|
-
message,
|
|
37
|
-
deletedDocuments: [],
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// Find the document to delete
|
|
43
|
-
const documentIndex = documentStructure.findIndex((item) => item.path === path);
|
|
44
|
-
if (documentIndex === -1) {
|
|
45
|
-
const errorMessage = `Cannot delete document: Document '${path}' does not exist. Please choose an existing document to delete.`;
|
|
46
|
-
console.log(`⚠️ ${errorMessage}`);
|
|
47
|
-
return {
|
|
48
|
-
documentStructure,
|
|
49
|
-
error: { message: errorMessage },
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const documentToDelete = documentStructure[documentIndex];
|
|
54
|
-
|
|
55
|
-
// Find all child documents (direct and indirect)
|
|
56
|
-
const findAllChildren = (parentPath, structure) => {
|
|
57
|
-
const children = structure.filter((item) => item.parentId === parentPath);
|
|
58
|
-
const allChildren = [...children];
|
|
59
|
-
for (const child of children) {
|
|
60
|
-
allChildren.push(...findAllChildren(child.path, structure));
|
|
61
|
-
}
|
|
62
|
-
return allChildren;
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
const childDocuments = findAllChildren(path, documentStructure);
|
|
66
|
-
|
|
67
|
-
// If recursive is false and there are child documents, return error
|
|
68
|
-
if (!recursive && childDocuments.length > 0) {
|
|
69
|
-
const errorMessage = `Cannot delete document: Document '${path}' has ${
|
|
70
|
-
childDocuments.length
|
|
71
|
-
} child document(s): ${childDocuments
|
|
72
|
-
.map((p) => p.path)
|
|
73
|
-
.join(
|
|
74
|
-
", ",
|
|
75
|
-
)}. Please first move or delete these child documents, or set recursive=true to delete them all.`;
|
|
76
|
-
console.log(`⚠️ ${errorMessage}`);
|
|
77
|
-
return {
|
|
78
|
-
documentStructure,
|
|
79
|
-
error: { message: errorMessage },
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// Collect all documents to delete (children first, then parent)
|
|
84
|
-
const documentsToDelete = recursive ? [...childDocuments, documentToDelete] : [documentToDelete];
|
|
85
|
-
const pathsToDelete = new Set(documentsToDelete.map((doc) => doc.path));
|
|
86
|
-
const deletedCount = pathsToDelete.size - 1;
|
|
87
|
-
|
|
88
|
-
// Remove all documents from the structure
|
|
89
|
-
const updatedStructure = documentStructure.filter((item) => !pathsToDelete.has(item.path));
|
|
90
|
-
|
|
91
|
-
// Add paths to deleted paths
|
|
92
|
-
if (recursive) {
|
|
93
|
-
deletedPathsContext.set(deletedPaths.concat(Array.from(pathsToDelete)));
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
// Build success message
|
|
97
|
-
const successMessage = `deleteDocument executed successfully.
|
|
98
|
-
Successfully deleted document '${documentToDelete.title}' with path '${path}'${recursive && deletedCount > 0 ? ` along with ${deletedCount} child document(s)` : ""}.
|
|
99
|
-
Check if the latest version of documentStructure meets user feedback, if so, just return 'success'.`;
|
|
100
|
-
|
|
101
|
-
// update shared document structure
|
|
102
|
-
if (options?.context?.userContext) {
|
|
103
|
-
options.context.userContext.currentStructure = updatedStructure;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
return {
|
|
107
|
-
documentStructure: updatedStructure,
|
|
108
|
-
message: successMessage,
|
|
109
|
-
deletedDocuments: documentsToDelete,
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
deleteDocument.taskTitle = "Delete document";
|
|
114
|
-
deleteDocument.description = "Remove a document from the documentation structure";
|
|
115
|
-
deleteDocument.inputSchema = getDeleteDocumentInputJsonSchema();
|
|
116
|
-
deleteDocument.outputSchema = getDeleteDocumentOutputJsonSchema();
|