@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,371 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { access, readFile, mkdir, writeFile, appendFile } from "node:fs/promises";
|
|
3
|
+
import { constants } from "node:fs";
|
|
4
|
+
import { exec } from "node:child_process";
|
|
5
|
+
import { promisify } from "node:util";
|
|
6
|
+
import { join } from "node:path";
|
|
7
|
+
import { parse as yamlParse, stringify as yamlStringify } from "yaml";
|
|
8
|
+
|
|
9
|
+
const execAsync = promisify(exec);
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Workspace mode constants
|
|
13
|
+
*/
|
|
14
|
+
export const WORKSPACE_MODES = {
|
|
15
|
+
PROJECT: "project",
|
|
16
|
+
STANDALONE: "standalone",
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Directory structure constants
|
|
21
|
+
*/
|
|
22
|
+
export const AIGNE_DIR = ".aigne";
|
|
23
|
+
export const DOC_SMITH_DIR = ".aigne/doc-smith";
|
|
24
|
+
export const SOURCES_DIR = "sources";
|
|
25
|
+
export const WORKSPACE_SUBDIRS = ["intent", "planning", "docs"];
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* .gitignore content for doc-smith workspace
|
|
29
|
+
*/
|
|
30
|
+
export const GITIGNORE_CONTENT = `\
|
|
31
|
+
# Ignore sources directory
|
|
32
|
+
sources/
|
|
33
|
+
|
|
34
|
+
# Ignore temporary files
|
|
35
|
+
.tmp/
|
|
36
|
+
.temp/
|
|
37
|
+
temp/
|
|
38
|
+
`;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Check if path exists
|
|
42
|
+
* @param {string} path - Path
|
|
43
|
+
* @returns {Promise<boolean>}
|
|
44
|
+
*/
|
|
45
|
+
export async function pathExists(path) {
|
|
46
|
+
try {
|
|
47
|
+
await access(path, constants.F_OK);
|
|
48
|
+
return true;
|
|
49
|
+
} catch {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Check if path exists (synchronous version)
|
|
56
|
+
* @param {string} path - Path
|
|
57
|
+
* @returns {boolean}
|
|
58
|
+
*/
|
|
59
|
+
export function pathExistsSync(path) {
|
|
60
|
+
return existsSync(path);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Check if inside a git repository (supports subdirectories)
|
|
65
|
+
* @param {string} cwd - Working directory
|
|
66
|
+
* @returns {Promise<boolean>}
|
|
67
|
+
*/
|
|
68
|
+
export async function isGitRepo(cwd = ".") {
|
|
69
|
+
const result = await gitExec("rev-parse --is-inside-work-tree", cwd);
|
|
70
|
+
return result.success && result.output === "true";
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Execute git command
|
|
75
|
+
* @param {string} command - git command (without git prefix)
|
|
76
|
+
* @param {string} cwd - Working directory
|
|
77
|
+
* @returns {Promise<{success: boolean, output?: string, error?: string}>}
|
|
78
|
+
*/
|
|
79
|
+
export async function gitExec(command, cwd = ".") {
|
|
80
|
+
try {
|
|
81
|
+
const { stdout } = await execAsync(`git ${command}`, { cwd });
|
|
82
|
+
return { success: true, output: stdout.trim() };
|
|
83
|
+
} catch (error) {
|
|
84
|
+
return { success: false, error: error.message };
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Get git repository info (url, branch, commit)
|
|
90
|
+
* @param {string} cwd - Working directory
|
|
91
|
+
* @returns {Promise<{ url: string, branch: string, commit: string }>}
|
|
92
|
+
*/
|
|
93
|
+
export async function getGitInfo(cwd = ".") {
|
|
94
|
+
// Get remote repository URL (prefer origin)
|
|
95
|
+
let url = "";
|
|
96
|
+
const urlResult = await gitExec("remote get-url origin", cwd);
|
|
97
|
+
if (urlResult.success) {
|
|
98
|
+
url = urlResult.output;
|
|
99
|
+
} else {
|
|
100
|
+
// Try to get the first available remote
|
|
101
|
+
const remotesResult = await gitExec("remote", cwd);
|
|
102
|
+
if (remotesResult.success && remotesResult.output) {
|
|
103
|
+
const firstRemote = remotesResult.output.split("\n")[0];
|
|
104
|
+
const fallbackResult = await gitExec(`remote get-url ${firstRemote}`, cwd);
|
|
105
|
+
if (fallbackResult.success) {
|
|
106
|
+
url = fallbackResult.output;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Get current branch name
|
|
112
|
+
let branch = "";
|
|
113
|
+
const branchResult = await gitExec("branch --show-current", cwd);
|
|
114
|
+
if (branchResult.success) {
|
|
115
|
+
branch = branchResult.output;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// Get current commit hash (short format)
|
|
119
|
+
let commit = "";
|
|
120
|
+
const commitResult = await gitExec("rev-parse --short HEAD", cwd);
|
|
121
|
+
if (commitResult.success) {
|
|
122
|
+
commit = commitResult.output;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return { url, branch, commit };
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Get git repository root directory
|
|
130
|
+
* @param {string} cwd - Starting directory
|
|
131
|
+
* @returns {Promise<string | null>}
|
|
132
|
+
*/
|
|
133
|
+
export async function getGitRoot(cwd = ".") {
|
|
134
|
+
const result = await gitExec("rev-parse --show-toplevel", cwd);
|
|
135
|
+
if (result.success) {
|
|
136
|
+
return result.output;
|
|
137
|
+
}
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Add ignore rule to .gitignore (if not exists)
|
|
143
|
+
* @param {string} gitRoot - Git repository root directory
|
|
144
|
+
* @param {string} pattern - Pattern to ignore
|
|
145
|
+
* @returns {Promise<boolean>} Whether addition was successful
|
|
146
|
+
*/
|
|
147
|
+
export async function addToGitignore(gitRoot, pattern) {
|
|
148
|
+
const gitignorePath = join(gitRoot, ".gitignore");
|
|
149
|
+
|
|
150
|
+
try {
|
|
151
|
+
// Check if .gitignore exists
|
|
152
|
+
if (await pathExists(gitignorePath)) {
|
|
153
|
+
// Read existing content, check if pattern already exists
|
|
154
|
+
const content = await readFile(gitignorePath, "utf8");
|
|
155
|
+
if (content.includes(pattern)) {
|
|
156
|
+
return true; // Already exists, no need to add
|
|
157
|
+
}
|
|
158
|
+
// Append to end of file (ensure newline)
|
|
159
|
+
const prefix = content.endsWith("\n") ? "" : "\n";
|
|
160
|
+
await appendFile(gitignorePath, `${prefix}${pattern}\n`, "utf8");
|
|
161
|
+
} else {
|
|
162
|
+
// Create new .gitignore
|
|
163
|
+
await writeFile(gitignorePath, `${pattern}\n`, "utf8");
|
|
164
|
+
}
|
|
165
|
+
return true;
|
|
166
|
+
} catch {
|
|
167
|
+
return false;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Detect workspace mode (synchronous version)
|
|
173
|
+
* Used for scenarios requiring synchronous judgment at module load time
|
|
174
|
+
* @returns {{ mode: string, workspaceBase: string }}
|
|
175
|
+
*/
|
|
176
|
+
export function detectWorkspaceModeSync() {
|
|
177
|
+
const cwd = process.cwd();
|
|
178
|
+
const projectConfigPath = join(cwd, DOC_SMITH_DIR, "config.yaml");
|
|
179
|
+
|
|
180
|
+
if (existsSync(projectConfigPath)) {
|
|
181
|
+
return {
|
|
182
|
+
mode: WORKSPACE_MODES.PROJECT,
|
|
183
|
+
workspaceBase: join(cwd, DOC_SMITH_DIR),
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
return {
|
|
188
|
+
mode: WORKSPACE_MODES.STANDALONE,
|
|
189
|
+
workspaceBase: cwd,
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Detect workspace mode (asynchronous version)
|
|
195
|
+
* @returns {Promise<{ mode: string, configPath: string, workspacePath: string } | null>}
|
|
196
|
+
*/
|
|
197
|
+
export async function detectWorkspaceMode() {
|
|
198
|
+
const configInDocSmith = join(DOC_SMITH_DIR, "config.yaml");
|
|
199
|
+
const configInRoot = "config.yaml";
|
|
200
|
+
|
|
201
|
+
if (await pathExists(configInDocSmith)) {
|
|
202
|
+
return {
|
|
203
|
+
mode: WORKSPACE_MODES.PROJECT,
|
|
204
|
+
configPath: configInDocSmith,
|
|
205
|
+
workspacePath: `./${DOC_SMITH_DIR}`,
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
if (await pathExists(configInRoot)) {
|
|
210
|
+
return {
|
|
211
|
+
mode: WORKSPACE_MODES.STANDALONE,
|
|
212
|
+
configPath: configInRoot,
|
|
213
|
+
workspacePath: ".",
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
return null;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Load and parse config.yaml
|
|
222
|
+
* @param {string} configPath - Config file path
|
|
223
|
+
* @returns {Promise<Object | null>}
|
|
224
|
+
*/
|
|
225
|
+
export async function loadConfig(configPath) {
|
|
226
|
+
try {
|
|
227
|
+
const content = await readFile(configPath, "utf8");
|
|
228
|
+
return yamlParse(content);
|
|
229
|
+
} catch {
|
|
230
|
+
return null;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Generate config.yaml content
|
|
236
|
+
* @param {{ mode: string, sources: Array }} options - Configuration options
|
|
237
|
+
* @returns {string}
|
|
238
|
+
*/
|
|
239
|
+
export function generateConfig(options) {
|
|
240
|
+
const { mode, sources } = options;
|
|
241
|
+
return yamlStringify({ mode, sources });
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Create directory structure
|
|
246
|
+
* @param {string} baseDir - Base directory
|
|
247
|
+
* @param {boolean} includeSources - Whether to create sources directory
|
|
248
|
+
*/
|
|
249
|
+
export async function createDirectoryStructure(baseDir, includeSources = false) {
|
|
250
|
+
await mkdir(baseDir, { recursive: true });
|
|
251
|
+
|
|
252
|
+
for (const dir of WORKSPACE_SUBDIRS) {
|
|
253
|
+
await mkdir(join(baseDir, dir), { recursive: true });
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
if (includeSources) {
|
|
257
|
+
await mkdir(join(baseDir, SOURCES_DIR), { recursive: true });
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Initialize project mode workspace
|
|
263
|
+
* Create .aigne/doc-smith/ directory structure under project root
|
|
264
|
+
* @returns {Promise<{ mode: string, configPath: string, workspacePath: string }>}
|
|
265
|
+
*/
|
|
266
|
+
export async function initProjectMode() {
|
|
267
|
+
console.log("\n📂 Initializing doc-smith workspace...\n");
|
|
268
|
+
|
|
269
|
+
// Create .aigne/doc-smith directory
|
|
270
|
+
await mkdir(DOC_SMITH_DIR, { recursive: true });
|
|
271
|
+
|
|
272
|
+
// Initialize git in .aigne/doc-smith
|
|
273
|
+
await gitExec("init", DOC_SMITH_DIR);
|
|
274
|
+
|
|
275
|
+
// Create directory structure
|
|
276
|
+
await createDirectoryStructure(DOC_SMITH_DIR);
|
|
277
|
+
|
|
278
|
+
// Create .gitignore
|
|
279
|
+
await writeFile(join(DOC_SMITH_DIR, ".gitignore"), GITIGNORE_CONTENT, "utf8");
|
|
280
|
+
|
|
281
|
+
// Get project git info
|
|
282
|
+
const gitInfo = await getGitInfo(".");
|
|
283
|
+
|
|
284
|
+
// Generate config.yaml (include git info, consistent with git-clone format)
|
|
285
|
+
const sourceConfig = {
|
|
286
|
+
type: "local-path",
|
|
287
|
+
path: "../../",
|
|
288
|
+
};
|
|
289
|
+
|
|
290
|
+
// Add git info at root level (consistent with git-clone format)
|
|
291
|
+
if (gitInfo.url) sourceConfig.url = gitInfo.url;
|
|
292
|
+
if (gitInfo.branch) sourceConfig.branch = gitInfo.branch;
|
|
293
|
+
if (gitInfo.commit) sourceConfig.commit = gitInfo.commit;
|
|
294
|
+
|
|
295
|
+
const configContent = generateConfig({
|
|
296
|
+
mode: WORKSPACE_MODES.PROJECT,
|
|
297
|
+
sources: [sourceConfig],
|
|
298
|
+
});
|
|
299
|
+
await writeFile(join(DOC_SMITH_DIR, "config.yaml"), configContent, "utf8");
|
|
300
|
+
|
|
301
|
+
// Create initial commit in doc-smith repo
|
|
302
|
+
await gitExec("add .", DOC_SMITH_DIR);
|
|
303
|
+
const commitResult = await gitExec(
|
|
304
|
+
'commit -m "Initial commit: doc-smith workspace"',
|
|
305
|
+
DOC_SMITH_DIR,
|
|
306
|
+
);
|
|
307
|
+
if (commitResult.success) {
|
|
308
|
+
console.log(`✅ Created initial commit in ${DOC_SMITH_DIR}`);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
console.log("✅ Workspace initialized successfully!\n");
|
|
312
|
+
|
|
313
|
+
return {
|
|
314
|
+
mode: WORKSPACE_MODES.PROJECT,
|
|
315
|
+
configPath: join(DOC_SMITH_DIR, "config.yaml"),
|
|
316
|
+
workspacePath: `./${DOC_SMITH_DIR}`,
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* Initialize standalone mode workspace
|
|
322
|
+
* Create workspace structure in current directory
|
|
323
|
+
* @returns {Promise<{ mode: string, configPath: string, workspacePath: string }>}
|
|
324
|
+
*/
|
|
325
|
+
export async function initStandaloneMode() {
|
|
326
|
+
console.log("\n📂 Initializing doc-smith workspace...\n");
|
|
327
|
+
|
|
328
|
+
// Initialize git in current directory
|
|
329
|
+
await gitExec("init");
|
|
330
|
+
|
|
331
|
+
// Create .gitignore
|
|
332
|
+
await writeFile(".gitignore", GITIGNORE_CONTENT, "utf8");
|
|
333
|
+
|
|
334
|
+
// Create directory structure (including sources/)
|
|
335
|
+
await createDirectoryStructure(".", true);
|
|
336
|
+
|
|
337
|
+
// Generate config.yaml (sources empty, to be added during conversation)
|
|
338
|
+
const configContent = generateConfig({
|
|
339
|
+
mode: WORKSPACE_MODES.STANDALONE,
|
|
340
|
+
sources: [],
|
|
341
|
+
});
|
|
342
|
+
await writeFile("config.yaml", configContent, "utf8");
|
|
343
|
+
|
|
344
|
+
console.log("✅ Workspace initialized successfully!\n");
|
|
345
|
+
|
|
346
|
+
return {
|
|
347
|
+
mode: WORKSPACE_MODES.STANDALONE,
|
|
348
|
+
configPath: "config.yaml",
|
|
349
|
+
workspacePath: ".",
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* Detect directory state and initialize workspace when needed
|
|
355
|
+
* @returns {Promise<{ mode: string, configPath: string, workspacePath: string }>}
|
|
356
|
+
*/
|
|
357
|
+
export async function detectAndInitialize() {
|
|
358
|
+
// Check if already initialized
|
|
359
|
+
const existing = await detectWorkspaceMode();
|
|
360
|
+
if (existing) {
|
|
361
|
+
return existing;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
// Check if inside git repository (project mode)
|
|
365
|
+
if (await isGitRepo()) {
|
|
366
|
+
return await initProjectMode();
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
// Otherwise, initialize as standalone mode
|
|
370
|
+
return await initStandaloneMode();
|
|
371
|
+
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
You are a professional document generation assistant that helps users create, modify, and manage documentation through interactive chat. Your primary role is to understand user requirements and intelligently call upon various specialized skills to complete documentation tasks efficiently.
|
|
2
|
-
|
|
3
|
-
Core Capabilities:
|
|
4
|
-
- Generate comprehensive documentation from user inputs and specifications
|
|
5
|
-
- Regenerate and refine document details based on feedback
|
|
6
|
-
- Translate and localize documentation content
|
|
7
|
-
- Publish and manage team documentation workflows
|
|
8
|
-
- Provide interactive guidance throughout the document creation process
|
|
9
|
-
|
|
10
|
-
Interaction Guidelines:
|
|
11
|
-
- Engage users in a professional yet friendly manner
|
|
12
|
-
- Ask clarifying questions to understand specific documentation needs
|
|
13
|
-
- Suggest appropriate skills and workflows based on user requests
|
|
14
|
-
- Provide clear explanations of available capabilities and processes
|
|
15
|
-
- Maintain context throughout multi-step documentation tasks
|
|
16
|
-
- Offer proactive suggestions for improving document quality and structure
|
|
17
|
-
|
|
18
|
-
<skill_usage>
|
|
19
|
-
- afs_xxx skills: AFS(AIGNE File System) skills provide capabilities to explore, read, write and manage files and virtual modules within the AIGNE environment.
|
|
20
|
-
You can use these skills to access source files and other resources needed for documentation tasks.
|
|
21
|
-
- listDocuments: This skill lists all available documentation files in the system.
|
|
22
|
-
You can use this skill to get an overview of existing documents before creating or modifying documentation. for documentation tasks,
|
|
23
|
-
you should use this skill rather than afs_read to list documentation files.
|
|
24
|
-
- generateDocument: This skill generates new documentation or updates existing documents structure based on user inputs and specifications,
|
|
25
|
-
You can use this skill to create comprehensive documents from scratch or based on existing templates or update document structure as per user requirements.
|
|
26
|
-
- updateDocument: This skill updates existing documentation content with new information or revisions provided by the user.
|
|
27
|
-
You can use this skill to refine and enhance documents content based on feedback or additional details.
|
|
28
|
-
- publish: This skill publishes completed documentation to an online website to make it accessible to the intended audience.
|
|
29
|
-
You can use this skill to manage the publication process and ensure documents are properly formatted and available.
|
|
30
|
-
- translate: This skill translates documentation content into different languages for localization purposes.
|
|
31
|
-
You can use this skill to adapt documents for diverse audiences by providing translations in the required languages.
|
|
32
|
-
</skill_usage>
|
|
33
|
-
|
|
34
|
-
<output_requirements>
|
|
35
|
-
- respect tools results and do not fabricate information, use tools results to answer user questions whenever possible
|
|
36
|
-
- Use markdown format for all responses
|
|
37
|
-
- Respond in the same language as the user
|
|
38
|
-
</output_requirements>
|
package/agents/chat/index.mjs
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { mkdir, readFile } from "node:fs/promises";
|
|
2
|
-
import { parse } from "yaml";
|
|
3
|
-
|
|
4
|
-
await mkdir(".aigne/doc-smith", { recursive: true });
|
|
5
|
-
const config = await readFile(".aigne/doc-smith/config.yaml", "utf-8")
|
|
6
|
-
.then((raw) => parse(raw))
|
|
7
|
-
.catch(() => null);
|
|
8
|
-
|
|
9
|
-
const docsDir = config?.docsDir || ".aigne/doc-smith/docs";
|
|
10
|
-
await mkdir(docsDir, { recursive: true });
|
|
11
|
-
|
|
12
|
-
export default {
|
|
13
|
-
type: "ai",
|
|
14
|
-
name: "chat",
|
|
15
|
-
description: "Start interactive document generation assistant",
|
|
16
|
-
instructions: {
|
|
17
|
-
url: "./chat-system.md",
|
|
18
|
-
},
|
|
19
|
-
input_key: "message",
|
|
20
|
-
afs: {
|
|
21
|
-
modules: [
|
|
22
|
-
{
|
|
23
|
-
module: "history",
|
|
24
|
-
options: {
|
|
25
|
-
storage: {
|
|
26
|
-
url: "file:.aigne/doc-smith/.local/afs-storage.sqlite3",
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
module: "system-fs",
|
|
32
|
-
options: {
|
|
33
|
-
name: "source",
|
|
34
|
-
localPath: ".",
|
|
35
|
-
description: "Project root directory for document generation",
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
module: "system-fs",
|
|
40
|
-
options: {
|
|
41
|
-
name: "docs",
|
|
42
|
-
localPath: docsDir,
|
|
43
|
-
description: "Generated documentation files directory",
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
],
|
|
47
|
-
},
|
|
48
|
-
afs_config: {
|
|
49
|
-
inject_history: true,
|
|
50
|
-
},
|
|
51
|
-
skills: [
|
|
52
|
-
"./skills/list-documents.mjs",
|
|
53
|
-
"./skills/generate-document.yaml",
|
|
54
|
-
"./skills/update-document.yaml",
|
|
55
|
-
"../publish/index.yaml",
|
|
56
|
-
"../localize/index.yaml",
|
|
57
|
-
"../utils/exit.mjs",
|
|
58
|
-
],
|
|
59
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
type: team
|
|
2
|
-
name: generateDocument
|
|
3
|
-
description: Generate complete documentation for your project, or update/delete existing documents or structure based on user feedback
|
|
4
|
-
input_schema:
|
|
5
|
-
type: object
|
|
6
|
-
properties:
|
|
7
|
-
feedback:
|
|
8
|
-
type: string
|
|
9
|
-
description: How to generate or update the document content
|
|
10
|
-
required:
|
|
11
|
-
- feedback
|
|
12
|
-
skills:
|
|
13
|
-
- url: ../../create/index.yaml
|
|
14
|
-
default_input:
|
|
15
|
-
isChat: true
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { getMainLanguageFiles } from "../../../utils/docs-finder-utils.mjs";
|
|
2
|
-
import init from "../../init/index.mjs";
|
|
3
|
-
|
|
4
|
-
export default async function listDocuments(_, options) {
|
|
5
|
-
const config = await init({ checkOnly: true }, options);
|
|
6
|
-
|
|
7
|
-
// Get all main language .md files in docsDir
|
|
8
|
-
const mainLanguageFiles = await getMainLanguageFiles(config.docsDir, config.locale);
|
|
9
|
-
|
|
10
|
-
return {
|
|
11
|
-
documents: mainLanguageFiles,
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
listDocuments.description = "List all available documentation files";
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
type: team
|
|
2
|
-
name: updateDocument
|
|
3
|
-
description: Update a existing document based on user feedback
|
|
4
|
-
input_schema:
|
|
5
|
-
type: object
|
|
6
|
-
properties:
|
|
7
|
-
docs:
|
|
8
|
-
type: array
|
|
9
|
-
items:
|
|
10
|
-
type: string
|
|
11
|
-
description: Documents to update, must from listDocuments output
|
|
12
|
-
feedback:
|
|
13
|
-
type: string
|
|
14
|
-
description: Tell us what to change in this content
|
|
15
|
-
reset:
|
|
16
|
-
type: boolean
|
|
17
|
-
description: Regenerate the document from scratch, ignoring previous versions
|
|
18
|
-
required:
|
|
19
|
-
- docs
|
|
20
|
-
- feedback
|
|
21
|
-
skills:
|
|
22
|
-
- url: ../../update/index.yaml
|
|
23
|
-
default_input:
|
|
24
|
-
isChat: true
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { rm } from "node:fs/promises";
|
|
2
|
-
import { pathExists, toDisplayPath, getConfigFilePath } from "../../utils/file-utils.mjs";
|
|
3
|
-
|
|
4
|
-
export default async function clearDocumentConfig({ workDir }) {
|
|
5
|
-
const documentConfigPath = getConfigFilePath(workDir);
|
|
6
|
-
const displayPath = toDisplayPath(documentConfigPath);
|
|
7
|
-
|
|
8
|
-
try {
|
|
9
|
-
const existed = await pathExists(documentConfigPath);
|
|
10
|
-
await rm(documentConfigPath, { recursive: true, force: true });
|
|
11
|
-
|
|
12
|
-
const message = existed
|
|
13
|
-
? `⚙️ Cleared document configuration (${displayPath})`
|
|
14
|
-
: `⚙️ Document configuration already empty (${displayPath})`;
|
|
15
|
-
|
|
16
|
-
const suggestions = existed
|
|
17
|
-
? ["Run `aigne doc init` to generate a fresh configuration file."]
|
|
18
|
-
: [];
|
|
19
|
-
|
|
20
|
-
return {
|
|
21
|
-
message,
|
|
22
|
-
cleared: existed,
|
|
23
|
-
path: displayPath,
|
|
24
|
-
suggestions,
|
|
25
|
-
};
|
|
26
|
-
} catch (error) {
|
|
27
|
-
return {
|
|
28
|
-
message: `⚠️ Failed to clear document configuration: ${error.message}`,
|
|
29
|
-
error: true,
|
|
30
|
-
path: displayPath,
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
clearDocumentConfig.taskTitle = "Clear document configuration";
|
|
36
|
-
clearDocumentConfig.description = "Clear the document configuration file";
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { rm } from "node:fs/promises";
|
|
2
|
-
import { pathExists, toDisplayPath, getStructurePlanPath } from "../../utils/file-utils.mjs";
|
|
3
|
-
|
|
4
|
-
export default async function clearDocumentStructure(input = {}, _options = {}) {
|
|
5
|
-
const { docsDir, workDir } = input;
|
|
6
|
-
|
|
7
|
-
const structurePlanPath = getStructurePlanPath(workDir);
|
|
8
|
-
|
|
9
|
-
const results = [];
|
|
10
|
-
let hasError = false;
|
|
11
|
-
|
|
12
|
-
// Clear structure-plan.json
|
|
13
|
-
try {
|
|
14
|
-
const structureExists = await pathExists(structurePlanPath);
|
|
15
|
-
await rm(structurePlanPath, { force: true });
|
|
16
|
-
|
|
17
|
-
const structureDisplayPath = toDisplayPath(structurePlanPath);
|
|
18
|
-
const structureMessage = structureExists
|
|
19
|
-
? `✔ Cleared documentation structure (${structureDisplayPath})`
|
|
20
|
-
: `• Documentation structure already empty (${structureDisplayPath})`;
|
|
21
|
-
|
|
22
|
-
results.push({
|
|
23
|
-
type: "structure",
|
|
24
|
-
cleared: structureExists,
|
|
25
|
-
message: structureMessage,
|
|
26
|
-
});
|
|
27
|
-
} catch (error) {
|
|
28
|
-
hasError = true;
|
|
29
|
-
results.push({
|
|
30
|
-
type: "structure",
|
|
31
|
-
error: true,
|
|
32
|
-
message: `✗ Failed to clear documentation structure: ${error.message}`,
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
// Clear documents directory if provided
|
|
37
|
-
if (docsDir) {
|
|
38
|
-
try {
|
|
39
|
-
const docsExists = await pathExists(docsDir);
|
|
40
|
-
await rm(docsDir, { recursive: true, force: true });
|
|
41
|
-
|
|
42
|
-
const docsDisplayPath = toDisplayPath(docsDir);
|
|
43
|
-
const docsMessage = docsExists
|
|
44
|
-
? `✔ Cleared documents directory (${docsDisplayPath})`
|
|
45
|
-
: `• Documents directory already empty (${docsDisplayPath})`;
|
|
46
|
-
|
|
47
|
-
results.push({
|
|
48
|
-
type: "documents",
|
|
49
|
-
cleared: docsExists,
|
|
50
|
-
message: docsMessage,
|
|
51
|
-
});
|
|
52
|
-
} catch (error) {
|
|
53
|
-
hasError = true;
|
|
54
|
-
results.push({
|
|
55
|
-
type: "documents",
|
|
56
|
-
error: true,
|
|
57
|
-
message: `✗ Failed to clear documents directory: ${error.message}`,
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// Prepare summary message
|
|
63
|
-
const clearedItems = results.filter((r) => r.cleared).length;
|
|
64
|
-
const errorItems = results.filter((r) => r.error).length;
|
|
65
|
-
|
|
66
|
-
let header;
|
|
67
|
-
if (errorItems > 0) {
|
|
68
|
-
header = "⚠️ Documentation Structure cleanup finished with some issues.";
|
|
69
|
-
} else if (clearedItems > 0) {
|
|
70
|
-
header = "📖 Documentation Structure cleared successfully!";
|
|
71
|
-
} else {
|
|
72
|
-
header = "📖 Documentation Structure already empty.";
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
const detailLines = results.map((item) => ` ${item.message}`).join("\n");
|
|
76
|
-
const message = [header, "", detailLines].filter(Boolean).join("\n");
|
|
77
|
-
|
|
78
|
-
return {
|
|
79
|
-
message,
|
|
80
|
-
results,
|
|
81
|
-
hasError,
|
|
82
|
-
clearedCount: clearedItems,
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
clearDocumentStructure.input_schema = {
|
|
87
|
-
type: "object",
|
|
88
|
-
properties: {
|
|
89
|
-
docsDir: {
|
|
90
|
-
type: "string",
|
|
91
|
-
description: "The documents directory to clear (optional)",
|
|
92
|
-
},
|
|
93
|
-
workDir: {
|
|
94
|
-
type: "string",
|
|
95
|
-
description: "The working directory (defaults to current directory)",
|
|
96
|
-
},
|
|
97
|
-
},
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
clearDocumentStructure.taskTitle = "Clear documentation structure and all generated documents";
|
|
101
|
-
clearDocumentStructure.description =
|
|
102
|
-
"Clear the documentation structure (structure-plan.json) and optionally the documents directory";
|