@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
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,192 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getConfigFilePath,
|
|
3
|
-
getMediaDescriptionCachePath,
|
|
4
|
-
getStructurePlanPath,
|
|
5
|
-
toDisplayPath,
|
|
6
|
-
} from "../../utils/file-utils.mjs";
|
|
7
|
-
|
|
8
|
-
const TARGET_METADATA = {
|
|
9
|
-
generatedDocs: {
|
|
10
|
-
label: "Generated Documents",
|
|
11
|
-
description: ({ docsDir }) =>
|
|
12
|
-
`Select and delete specific generated documents in './${toDisplayPath(docsDir)}'. The documentation structure will be preserved.`,
|
|
13
|
-
agent: "clearGeneratedDocs",
|
|
14
|
-
},
|
|
15
|
-
documentStructure: {
|
|
16
|
-
label: "Documentation Structure",
|
|
17
|
-
description: ({ docsDir, workDir }) =>
|
|
18
|
-
`Delete all generated documents in './${toDisplayPath(docsDir)}' and the documentation structure in './${toDisplayPath(
|
|
19
|
-
getStructurePlanPath(workDir),
|
|
20
|
-
)}'.`,
|
|
21
|
-
agent: "clearDocumentStructure",
|
|
22
|
-
},
|
|
23
|
-
documentConfig: {
|
|
24
|
-
label: "Document Configuration",
|
|
25
|
-
description: ({ workDir }) =>
|
|
26
|
-
`Delete the configuration file in './${toDisplayPath(
|
|
27
|
-
getConfigFilePath(workDir),
|
|
28
|
-
)}'. You will need to run \`aigne doc init\` to regenerate it.`,
|
|
29
|
-
agent: "clearDocumentConfig",
|
|
30
|
-
},
|
|
31
|
-
authTokens: {
|
|
32
|
-
label: "Authorizations",
|
|
33
|
-
description: () =>
|
|
34
|
-
"Delete authorization information. You will need to re-authorize after clearing.",
|
|
35
|
-
agent: "clearAuthTokens",
|
|
36
|
-
},
|
|
37
|
-
deploymentConfig: {
|
|
38
|
-
label: "Deployment Config",
|
|
39
|
-
description: ({ workDir }) =>
|
|
40
|
-
`Delete the appUrl from './${toDisplayPath(getConfigFilePath(workDir))}'.`,
|
|
41
|
-
agent: "clearDeploymentConfig",
|
|
42
|
-
},
|
|
43
|
-
mediaDescription: {
|
|
44
|
-
label: "Media File Descriptions",
|
|
45
|
-
description: () =>
|
|
46
|
-
`Delete AI-generated descriptions in './${toDisplayPath(
|
|
47
|
-
getMediaDescriptionCachePath(),
|
|
48
|
-
)}'. They will be regenerated on the next run.`,
|
|
49
|
-
agent: "clearMediaDescription",
|
|
50
|
-
},
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
const TARGET_KEYS = Object.keys(TARGET_METADATA);
|
|
54
|
-
|
|
55
|
-
function normalizeTarget(value) {
|
|
56
|
-
if (!value) return null;
|
|
57
|
-
const trimmed = value.trim();
|
|
58
|
-
if (TARGET_METADATA[trimmed]) return trimmed;
|
|
59
|
-
|
|
60
|
-
const lowerMatched = TARGET_KEYS.find((key) => key.toLowerCase() === trimmed.toLowerCase());
|
|
61
|
-
return lowerMatched || null;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export default async function chooseContents(input = {}, options = {}) {
|
|
65
|
-
const { targets: rawTargets, ...rest } = input;
|
|
66
|
-
|
|
67
|
-
const normalizedTargets = Array.isArray(rawTargets)
|
|
68
|
-
? rawTargets.map(normalizeTarget).filter(Boolean)
|
|
69
|
-
: [];
|
|
70
|
-
|
|
71
|
-
let selectedTargets = [...new Set(normalizedTargets)];
|
|
72
|
-
|
|
73
|
-
if (selectedTargets.length === 0) {
|
|
74
|
-
if (options?.prompts?.checkbox) {
|
|
75
|
-
const choices = Object.entries(TARGET_METADATA).map(([value, def]) => ({
|
|
76
|
-
name: def.label,
|
|
77
|
-
value,
|
|
78
|
-
description: def.description({ docsDir: input.docsDir, workDir: input.workDir }),
|
|
79
|
-
}));
|
|
80
|
-
|
|
81
|
-
selectedTargets = await options.prompts.checkbox({
|
|
82
|
-
message: "Please select the items you'd like to clear:",
|
|
83
|
-
choices,
|
|
84
|
-
validate: (answer) => (answer.length > 0 ? true : "You must select at least one item."),
|
|
85
|
-
});
|
|
86
|
-
} else {
|
|
87
|
-
return {
|
|
88
|
-
message: `Available options to clear: ${TARGET_KEYS.join(", ")}`,
|
|
89
|
-
availableTargets: TARGET_KEYS,
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
if (selectedTargets.length === 0) {
|
|
95
|
-
return {
|
|
96
|
-
message: "You haven't selected any items to clear.",
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
const results = [];
|
|
101
|
-
let hasError = false;
|
|
102
|
-
let configCleared = false;
|
|
103
|
-
|
|
104
|
-
for (const target of selectedTargets) {
|
|
105
|
-
const metadata = TARGET_METADATA[target];
|
|
106
|
-
if (!metadata) {
|
|
107
|
-
results.push({
|
|
108
|
-
status: "error",
|
|
109
|
-
message: `Unknown target: ${target}`,
|
|
110
|
-
});
|
|
111
|
-
hasError = true;
|
|
112
|
-
continue;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
try {
|
|
116
|
-
const clearAgent = options.context?.agents?.[metadata.agent];
|
|
117
|
-
if (!clearAgent) {
|
|
118
|
-
throw new Error(`The clear agent '${metadata.agent}' was not found.`);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
const result = await options.context.invoke(clearAgent, rest);
|
|
122
|
-
|
|
123
|
-
if (result.error) {
|
|
124
|
-
hasError = true;
|
|
125
|
-
results.push({
|
|
126
|
-
status: "error",
|
|
127
|
-
message: result.message,
|
|
128
|
-
});
|
|
129
|
-
} else {
|
|
130
|
-
const status = result.cleared ? "removed" : "noop";
|
|
131
|
-
results.push({
|
|
132
|
-
status,
|
|
133
|
-
message: result.message,
|
|
134
|
-
path: result.path,
|
|
135
|
-
suggestions: result.suggestions,
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
if (target === "documentConfig" && result.cleared) {
|
|
139
|
-
configCleared = true;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
} catch (error) {
|
|
143
|
-
hasError = true;
|
|
144
|
-
results.push({
|
|
145
|
-
status: "error",
|
|
146
|
-
message: `Failed to clear ${metadata.label}: ${error.message}`,
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
const header = hasError
|
|
152
|
-
? "🧹 Cleanup finished with some issues.\n"
|
|
153
|
-
: "🧹 Cleanup completed successfully!\n";
|
|
154
|
-
const detailLines = results.map((item) => `${item.message}`).join("\n\n");
|
|
155
|
-
|
|
156
|
-
const suggestions = [];
|
|
157
|
-
results.forEach((result) => {
|
|
158
|
-
if (result.suggestions) {
|
|
159
|
-
suggestions.push(...result.suggestions);
|
|
160
|
-
}
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
if (configCleared && !suggestions.some((s) => s.includes("aigne doc init"))) {
|
|
164
|
-
suggestions.push("Run `aigne doc init` to generate a fresh configuration file.");
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
const message = [header, "", detailLines, suggestions.length ? "" : null, suggestions.join("\n")]
|
|
168
|
-
.filter(Boolean)
|
|
169
|
-
.join("\n");
|
|
170
|
-
|
|
171
|
-
return {
|
|
172
|
-
message,
|
|
173
|
-
};
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
chooseContents.input_schema = {
|
|
177
|
-
type: "object",
|
|
178
|
-
properties: {
|
|
179
|
-
targets: {
|
|
180
|
-
type: "array",
|
|
181
|
-
description: "A list of items to clear without confirmation.",
|
|
182
|
-
items: {
|
|
183
|
-
type: "string",
|
|
184
|
-
enum: TARGET_KEYS,
|
|
185
|
-
},
|
|
186
|
-
},
|
|
187
|
-
},
|
|
188
|
-
};
|
|
189
|
-
|
|
190
|
-
chooseContents.taskTitle = "Select and clear project contents";
|
|
191
|
-
chooseContents.description =
|
|
192
|
-
"Select and clear project contents, such as generated documents, configuration, and authorization tokens.";
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import chalk from "chalk";
|
|
2
|
-
import { createStore } from "../../utils/store/index.mjs";
|
|
3
|
-
|
|
4
|
-
export default async function clearAuthTokens(_input = {}, options = {}) {
|
|
5
|
-
const store = await createStore();
|
|
6
|
-
|
|
7
|
-
try {
|
|
8
|
-
const listMap = await store.listMap();
|
|
9
|
-
// Get all available sites
|
|
10
|
-
const siteHostnames = Object.keys(listMap);
|
|
11
|
-
|
|
12
|
-
if (siteHostnames.length === 0) {
|
|
13
|
-
return {
|
|
14
|
-
message: "🔑 No site authorizations found to clear",
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// Display all sites with their URLs for user selection
|
|
19
|
-
const choices = siteHostnames.map((hostname) => {
|
|
20
|
-
return {
|
|
21
|
-
name: `${chalk.cyan(hostname)}`,
|
|
22
|
-
value: hostname,
|
|
23
|
-
checked: false, // Allow multiple selection
|
|
24
|
-
};
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
// Add an option to clear all site authorizations
|
|
28
|
-
choices.push({
|
|
29
|
-
name: chalk.red("🗑️ Clear ALL site authorizations"),
|
|
30
|
-
value: "__ALL__",
|
|
31
|
-
checked: false,
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
let selectedSites = [];
|
|
35
|
-
|
|
36
|
-
if (options?.prompts?.checkbox) {
|
|
37
|
-
selectedSites = await options.prompts.checkbox({
|
|
38
|
-
message: "Select sites to clear authorization from:",
|
|
39
|
-
choices,
|
|
40
|
-
validate: (answer) => (answer.length > 0 ? true : "Please select at least one site."),
|
|
41
|
-
});
|
|
42
|
-
} else {
|
|
43
|
-
// If no prompts available, clear all site authorizations
|
|
44
|
-
selectedSites = ["__ALL__"];
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
if (selectedSites.length === 0) {
|
|
48
|
-
return {
|
|
49
|
-
message: "🔑 No sites selected for clearing authorization",
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const results = [];
|
|
54
|
-
let clearedCount = 0;
|
|
55
|
-
|
|
56
|
-
if (selectedSites.includes("__ALL__")) {
|
|
57
|
-
// Clear all site authorizations
|
|
58
|
-
await store.clear();
|
|
59
|
-
results.push(`✔ Cleared site authorization for all sites (${siteHostnames.length} sites)`);
|
|
60
|
-
clearedCount = siteHostnames.length;
|
|
61
|
-
} else {
|
|
62
|
-
for (const hostname of selectedSites) {
|
|
63
|
-
await store.deleteItem(hostname);
|
|
64
|
-
results.push(`✔ Cleared site authorization for ${chalk.cyan(hostname)}`);
|
|
65
|
-
clearedCount++;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const header = `🔑 Successfully cleared site authorizations!`;
|
|
70
|
-
const detailLines = results.map((item) => ` ${item}`).join("\n");
|
|
71
|
-
|
|
72
|
-
const message = [header, "", detailLines, ""].filter(Boolean).join("\n");
|
|
73
|
-
|
|
74
|
-
return {
|
|
75
|
-
message,
|
|
76
|
-
clearedCount,
|
|
77
|
-
clearedSites: selectedSites.includes("__ALL__") ? siteHostnames : selectedSites,
|
|
78
|
-
};
|
|
79
|
-
} catch (error) {
|
|
80
|
-
return {
|
|
81
|
-
message: `⚠️ Failed to clear site authorizations: ${error.message}`,
|
|
82
|
-
error: true,
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
clearAuthTokens.taskTitle = "Clear site authorizations";
|
|
88
|
-
clearAuthTokens.description = "Clear site authorizations for document publishing sites";
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { readFile, writeFile } from "node:fs/promises";
|
|
2
|
-
import yaml from "yaml";
|
|
3
|
-
import { pathExists, toDisplayPath, getConfigFilePath } from "../../utils/file-utils.mjs";
|
|
4
|
-
|
|
5
|
-
export default async function clearDeploymentConfig(input = {}) {
|
|
6
|
-
const { workDir } = input;
|
|
7
|
-
|
|
8
|
-
const configFilePath = getConfigFilePath(workDir);
|
|
9
|
-
const displayPath = toDisplayPath(configFilePath);
|
|
10
|
-
|
|
11
|
-
try {
|
|
12
|
-
// Check if config file exists
|
|
13
|
-
const exists = await pathExists(configFilePath);
|
|
14
|
-
if (!exists) {
|
|
15
|
-
return {
|
|
16
|
-
message: `📦 Config file not found (${displayPath}). No need to clear appUrl.`,
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
// Remove appUrl field while preserving comments
|
|
21
|
-
const configContent = await readFile(configFilePath, "utf-8");
|
|
22
|
-
const doc = yaml.parseDocument(configContent);
|
|
23
|
-
|
|
24
|
-
if (doc.has("appUrl")) {
|
|
25
|
-
doc.delete("appUrl");
|
|
26
|
-
await writeFile(
|
|
27
|
-
configFilePath,
|
|
28
|
-
doc.toString({
|
|
29
|
-
keepSourceTokens: true,
|
|
30
|
-
indent: 2,
|
|
31
|
-
lineWidth: 0,
|
|
32
|
-
minContentWidth: 0,
|
|
33
|
-
}),
|
|
34
|
-
"utf-8",
|
|
35
|
-
);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return {
|
|
39
|
-
message: `📦 Cleared appUrl from config file (${displayPath})`,
|
|
40
|
-
};
|
|
41
|
-
} catch (error) {
|
|
42
|
-
return {
|
|
43
|
-
error: true,
|
|
44
|
-
message: `⚠️ Failed to clear deployment config: ${error.message}`,
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
clearDeploymentConfig.taskTitle = "Clear deployment configuration";
|
|
@@ -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";
|