@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.
Files changed (257) hide show
  1. package/CLAUDE.md +43 -0
  2. package/README.md +94 -250
  3. package/aigne.yaml +2 -149
  4. package/doc-smith/SKILL.md +117 -0
  5. package/doc-smith/references/changeset_schema.md +118 -0
  6. package/doc-smith/references/document_structure_schema.md +139 -0
  7. package/doc-smith/references/document_update_guide.md +193 -0
  8. package/doc-smith/references/structure_confirmation_guide.md +133 -0
  9. package/doc-smith/references/structure_planning_guide.md +146 -0
  10. package/doc-smith/references/user_intent_guide.md +172 -0
  11. package/doc-smith.yaml +114 -0
  12. package/main-system-prompt.md +56 -0
  13. package/package.json +3 -69
  14. package/scripts/README.md +90 -0
  15. package/scripts/install.sh +86 -0
  16. package/scripts/uninstall.sh +52 -0
  17. package/CHANGELOG.md +0 -994
  18. package/LICENSE +0 -93
  19. package/agentic-agents/common/base-info.md +0 -53
  20. package/agentic-agents/common/completer.md +0 -54
  21. package/agentic-agents/common/planner.md +0 -168
  22. package/agentic-agents/common/worker.md +0 -93
  23. package/agentic-agents/create/index.yaml +0 -129
  24. package/agentic-agents/create/objective.md +0 -44
  25. package/agentic-agents/create/set-custom-prompt.mjs +0 -27
  26. package/agentic-agents/detail/index.yaml +0 -95
  27. package/agentic-agents/detail/objective.md +0 -9
  28. package/agentic-agents/detail/set-custom-prompt.mjs +0 -88
  29. package/agentic-agents/predict-resources/index.yaml +0 -44
  30. package/agentic-agents/predict-resources/instructions.md +0 -61
  31. package/agentic-agents/structure/design-rules.md +0 -39
  32. package/agentic-agents/structure/index.yaml +0 -86
  33. package/agentic-agents/structure/objective.md +0 -14
  34. package/agentic-agents/structure/review-criteria.md +0 -55
  35. package/agentic-agents/structure/set-custom-prompt.mjs +0 -78
  36. package/agentic-agents/utils/init-workspace-cache.mjs +0 -171
  37. package/agentic-agents/utils/load-base-sources.mjs +0 -20
  38. package/agentic-agents/workspace-cache-sharing-design.md +0 -671
  39. package/agents/chat/chat-system.md +0 -38
  40. package/agents/chat/index.mjs +0 -59
  41. package/agents/chat/skills/generate-document.yaml +0 -15
  42. package/agents/chat/skills/list-documents.mjs +0 -15
  43. package/agents/chat/skills/update-document.yaml +0 -24
  44. package/agents/clear/choose-contents.mjs +0 -192
  45. package/agents/clear/clear-auth-tokens.mjs +0 -88
  46. package/agents/clear/clear-deployment-config.mjs +0 -49
  47. package/agents/clear/clear-document-config.mjs +0 -36
  48. package/agents/clear/clear-document-structure.mjs +0 -102
  49. package/agents/clear/clear-generated-docs.mjs +0 -142
  50. package/agents/clear/clear-media-description.mjs +0 -129
  51. package/agents/clear/index.yaml +0 -26
  52. package/agents/create/analyze-diagram-type-llm.yaml +0 -160
  53. package/agents/create/analyze-diagram-type.mjs +0 -297
  54. package/agents/create/check-document-structure.yaml +0 -30
  55. package/agents/create/check-need-generate-structure.mjs +0 -105
  56. package/agents/create/document-structure-tools/add-document.mjs +0 -85
  57. package/agents/create/document-structure-tools/delete-document.mjs +0 -116
  58. package/agents/create/document-structure-tools/move-document.mjs +0 -109
  59. package/agents/create/document-structure-tools/update-document.mjs +0 -84
  60. package/agents/create/generate-diagram-image.yaml +0 -60
  61. package/agents/create/generate-structure.yaml +0 -117
  62. package/agents/create/index.yaml +0 -49
  63. package/agents/create/refine-document-structure.yaml +0 -12
  64. package/agents/create/replace-d2-with-image.mjs +0 -625
  65. package/agents/create/update-document-structure.yaml +0 -54
  66. package/agents/create/user-add-document/add-documents-to-structure.mjs +0 -90
  67. package/agents/create/user-add-document/find-documents-to-add-links.yaml +0 -47
  68. package/agents/create/user-add-document/index.yaml +0 -46
  69. package/agents/create/user-add-document/prepare-documents-to-translate.mjs +0 -22
  70. package/agents/create/user-add-document/print-add-document-summary.mjs +0 -63
  71. package/agents/create/user-add-document/review-documents-with-new-links.mjs +0 -110
  72. package/agents/create/user-remove-document/find-documents-with-invalid-links.mjs +0 -78
  73. package/agents/create/user-remove-document/index.yaml +0 -40
  74. package/agents/create/user-remove-document/prepare-documents-to-translate.mjs +0 -22
  75. package/agents/create/user-remove-document/print-remove-document-summary.mjs +0 -53
  76. package/agents/create/user-remove-document/remove-documents-from-structure.mjs +0 -99
  77. package/agents/create/user-remove-document/review-documents-with-invalid-links.mjs +0 -115
  78. package/agents/create/user-review-document-structure.mjs +0 -140
  79. package/agents/create/utils/init-current-content.mjs +0 -34
  80. package/agents/create/utils/merge-document-structures.mjs +0 -30
  81. package/agents/evaluate/code-snippet.mjs +0 -97
  82. package/agents/evaluate/document-structure.yaml +0 -67
  83. package/agents/evaluate/document.yaml +0 -82
  84. package/agents/evaluate/generate-report.mjs +0 -85
  85. package/agents/evaluate/index.yaml +0 -46
  86. package/agents/history/index.yaml +0 -6
  87. package/agents/history/view.mjs +0 -78
  88. package/agents/init/check.mjs +0 -16
  89. package/agents/init/index.mjs +0 -275
  90. package/agents/init/validate.mjs +0 -16
  91. package/agents/localize/choose-language.mjs +0 -107
  92. package/agents/localize/index.yaml +0 -58
  93. package/agents/localize/record-translation-history.mjs +0 -23
  94. package/agents/localize/translate-document.yaml +0 -24
  95. package/agents/localize/translate-multilingual.yaml +0 -51
  96. package/agents/media/batch-generate-media-description.yaml +0 -46
  97. package/agents/media/generate-media-description.yaml +0 -50
  98. package/agents/media/load-media-description.mjs +0 -256
  99. package/agents/prefs/index.mjs +0 -203
  100. package/agents/publish/index.yaml +0 -26
  101. package/agents/publish/publish-docs.mjs +0 -356
  102. package/agents/publish/translate-meta.mjs +0 -103
  103. package/agents/schema/document-structure-item.yaml +0 -26
  104. package/agents/schema/document-structure-refine-item.yaml +0 -23
  105. package/agents/schema/document-structure.yaml +0 -29
  106. package/agents/update/batch-generate-document.yaml +0 -27
  107. package/agents/update/batch-update-document.yaml +0 -7
  108. package/agents/update/check-diagram-flag.mjs +0 -116
  109. package/agents/update/check-document.mjs +0 -162
  110. package/agents/update/check-generate-diagram.mjs +0 -106
  111. package/agents/update/check-sync-image-flag.mjs +0 -55
  112. package/agents/update/check-update-is-single.mjs +0 -53
  113. package/agents/update/document-tools/update-document-content.mjs +0 -303
  114. package/agents/update/generate-diagram.yaml +0 -63
  115. package/agents/update/generate-document.yaml +0 -70
  116. package/agents/update/handle-document-update.yaml +0 -103
  117. package/agents/update/index.yaml +0 -79
  118. package/agents/update/pre-check-generate-diagram.yaml +0 -44
  119. package/agents/update/save-and-translate-document.mjs +0 -76
  120. package/agents/update/sync-images-and-exit.mjs +0 -148
  121. package/agents/update/update-document-detail.yaml +0 -71
  122. package/agents/update/update-single/update-single-document-detail.mjs +0 -280
  123. package/agents/update/update-single-document.yaml +0 -7
  124. package/agents/update/user-review-document.mjs +0 -272
  125. package/agents/utils/action-success.mjs +0 -16
  126. package/agents/utils/analyze-document-feedback-intent.yaml +0 -32
  127. package/agents/utils/analyze-feedback-intent.mjs +0 -136
  128. package/agents/utils/analyze-structure-feedback-intent.yaml +0 -29
  129. package/agents/utils/check-detail-result.mjs +0 -38
  130. package/agents/utils/check-feedback-refiner.mjs +0 -81
  131. package/agents/utils/choose-docs.mjs +0 -293
  132. package/agents/utils/document-icon-generate.yaml +0 -52
  133. package/agents/utils/document-title-streamline.yaml +0 -48
  134. package/agents/utils/ensure-document-icons.mjs +0 -129
  135. package/agents/utils/exit.mjs +0 -6
  136. package/agents/utils/feedback-refiner.yaml +0 -50
  137. package/agents/utils/find-item-by-path.mjs +0 -114
  138. package/agents/utils/find-user-preferences-by-path.mjs +0 -37
  139. package/agents/utils/format-document-structure.mjs +0 -35
  140. package/agents/utils/generate-document-or-skip.mjs +0 -41
  141. package/agents/utils/handle-diagram-operations.mjs +0 -263
  142. package/agents/utils/load-all-document-content.mjs +0 -30
  143. package/agents/utils/load-document-all-content.mjs +0 -84
  144. package/agents/utils/load-sources.mjs +0 -405
  145. package/agents/utils/map-reasoning-effort-level.mjs +0 -15
  146. package/agents/utils/post-generate.mjs +0 -144
  147. package/agents/utils/read-current-document-content.mjs +0 -46
  148. package/agents/utils/save-doc-translation.mjs +0 -61
  149. package/agents/utils/save-doc.mjs +0 -88
  150. package/agents/utils/save-output.mjs +0 -26
  151. package/agents/utils/save-sidebar.mjs +0 -51
  152. package/agents/utils/skip-if-content-exists.mjs +0 -27
  153. package/agents/utils/streamline-document-titles-if-needed.mjs +0 -88
  154. package/agents/utils/transform-detail-data-sources.mjs +0 -45
  155. package/agents/utils/update-branding.mjs +0 -84
  156. package/assets/report-template/report.html +0 -198
  157. package/docs-mcp/analyze-content-relevance.yaml +0 -50
  158. package/docs-mcp/analyze-docs-relevance.yaml +0 -59
  159. package/docs-mcp/docs-search.yaml +0 -42
  160. package/docs-mcp/get-docs-detail.mjs +0 -41
  161. package/docs-mcp/get-docs-structure.mjs +0 -16
  162. package/docs-mcp/read-doc-content.mjs +0 -119
  163. package/prompts/common/document/content-rules-core.md +0 -20
  164. package/prompts/common/document/markdown-syntax-rules.md +0 -65
  165. package/prompts/common/document/media-file-list-usage-rules.md +0 -18
  166. package/prompts/common/document/openapi-usage-rules.md +0 -189
  167. package/prompts/common/document/role-and-personality.md +0 -16
  168. package/prompts/common/document/user-preferences.md +0 -9
  169. package/prompts/common/document-structure/conflict-resolution-guidance.md +0 -16
  170. package/prompts/common/document-structure/document-icon-generate.md +0 -116
  171. package/prompts/common/document-structure/document-structure-rules.md +0 -43
  172. package/prompts/common/document-structure/document-title-streamline.md +0 -86
  173. package/prompts/common/document-structure/glossary.md +0 -7
  174. package/prompts/common/document-structure/intj-traits.md +0 -5
  175. package/prompts/common/document-structure/openapi-usage-rules.md +0 -28
  176. package/prompts/common/document-structure/output-constraints.md +0 -18
  177. package/prompts/common/document-structure/user-locale-rules.md +0 -10
  178. package/prompts/common/document-structure/user-preferences.md +0 -9
  179. package/prompts/detail/custom/admonition-usage-rules.md +0 -94
  180. package/prompts/detail/custom/code-block-usage-rules.md +0 -163
  181. package/prompts/detail/custom/custom-components/x-card-usage-rules.md +0 -63
  182. package/prompts/detail/custom/custom-components/x-cards-usage-rules.md +0 -83
  183. package/prompts/detail/custom/custom-components/x-field-desc-usage-rules.md +0 -120
  184. package/prompts/detail/custom/custom-components/x-field-group-usage-rules.md +0 -80
  185. package/prompts/detail/custom/custom-components/x-field-usage-rules.md +0 -189
  186. package/prompts/detail/custom/custom-components-usage-rules.md +0 -18
  187. package/prompts/detail/diagram/generate-image-system.md +0 -135
  188. package/prompts/detail/diagram/generate-image-user.md +0 -32
  189. package/prompts/detail/diagram/guide.md +0 -29
  190. package/prompts/detail/diagram/official-examples.md +0 -712
  191. package/prompts/detail/diagram/pre-check.md +0 -23
  192. package/prompts/detail/diagram/role-and-personality.md +0 -2
  193. package/prompts/detail/diagram/rules.md +0 -46
  194. package/prompts/detail/diagram/system-prompt.md +0 -1139
  195. package/prompts/detail/diagram/user-prompt.md +0 -43
  196. package/prompts/detail/generate/detail-example.md +0 -457
  197. package/prompts/detail/generate/document-rules.md +0 -45
  198. package/prompts/detail/generate/system-prompt.md +0 -61
  199. package/prompts/detail/generate/user-prompt.md +0 -99
  200. package/prompts/detail/jsx/rules.md +0 -6
  201. package/prompts/detail/update/system-prompt.md +0 -121
  202. package/prompts/detail/update/user-prompt.md +0 -41
  203. package/prompts/evaluate/document-structure.md +0 -93
  204. package/prompts/evaluate/document.md +0 -149
  205. package/prompts/media/media-description/system-prompt.md +0 -43
  206. package/prompts/media/media-description/user-prompt.md +0 -17
  207. package/prompts/structure/check-document-structure.md +0 -93
  208. package/prompts/structure/document-rules.md +0 -21
  209. package/prompts/structure/find-documents-to-add-links.md +0 -52
  210. package/prompts/structure/generate/system-prompt.md +0 -13
  211. package/prompts/structure/generate/user-prompt.md +0 -137
  212. package/prompts/structure/review/structure-review-system.md +0 -81
  213. package/prompts/structure/structure-example.md +0 -89
  214. package/prompts/structure/structure-getting-started.md +0 -10
  215. package/prompts/structure/update/system-prompt.md +0 -93
  216. package/prompts/structure/update/user-prompt.md +0 -43
  217. package/prompts/translate/admonition.md +0 -20
  218. package/prompts/translate/code-block.md +0 -33
  219. package/prompts/translate/glossary.md +0 -6
  220. package/prompts/translate/translate-document.md +0 -305
  221. package/prompts/utils/analyze-document-feedback-intent.md +0 -54
  222. package/prompts/utils/analyze-structure-feedback-intent.md +0 -43
  223. package/prompts/utils/feedback-refiner.md +0 -105
  224. package/types/document-schema.mjs +0 -55
  225. package/types/document-structure-schema.mjs +0 -261
  226. package/utils/auth-utils.mjs +0 -275
  227. package/utils/blocklet.mjs +0 -104
  228. package/utils/check-document-has-diagram.mjs +0 -95
  229. package/utils/conflict-detector.mjs +0 -149
  230. package/utils/constants/index.mjs +0 -620
  231. package/utils/constants/linter.mjs +0 -102
  232. package/utils/d2-utils.mjs +0 -198
  233. package/utils/debug.mjs +0 -3
  234. package/utils/delete-diagram-images.mjs +0 -99
  235. package/utils/deploy.mjs +0 -86
  236. package/utils/docs-finder-utils.mjs +0 -623
  237. package/utils/evaluate/report-utils.mjs +0 -132
  238. package/utils/extract-api.mjs +0 -32
  239. package/utils/file-utils.mjs +0 -960
  240. package/utils/history-utils.mjs +0 -203
  241. package/utils/icon-map.mjs +0 -26
  242. package/utils/image-compress.mjs +0 -75
  243. package/utils/kroki-utils.mjs +0 -173
  244. package/utils/linter/index.mjs +0 -50
  245. package/utils/load-config.mjs +0 -107
  246. package/utils/markdown/index.mjs +0 -26
  247. package/utils/markdown-checker.mjs +0 -694
  248. package/utils/mermaid-validator.mjs +0 -140
  249. package/utils/mermaid-worker-pool.mjs +0 -250
  250. package/utils/mermaid-worker.mjs +0 -233
  251. package/utils/openapi/index.mjs +0 -28
  252. package/utils/preferences-utils.mjs +0 -175
  253. package/utils/request.mjs +0 -10
  254. package/utils/store/index.mjs +0 -45
  255. package/utils/sync-diagram-to-translations.mjs +0 -262
  256. package/utils/upload-files.mjs +0 -231
  257. package/utils/utils.mjs +0 -1354
@@ -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";