@aigne/doc-smith 0.9.10 → 0.9.11-beta
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 +12 -0
- package/README.md +189 -219
- package/README.zh.md +270 -0
- package/agents/bash-executor/index.mjs +347 -0
- package/agents/clear/ai/intent.md +142 -0
- package/agents/clear/choose-contents.mjs +13 -65
- package/agents/clear/clear-auth-tokens.mjs +17 -21
- package/agents/clear/clear-deployment-config.mjs +33 -24
- package/agents/clear/index.yaml +1 -9
- package/agents/content-checker/ai/intent.md +209 -0
- package/agents/content-checker/clean-invalid-docs.mjs +254 -0
- package/agents/content-checker/index.mjs +191 -0
- package/agents/content-checker/validate-content.mjs +983 -0
- package/agents/generate-images/generate-image.yaml +75 -0
- package/agents/generate-images/generate-summary.mjs +213 -0
- package/agents/generate-images/index.yaml +39 -0
- package/agents/generate-images/prepare-generation.mjs +286 -0
- package/agents/generate-images/prepare-image-generation.mjs +130 -0
- package/{prompts/detail/diagram/generate-image-system.md → agents/generate-images/prompts/system.md} +22 -56
- package/agents/generate-images/prompts/user.md +85 -0
- package/agents/generate-images/save-image-result.mjs +247 -0
- package/agents/generate-images/scan-image-slots.mjs +247 -0
- package/agents/localize/index.yaml +19 -42
- package/{prompts/translate → agents/localize/prompts}/translate-document.md +0 -139
- package/agents/localize/translate-documents/generate-summary.mjs +163 -0
- package/agents/localize/translate-documents/load-glossary.mjs +52 -0
- package/agents/localize/translate-documents/prepare-translation.mjs +249 -0
- package/agents/localize/translate-documents/save-translation.mjs +171 -0
- package/agents/localize/translate-documents/translate-document-to-language.mjs +209 -0
- package/agents/localize/translate-documents/translate-document.yaml +23 -0
- package/agents/localize/translate-documents/translate-to-languages.yaml +10 -0
- package/agents/localize/translate-images/check-image-translation.mjs +225 -0
- package/agents/localize/translate-images/detect-text/detect-and-update-shared.mjs +148 -0
- package/agents/localize/translate-images/detect-text/detect-image-text.yaml +44 -0
- package/agents/localize/translate-images/detect-text/detect-images-text.yaml +21 -0
- package/agents/localize/translate-images/detect-text/prompts/detect-image-text-system.md +43 -0
- package/agents/localize/translate-images/detect-text/prompts/detect-image-text-user.md +14 -0
- package/agents/localize/translate-images/detect-text/save-text-detection.mjs +105 -0
- package/agents/localize/translate-images/prepare-image-input.mjs +124 -0
- package/agents/localize/translate-images/save-image-translation.mjs +172 -0
- package/agents/localize/translate-images/scan-doc-images.mjs +165 -0
- package/agents/localize/translate-images/translate-doc-images.yaml +24 -0
- package/agents/localize/{translate-diagram.yaml → translate-images/translate-image.yaml} +25 -14
- package/agents/publish/ai/intent.md +182 -0
- package/agents/publish/check.mjs +107 -0
- package/agents/publish/index.yaml +9 -14
- package/agents/publish/publish-docs.mjs +81 -61
- package/agents/publish/translate-meta.mjs +79 -58
- package/agents/save-document/index.mjs +260 -0
- package/agents/structure-checker/index.mjs +307 -0
- package/agents/structure-checker/validate-structure.mjs +477 -0
- package/agents/update-image/analyze-feedback.yaml +37 -0
- package/agents/update-image/index.yaml +78 -0
- package/agents/update-image/load-existing-image.mjs +211 -0
- package/agents/update-image/prompts/analyze-feedback-system.md +43 -0
- package/agents/update-image/prompts/analyze-feedback-user.md +15 -0
- package/aigne.yaml +26 -139
- package/package.json +16 -48
- package/scripts/README.md +90 -0
- package/scripts/install.sh +86 -0
- package/scripts/uninstall.sh +52 -0
- package/skills/doc-smith/SKILL.md +285 -0
- package/skills/doc-smith/ai/intent/sources-improve.md +290 -0
- package/skills/doc-smith/references/changeset-guide.md +171 -0
- package/skills/doc-smith/references/document-content-guide.md +214 -0
- package/skills/doc-smith/references/document-structure-schema.md +138 -0
- package/skills/doc-smith/references/patch-guide.md +96 -0
- package/skills/doc-smith/references/structure-confirmation-guide.md +133 -0
- package/skills/doc-smith/references/structure-planning-guide.md +149 -0
- package/skills/doc-smith/references/update-workflow.md +108 -0
- package/skills/doc-smith/references/user-intent-guide.md +175 -0
- package/skills/doc-smith/references/workspace-initialization.md +376 -0
- package/skills/doc-smith-docs-detail/SKILL.md +356 -0
- package/skills/doc-smith-docs-detail/ai/intent.md +271 -0
- package/skills-entry/doc-smith/ai/intent.md +260 -0
- package/skills-entry/doc-smith/index.mjs +66 -0
- package/skills-entry/doc-smith/prompt.md +57 -0
- package/skills-entry/doc-smith/utils.mjs +27 -0
- package/skills-entry/doc-smith-docs-detail/batch.yaml +56 -0
- package/skills-entry/doc-smith-docs-detail/index.mjs +95 -0
- package/skills-entry/doc-smith-docs-detail/prompt.md +64 -0
- package/utils/afs-factory.mjs +183 -0
- package/utils/agent-constants.mjs +97 -0
- package/utils/{auth-utils.mjs → auth.mjs} +6 -9
- package/{agents/utils/update-branding.mjs → utils/branding.mjs} +3 -4
- package/utils/config.mjs +261 -0
- package/utils/constants.mjs +32 -0
- package/utils/deploy.mjs +3 -3
- package/utils/docs-converter.mjs +454 -0
- package/utils/docs.mjs +212 -0
- package/utils/document-paths.mjs +172 -0
- package/utils/files.mjs +74 -0
- package/utils/git.mjs +65 -0
- package/utils/{blocklet.mjs → http.mjs} +18 -0
- package/utils/image-slots.mjs +57 -0
- package/utils/image-utils.mjs +114 -0
- package/utils/project.mjs +95 -0
- package/utils/sources-path-resolver.mjs +76 -0
- package/utils/{upload-files.mjs → upload.mjs} +3 -3
- package/utils/workspace.mjs +371 -0
- 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/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/create/aggregate-document-structure.mjs +0 -21
- package/agents/create/analyze-diagram-type-llm.yaml +0 -159
- package/agents/create/analyze-diagram-type.mjs +0 -455
- package/agents/create/check-document-structure.yaml +0 -30
- package/agents/create/check-need-generate-structure.mjs +0 -138
- 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 -91
- package/agents/create/generate-structure.yaml +0 -106
- package/agents/create/index.yaml +0 -45
- package/agents/create/refine-document-structure.yaml +0 -12
- package/agents/create/replace-d2-with-image.mjs +0 -610
- 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 -139
- package/agents/create/utils/init-current-content.mjs +0 -34
- package/agents/create/utils/merge-document-structures.mjs +0 -36
- 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 -643
- package/agents/init/validate.mjs +0 -16
- package/agents/localize/choose-language.mjs +0 -107
- package/agents/localize/record-translation-history.mjs +0 -23
- package/agents/localize/save-doc-translation-or-skip.mjs +0 -18
- package/agents/localize/set-review-content.mjs +0 -58
- package/agents/localize/translate-document-wrapper.mjs +0 -34
- package/agents/localize/translate-document.yaml +0 -24
- package/agents/localize/translate-multilingual.yaml +0 -57
- package/agents/localize/translate-or-skip-diagram.mjs +0 -52
- 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 -454
- package/agents/prefs/index.mjs +0 -203
- 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-update-is-single.mjs +0 -53
- package/agents/update/document-tools/update-document-content.mjs +0 -303
- package/agents/update/generate-diagram.yaml +0 -80
- package/agents/update/generate-document.yaml +0 -70
- package/agents/update/handle-document-update.yaml +0 -103
- package/agents/update/index.yaml +0 -69
- package/agents/update/pre-check-generate-diagram.yaml +0 -44
- package/agents/update/save-and-translate-document.mjs +0 -80
- package/agents/update/update-document-detail.yaml +0 -71
- package/agents/update/update-single/update-single-document-detail.mjs +0 -322
- 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 -253
- package/agents/utils/analyze-structure-feedback-intent.yaml +0 -29
- package/agents/utils/check-detail-result.mjs +0 -51
- package/agents/utils/check-feedback-refiner.mjs +0 -81
- package/agents/utils/choose-docs.mjs +0 -251
- 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 -96
- 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 -133
- package/agents/utils/read-current-document-content.mjs +0 -46
- package/agents/utils/save-doc-translation.mjs +0 -30
- package/agents/utils/save-doc.mjs +0 -54
- package/agents/utils/save-output.mjs +0 -26
- package/agents/utils/save-sidebar.mjs +0 -38
- 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/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-user.md +0 -81
- 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/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/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 -205
- package/utils/debug.mjs +0 -3
- package/utils/delete-diagram-images.mjs +0 -99
- package/utils/diagram-version-utils.mjs +0 -14
- package/utils/docs-finder-utils.mjs +0 -548
- 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 -154
- package/utils/kroki-utils.mjs +0 -173
- package/utils/linter/index.mjs +0 -50
- package/utils/load-config.mjs +0 -78
- 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/sync-diagram-to-translations.mjs +0 -272
- package/utils/translate-diagram-images.mjs +0 -807
- package/utils/utils.mjs +0 -1354
- /package/{prompts/translate → agents/localize/prompts}/glossary.md +0 -0
|
@@ -0,0 +1,477 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { parse as yamlParse } from "yaml";
|
|
3
|
+
import { PATHS } from "../../utils/agent-constants.mjs";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Document Structure Validator Class
|
|
7
|
+
*/
|
|
8
|
+
class DocumentStructureValidator {
|
|
9
|
+
constructor(yamlContent) {
|
|
10
|
+
this.yamlContent = yamlContent;
|
|
11
|
+
this.errors = { fatal: [], fixable: [], warnings: [] };
|
|
12
|
+
this.pathSet = new Set();
|
|
13
|
+
this.documentCount = 0;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Execute complete validation
|
|
18
|
+
*/
|
|
19
|
+
async validate() {
|
|
20
|
+
// Layer 1: YAML parsing
|
|
21
|
+
try {
|
|
22
|
+
this.data = yamlParse(this.yamlContent);
|
|
23
|
+
} catch (e) {
|
|
24
|
+
this.errors.fatal.push({
|
|
25
|
+
type: "YAML_PARSE_ERROR",
|
|
26
|
+
message: `YAML parse error: ${e.message}`,
|
|
27
|
+
line: e.linePos?.start.line,
|
|
28
|
+
});
|
|
29
|
+
return this.getResult();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Layer 2: Schema structure
|
|
33
|
+
this.validateSchema();
|
|
34
|
+
|
|
35
|
+
// Layer 3: Document fields (recursive validation)
|
|
36
|
+
if (this.data.documents && Array.isArray(this.data.documents)) {
|
|
37
|
+
this.data.documents.forEach((doc, idx) => {
|
|
38
|
+
this.validateDocument(doc, `documents[${idx}]`, true);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Layer 4: Advanced rules
|
|
43
|
+
this.validateAdvancedRules();
|
|
44
|
+
|
|
45
|
+
return this.getResult();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Validate Schema structure
|
|
50
|
+
*/
|
|
51
|
+
validateSchema() {
|
|
52
|
+
// Check project field
|
|
53
|
+
if (!this.data.project) {
|
|
54
|
+
this.errors.fatal.push({
|
|
55
|
+
type: "MISSING_FIELD",
|
|
56
|
+
path: "project",
|
|
57
|
+
message: "Missing required field: project",
|
|
58
|
+
});
|
|
59
|
+
} else {
|
|
60
|
+
if (!this.data.project.title || typeof this.data.project.title !== "string") {
|
|
61
|
+
this.errors.fatal.push({
|
|
62
|
+
type: "MISSING_FIELD",
|
|
63
|
+
path: "project.title",
|
|
64
|
+
message: "Missing or invalid project.title",
|
|
65
|
+
suggestion: "Please add project title",
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
if (!this.data.project.description || typeof this.data.project.description !== "string") {
|
|
69
|
+
this.errors.fatal.push({
|
|
70
|
+
type: "MISSING_FIELD",
|
|
71
|
+
path: "project.description",
|
|
72
|
+
message: "Missing or invalid project.description",
|
|
73
|
+
suggestion: "Please add project description",
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Check documents field
|
|
79
|
+
if (!this.data.documents) {
|
|
80
|
+
this.errors.fatal.push({
|
|
81
|
+
type: "MISSING_FIELD",
|
|
82
|
+
path: "documents",
|
|
83
|
+
message: "Missing required field: documents",
|
|
84
|
+
});
|
|
85
|
+
} else if (!Array.isArray(this.data.documents)) {
|
|
86
|
+
this.errors.fatal.push({
|
|
87
|
+
type: "INVALID_TYPE",
|
|
88
|
+
path: "documents",
|
|
89
|
+
message: "documents must be an array",
|
|
90
|
+
});
|
|
91
|
+
} else if (this.data.documents.length === 0) {
|
|
92
|
+
this.errors.fatal.push({
|
|
93
|
+
type: "EMPTY_DOCUMENTS",
|
|
94
|
+
path: "documents",
|
|
95
|
+
message: "documents array cannot be empty",
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Recursively validate document
|
|
102
|
+
*/
|
|
103
|
+
validateDocument(doc, path, isTopLevel = false) {
|
|
104
|
+
this.documentCount++;
|
|
105
|
+
|
|
106
|
+
// Validate required fields
|
|
107
|
+
if (!doc.title || typeof doc.title !== "string") {
|
|
108
|
+
this.errors.fatal.push({
|
|
109
|
+
type: "MISSING_FIELD",
|
|
110
|
+
path: `${path}.title`,
|
|
111
|
+
message: "Missing or invalid title",
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (!doc.description || typeof doc.description !== "string") {
|
|
116
|
+
this.errors.fatal.push({
|
|
117
|
+
type: "MISSING_FIELD",
|
|
118
|
+
path: `${path}.description`,
|
|
119
|
+
message: "Missing or invalid description",
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Validate path
|
|
124
|
+
if (!doc.path) {
|
|
125
|
+
this.errors.fatal.push({
|
|
126
|
+
type: "MISSING_FIELD",
|
|
127
|
+
path: `${path}.path`,
|
|
128
|
+
message: "Missing path field",
|
|
129
|
+
});
|
|
130
|
+
} else {
|
|
131
|
+
const pathErrors = this.validatePath(doc.path, path);
|
|
132
|
+
this.errors.fixable.push(...pathErrors);
|
|
133
|
+
|
|
134
|
+
// Check path should not end with .md (this is a FATAL error)
|
|
135
|
+
if (doc.path.endsWith(".md")) {
|
|
136
|
+
this.errors.fatal.push({
|
|
137
|
+
type: "PATH_FORMAT",
|
|
138
|
+
path: `${path}.path`,
|
|
139
|
+
current: doc.path,
|
|
140
|
+
expected: doc.path.slice(0, -3),
|
|
141
|
+
message: "path should not end with .md (should point to folder)",
|
|
142
|
+
suggestion: `Change path to "${doc.path.slice(0, -3)}"`,
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// Check path uniqueness
|
|
147
|
+
if (this.pathSet.has(doc.path)) {
|
|
148
|
+
this.errors.fatal.push({
|
|
149
|
+
type: "DUPLICATE_PATH",
|
|
150
|
+
path: `${path}.path`,
|
|
151
|
+
value: doc.path,
|
|
152
|
+
message: `Duplicate path: ${doc.path}`,
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
this.pathSet.add(doc.path);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// Validate sourcePaths
|
|
159
|
+
if (doc.sourcePaths === undefined) {
|
|
160
|
+
this.errors.fatal.push({
|
|
161
|
+
type: "MISSING_FIELD",
|
|
162
|
+
path: `${path}.sourcePaths`,
|
|
163
|
+
message: "Missing sourcePaths field",
|
|
164
|
+
});
|
|
165
|
+
} else {
|
|
166
|
+
const sourceErrors = this.validateSourcePaths(doc.sourcePaths, path);
|
|
167
|
+
this.errors.fixable.push(...sourceErrors.fixable);
|
|
168
|
+
this.errors.warnings.push(...sourceErrors.warnings);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// Validate icon
|
|
172
|
+
const iconErrors = this.validateIcon(doc.icon, isTopLevel, path, doc.title);
|
|
173
|
+
this.errors.fixable.push(...iconErrors.fixable);
|
|
174
|
+
this.errors.fatal.push(...iconErrors.fatal);
|
|
175
|
+
|
|
176
|
+
// Recursively validate children
|
|
177
|
+
if (doc.children) {
|
|
178
|
+
if (!Array.isArray(doc.children)) {
|
|
179
|
+
this.errors.fatal.push({
|
|
180
|
+
type: "INVALID_TYPE",
|
|
181
|
+
path: `${path}.children`,
|
|
182
|
+
message: "children must be an array",
|
|
183
|
+
});
|
|
184
|
+
} else {
|
|
185
|
+
doc.children.forEach((child, idx) => {
|
|
186
|
+
this.validateDocument(child, `${path}.children[${idx}]`, false);
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Validate path format
|
|
194
|
+
*/
|
|
195
|
+
validatePath(path, location) {
|
|
196
|
+
const errors = [];
|
|
197
|
+
|
|
198
|
+
if (typeof path !== "string") {
|
|
199
|
+
return errors;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
if (!path.startsWith("/")) {
|
|
203
|
+
errors.push({
|
|
204
|
+
type: "PATH_FORMAT",
|
|
205
|
+
path: `${location}.path`,
|
|
206
|
+
current: path,
|
|
207
|
+
expected: `/${path}`,
|
|
208
|
+
fix: "add_leading_slash",
|
|
209
|
+
message: "path must start with /",
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
return errors;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Validate sourcePaths
|
|
218
|
+
*/
|
|
219
|
+
validateSourcePaths(sourcePaths, location) {
|
|
220
|
+
const errors = { fixable: [], warnings: [] };
|
|
221
|
+
|
|
222
|
+
if (!Array.isArray(sourcePaths)) {
|
|
223
|
+
errors.fixable.push({
|
|
224
|
+
type: "INVALID_TYPE",
|
|
225
|
+
path: `${location}.sourcePaths`,
|
|
226
|
+
current: typeof sourcePaths,
|
|
227
|
+
expected: "array",
|
|
228
|
+
fix: "convert_to_array",
|
|
229
|
+
message: "sourcePaths must be an array",
|
|
230
|
+
});
|
|
231
|
+
return errors;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
if (sourcePaths.length === 0) {
|
|
235
|
+
errors.warnings.push({
|
|
236
|
+
type: "EMPTY_SOURCES",
|
|
237
|
+
path: `${location}.sourcePaths`,
|
|
238
|
+
message: "sourcePaths is empty array - no source files referenced",
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
sourcePaths.forEach((srcPath, idx) => {
|
|
243
|
+
if (typeof srcPath !== "string") {
|
|
244
|
+
errors.fixable.push({
|
|
245
|
+
type: "INVALID_TYPE",
|
|
246
|
+
path: `${location}.sourcePaths[${idx}]`,
|
|
247
|
+
message: "Source file path must be a string",
|
|
248
|
+
});
|
|
249
|
+
} else if (srcPath.startsWith("workspace:")) {
|
|
250
|
+
errors.fixable.push({
|
|
251
|
+
type: "SOURCE_PATH_PREFIX",
|
|
252
|
+
path: `${location}.sourcePaths[${idx}]`,
|
|
253
|
+
current: srcPath,
|
|
254
|
+
expected: srcPath.replace("workspace:", ""),
|
|
255
|
+
fix: "remove_workspace_prefix",
|
|
256
|
+
message: "Remove workspace: prefix",
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
return errors;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Validate icon
|
|
266
|
+
*/
|
|
267
|
+
validateIcon(icon, isTopLevel, location, docTitle) {
|
|
268
|
+
const errors = { fixable: [], fatal: [] };
|
|
269
|
+
|
|
270
|
+
if (isTopLevel) {
|
|
271
|
+
// Top-level documents must have icon
|
|
272
|
+
if (!icon) {
|
|
273
|
+
errors.fatal.push({
|
|
274
|
+
type: "MISSING_ICON",
|
|
275
|
+
path: `${location}.icon`,
|
|
276
|
+
docTitle: docTitle || "Unknown document",
|
|
277
|
+
message: `Top-level document "${docTitle || "Unknown document"}" missing icon`,
|
|
278
|
+
suggestion: `Please select an appropriate icon based on document content, common options:
|
|
279
|
+
- lucide:book-open (documentation, overview)
|
|
280
|
+
- lucide:rocket (quick start, getting started)
|
|
281
|
+
- lucide:code (API, code reference)
|
|
282
|
+
- lucide:settings (configuration, settings)
|
|
283
|
+
- lucide:file-text (guide, tutorial)
|
|
284
|
+
- lucide:package (component, module)
|
|
285
|
+
More icons at: https://lucide.dev/icons`,
|
|
286
|
+
});
|
|
287
|
+
} else if (!icon.startsWith("lucide:")) {
|
|
288
|
+
errors.fixable.push({
|
|
289
|
+
type: "ICON_FORMAT",
|
|
290
|
+
path: `${location}.icon`,
|
|
291
|
+
current: icon,
|
|
292
|
+
expected: `lucide:${icon}`,
|
|
293
|
+
fix: "add_lucide_prefix",
|
|
294
|
+
message: "icon must start with lucide:",
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
} else {
|
|
298
|
+
// Child documents should not have icon
|
|
299
|
+
if (icon) {
|
|
300
|
+
errors.fixable.push({
|
|
301
|
+
type: "EXTRA_ICON",
|
|
302
|
+
path: `${location}.icon`,
|
|
303
|
+
current: icon,
|
|
304
|
+
fix: "remove_icon",
|
|
305
|
+
message: "Child documents should not contain icon field",
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
return errors;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* Advanced rules validation
|
|
315
|
+
*/
|
|
316
|
+
validateAdvancedRules() {
|
|
317
|
+
// Check nesting depth
|
|
318
|
+
const maxDepth = this.getMaxDepth(this.data.documents);
|
|
319
|
+
if (maxDepth > 3) {
|
|
320
|
+
this.errors.warnings.push({
|
|
321
|
+
type: "DEEP_NESTING",
|
|
322
|
+
message: `Document structure nested ${maxDepth} levels deep (recommended ≤3 levels)`,
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* Get maximum nesting depth
|
|
329
|
+
*/
|
|
330
|
+
getMaxDepth(docs, currentDepth = 1) {
|
|
331
|
+
if (!docs || !Array.isArray(docs) || docs.length === 0) {
|
|
332
|
+
return currentDepth;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
let maxDepth = currentDepth;
|
|
336
|
+
for (const doc of docs) {
|
|
337
|
+
if (doc.children && Array.isArray(doc.children) && doc.children.length > 0) {
|
|
338
|
+
const childDepth = this.getMaxDepth(doc.children, currentDepth + 1);
|
|
339
|
+
maxDepth = Math.max(maxDepth, childDepth);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
return maxDepth;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* Get validation result
|
|
347
|
+
*/
|
|
348
|
+
getResult() {
|
|
349
|
+
const hasErrors = this.errors.fatal.length > 0 || this.errors.fixable.length > 0;
|
|
350
|
+
|
|
351
|
+
return {
|
|
352
|
+
valid: !hasErrors,
|
|
353
|
+
errors: this.errors,
|
|
354
|
+
summary: {
|
|
355
|
+
totalDocuments: this.documentCount,
|
|
356
|
+
totalErrors: this.errors.fatal.length + this.errors.fixable.length,
|
|
357
|
+
fatalCount: this.errors.fatal.length,
|
|
358
|
+
fixableCount: this.errors.fixable.length,
|
|
359
|
+
warningCount: this.errors.warnings.length,
|
|
360
|
+
},
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* Format output
|
|
367
|
+
*/
|
|
368
|
+
function formatOutput(result) {
|
|
369
|
+
let output = "";
|
|
370
|
+
|
|
371
|
+
if (result.valid) {
|
|
372
|
+
output += "✅ PASS: document-structure.yaml is valid\n";
|
|
373
|
+
output += ` Documents: ${result.summary.totalDocuments}\n`;
|
|
374
|
+
if (result.summary.warningCount > 0) {
|
|
375
|
+
output += ` Warnings: ${result.summary.warningCount}\n`;
|
|
376
|
+
}
|
|
377
|
+
return output;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
output += "❌ FAIL: document-structure.yaml has errors\n\n";
|
|
381
|
+
output += "Summary:\n";
|
|
382
|
+
output += ` Total Documents: ${result.summary.totalDocuments}\n`;
|
|
383
|
+
output += ` Fatal Errors: ${result.summary.fatalCount}\n`;
|
|
384
|
+
output += ` Fixable Errors: ${result.summary.fixableCount}\n`;
|
|
385
|
+
output += ` Warnings: ${result.summary.warningCount}\n\n`;
|
|
386
|
+
|
|
387
|
+
// FATAL errors
|
|
388
|
+
if (result.errors.fatal.length > 0) {
|
|
389
|
+
output += "FATAL ERRORS (must fix before proceeding):\n\n";
|
|
390
|
+
result.errors.fatal.forEach((err, idx) => {
|
|
391
|
+
output += `${idx + 1}. ${err.type} at ${err.path || "unknown"}\n`;
|
|
392
|
+
output += ` ${err.message}\n`;
|
|
393
|
+
if (err.suggestion) {
|
|
394
|
+
output += ` Suggestion: ${err.suggestion}\n`;
|
|
395
|
+
}
|
|
396
|
+
output += "\n";
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
// FIXABLE errors
|
|
401
|
+
if (result.errors.fixable.length > 0) {
|
|
402
|
+
output += "FIXABLE ERRORS (can be auto-corrected):\n\n";
|
|
403
|
+
result.errors.fixable.forEach((err, idx) => {
|
|
404
|
+
output += `${idx + 1}. ${err.type} at ${err.path}\n`;
|
|
405
|
+
output += ` ${err.message}\n`;
|
|
406
|
+
if (err.current) output += ` Current: ${err.current}\n`;
|
|
407
|
+
if (err.expected) output += ` Expected: ${err.expected}\n`;
|
|
408
|
+
if (err.fix) output += ` Fix: ${err.fix}\n`;
|
|
409
|
+
output += "\n";
|
|
410
|
+
});
|
|
411
|
+
output += "Call the fix tool to auto-correct these errors:\n";
|
|
412
|
+
output += " Tool: fix_yaml_structure\n";
|
|
413
|
+
output += ' Parameters: { yamlPath: "planning/document-structure.yaml" }\n\n';
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
// WARNING
|
|
417
|
+
if (result.errors.warnings.length > 0) {
|
|
418
|
+
output += "WARNINGS (informational):\n\n";
|
|
419
|
+
result.errors.warnings.forEach((warn, idx) => {
|
|
420
|
+
output += `${idx + 1}. ${warn.type || "WARNING"}: ${warn.message}\n`;
|
|
421
|
+
});
|
|
422
|
+
output += "\n";
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
return output;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
/**
|
|
429
|
+
* Main function - Function Agent
|
|
430
|
+
* @param {Object} params
|
|
431
|
+
* @param {string} params.yamlPath - YAML file path
|
|
432
|
+
* @returns {Promise<Object>} - Validation result
|
|
433
|
+
*/
|
|
434
|
+
export default async function validateYamlStructure({ yamlPath = PATHS.DOCUMENT_STRUCTURE }) {
|
|
435
|
+
try {
|
|
436
|
+
// Read YAML file
|
|
437
|
+
const content = await readFile(yamlPath, "utf8");
|
|
438
|
+
|
|
439
|
+
// Execute validation
|
|
440
|
+
const validator = new DocumentStructureValidator(content);
|
|
441
|
+
const result = await validator.validate();
|
|
442
|
+
|
|
443
|
+
// Format output
|
|
444
|
+
const formattedOutput = formatOutput(result);
|
|
445
|
+
|
|
446
|
+
return {
|
|
447
|
+
valid: result.valid,
|
|
448
|
+
errors: result.errors,
|
|
449
|
+
summary: result.summary,
|
|
450
|
+
message: formattedOutput,
|
|
451
|
+
};
|
|
452
|
+
} catch (error) {
|
|
453
|
+
if (error.code === "ENOENT") {
|
|
454
|
+
return {
|
|
455
|
+
valid: false,
|
|
456
|
+
message: `❌ FAIL: File not found: ${yamlPath}`,
|
|
457
|
+
};
|
|
458
|
+
}
|
|
459
|
+
return {
|
|
460
|
+
valid: false,
|
|
461
|
+
message: `❌ FAIL: ${error.message}`,
|
|
462
|
+
};
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
validateYamlStructure.description = "Validate document-structure.yaml format and schema compliance";
|
|
467
|
+
|
|
468
|
+
validateYamlStructure.input_schema = {
|
|
469
|
+
type: "object",
|
|
470
|
+
properties: {
|
|
471
|
+
yamlPath: {
|
|
472
|
+
type: "string",
|
|
473
|
+
description: "Path to the YAML file to validate (relative to workspace root)",
|
|
474
|
+
default: "planning/document-structure.yaml",
|
|
475
|
+
},
|
|
476
|
+
},
|
|
477
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
name: analyzeFeedback
|
|
2
|
+
description: Analyze user feedback and extract image editing intent information (e.g., aspect ratio modification)
|
|
3
|
+
model: gemini-2.5-flash
|
|
4
|
+
instructions:
|
|
5
|
+
- role: system
|
|
6
|
+
url: ./prompts/analyze-feedback-system.md
|
|
7
|
+
- role: user
|
|
8
|
+
url: ./prompts/analyze-feedback-user.md
|
|
9
|
+
|
|
10
|
+
include_input_in_output: true
|
|
11
|
+
|
|
12
|
+
input_schema:
|
|
13
|
+
type: object
|
|
14
|
+
properties:
|
|
15
|
+
feedback:
|
|
16
|
+
type: string
|
|
17
|
+
description: User feedback (natural language)
|
|
18
|
+
currentAspectRatio:
|
|
19
|
+
type: string
|
|
20
|
+
description: Current aspect ratio of the image
|
|
21
|
+
default: "4:3"
|
|
22
|
+
required:
|
|
23
|
+
- feedback
|
|
24
|
+
|
|
25
|
+
output_schema:
|
|
26
|
+
type: object
|
|
27
|
+
properties:
|
|
28
|
+
hasRatioChange:
|
|
29
|
+
type: boolean
|
|
30
|
+
description: Whether aspect ratio modification intent was detected
|
|
31
|
+
aspectRatio:
|
|
32
|
+
type: string
|
|
33
|
+
description: Final aspect ratio to use (new value if modified, otherwise current value)
|
|
34
|
+
enum: ["1:1", "5:4", "4:3", "3:2", "16:9", "21:9"]
|
|
35
|
+
required:
|
|
36
|
+
- hasRatioChange
|
|
37
|
+
- aspectRatio
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
type: team
|
|
2
|
+
name: updateImage
|
|
3
|
+
description: |
|
|
4
|
+
Edit already generated images based on user feedback, supports:
|
|
5
|
+
- Modify image aspect ratio
|
|
6
|
+
- Adjust image content based on natural language feedback
|
|
7
|
+
|
|
8
|
+
skills:
|
|
9
|
+
# Step 1: Load existing image and slot information
|
|
10
|
+
- url: ./load-existing-image.mjs
|
|
11
|
+
|
|
12
|
+
# Step 2: Analyze user feedback, extract ratio modification intent (using LLM)
|
|
13
|
+
- url: ./analyze-feedback.yaml
|
|
14
|
+
|
|
15
|
+
# Step 3: Prepare image generation parameters
|
|
16
|
+
- type: transform
|
|
17
|
+
jsonata: |
|
|
18
|
+
$merge([
|
|
19
|
+
$,
|
|
20
|
+
{
|
|
21
|
+
"id": slotId,
|
|
22
|
+
"documentContent": content,
|
|
23
|
+
"size": "2K",
|
|
24
|
+
"useImageToImage": true,
|
|
25
|
+
"documents": [{
|
|
26
|
+
"path": doc,
|
|
27
|
+
"hash": hash,
|
|
28
|
+
"content": content
|
|
29
|
+
}],
|
|
30
|
+
"isUpdate": true
|
|
31
|
+
}
|
|
32
|
+
])
|
|
33
|
+
|
|
34
|
+
# Step 4: Generate new image using image-to-image mode
|
|
35
|
+
- url: ../generate-images/generate-image.yaml
|
|
36
|
+
|
|
37
|
+
# Step 5: Save the updated image
|
|
38
|
+
- url: ../generate-images/save-image-result.mjs
|
|
39
|
+
|
|
40
|
+
input_schema:
|
|
41
|
+
type: object
|
|
42
|
+
properties:
|
|
43
|
+
doc:
|
|
44
|
+
type: string
|
|
45
|
+
description: Document path (e.g., "overview" or "/overview")
|
|
46
|
+
slotId:
|
|
47
|
+
type: string
|
|
48
|
+
description: Image slot id
|
|
49
|
+
feedback:
|
|
50
|
+
type: string
|
|
51
|
+
description: |
|
|
52
|
+
User feedback (natural language), can include:
|
|
53
|
+
- Aspect ratio modification (e.g., "change to 16:9")
|
|
54
|
+
- Image content adjustment (e.g., "use a more modern style")
|
|
55
|
+
required:
|
|
56
|
+
- doc
|
|
57
|
+
- slotId
|
|
58
|
+
- feedback
|
|
59
|
+
|
|
60
|
+
output_schema:
|
|
61
|
+
type: object
|
|
62
|
+
properties:
|
|
63
|
+
success:
|
|
64
|
+
type: boolean
|
|
65
|
+
description: Whether operation succeeded
|
|
66
|
+
key:
|
|
67
|
+
type: string
|
|
68
|
+
description: Image key
|
|
69
|
+
imagePath:
|
|
70
|
+
type: string
|
|
71
|
+
description: Path of the updated image
|
|
72
|
+
message:
|
|
73
|
+
type: string
|
|
74
|
+
description: Operation result description
|
|
75
|
+
required:
|
|
76
|
+
- success
|
|
77
|
+
|
|
78
|
+
mode: sequential
|