@dxtmisha/scripts 0.11.7 → 1.0.0
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 +67 -0
- package/ai-resources/componentMaterials.md +19 -0
- package/ai-resources/componentPrompt.md +381 -0
- package/ai-resources/componentWiki.md +13 -0
- package/bin/arguments.ts +168 -0
- package/bin/build-packages.ts +12 -2
- package/bin/build-publish-packages.ts +12 -2
- package/bin/design-component.ts +7 -1
- package/bin/design-constructor.ts +22 -3
- package/bin/design-figma.ts +26 -4
- package/bin/design-flags.ts +14 -2
- package/bin/design-library.ts +7 -1
- package/bin/design-package.ts +29 -5
- package/bin/design-prompt.ts +22 -3
- package/bin/design-screenshot.ts +12 -2
- package/bin/design-types-save.ts +32 -5
- package/bin/design-types.ts +32 -6
- package/bin/design-ui.ts +21 -3
- package/bin/design-wiki-storm.ts +11 -3
- package/dist/AiZAi-x3CInynJ.js +232 -0
- package/dist/PropertiesConfig-ChizwW5y.js +250 -0
- package/{src/config.ts → dist/config.d.ts} +179 -158
- package/dist/config.js +20 -0
- package/dist/figmaApiTypes-CArSsNW8.js +6 -0
- package/dist/library-ai.d.ts +482 -0
- package/dist/library-ai.js +2 -0
- package/dist/library-figma.d.ts +462 -0
- package/dist/library-figma.js +75 -0
- package/dist/library-ui.d.ts +586 -0
- package/dist/library-ui.js +3760 -0
- package/dist/library.d.ts +4677 -0
- package/dist/library.js +1436 -0
- package/dist/propertyTypes-DflziKuR.js +236 -0
- package/package.json +69 -20
- package/bin/ai-doc.ts +0 -7
- package/bin/build-functional.ts +0 -5
- package/bin/design-component-wiki.ts +0 -11
- package/src/classes/Ai/AiAbstract.ts +0 -242
- package/src/classes/Ai/AiClaude.ts +0 -26
- package/src/classes/Ai/AiClaudeAgent.ts +0 -16
- package/src/classes/Ai/AiClaudeAgentLite.ts +0 -86
- package/src/classes/Ai/AiClaudeCli.ts +0 -24
- package/src/classes/Ai/AiClaudeCliLite.ts +0 -108
- package/src/classes/Ai/AiClaudeLite.ts +0 -112
- package/src/classes/Ai/AiDoc.ts +0 -81
- package/src/classes/Ai/AiDocItem.ts +0 -27
- package/src/classes/Ai/AiDocItemAbstract.ts +0 -209
- package/src/classes/Ai/AiDocItemClasses.ts +0 -27
- package/src/classes/Ai/AiDocItemComposables.ts +0 -20
- package/src/classes/Ai/AiDocType.ts +0 -45
- package/src/classes/Ai/AiGoogle.ts +0 -26
- package/src/classes/Ai/AiGoogleCli.ts +0 -24
- package/src/classes/Ai/AiGoogleCliLite.ts +0 -108
- package/src/classes/Ai/AiGoogleLite.ts +0 -78
- package/src/classes/Ai/AiOpenAi.ts +0 -26
- package/src/classes/Ai/AiOpenAiLite.ts +0 -107
- package/src/classes/Ai/AiZAi.ts +0 -17
- package/src/classes/Ai/AiZAiLite.ts +0 -77
- package/src/classes/Ai/ApiTmp.ts +0 -43
- package/src/classes/BrowserItem.ts +0 -408
- package/src/classes/Build/BuildFunctional.ts +0 -54
- package/src/classes/Build/BuildPackages.ts +0 -137
- package/src/classes/Build/BuildPublishPackages.ts +0 -105
- package/src/classes/BuildItem.ts +0 -187
- package/src/classes/Component/ComponentCreator.ts +0 -45
- package/src/classes/Component/ComponentItem.ts +0 -161
- package/src/classes/Component/ComponentWiki.ts +0 -258
- package/src/classes/Component/ComponentWikiFile.ts +0 -138
- package/src/classes/Design/DesignCommand.ts +0 -243
- package/src/classes/Design/DesignComponent.ts +0 -824
- package/src/classes/Design/DesignConstructor.ts +0 -222
- package/src/classes/Design/DesignConstructors.ts +0 -101
- package/src/classes/Design/DesignFigma.ts +0 -61
- package/src/classes/Design/DesignFlags.ts +0 -215
- package/src/classes/Design/DesignReplace.ts +0 -672
- package/src/classes/Design/DesignScreenshot.ts +0 -133
- package/src/classes/Design/DesignStructure.ts +0 -201
- package/src/classes/Design/DesignStructureClasses.ts +0 -105
- package/src/classes/Design/DesignStructureItemAbstract.ts +0 -52
- package/src/classes/Design/DesignStructureRead.ts +0 -349
- package/src/classes/Design/DesignStructureStyles.ts +0 -45
- package/src/classes/Design/DesignTypes.ts +0 -94
- package/src/classes/Design/DesignTypesAi.ts +0 -135
- package/src/classes/Design/DesignTypesDescription.ts +0 -119
- package/src/classes/Design/DesignTypesMake.ts +0 -460
- package/src/classes/Design/DesignTypesMcp.ts +0 -90
- package/src/classes/Design/DesignTypesPrompts.ts +0 -332
- package/src/classes/Design/DesignTypescript.ts +0 -244
- package/src/classes/Design/DesignUi.ts +0 -143
- package/src/classes/Design/DesignWiki.ts +0 -52
- package/src/classes/Design/DesignWikiStorm.ts +0 -95
- package/src/classes/Design/DesignWikiStormItem.ts +0 -316
- package/src/classes/FigmaApi.ts +0 -190
- package/src/classes/Git/GitRead.ts +0 -261
- package/src/classes/Library/LibraryAiMcpItem.ts +0 -67
- package/src/classes/Library/LibraryAiPrompt.ts +0 -268
- package/src/classes/Library/LibraryAiPromptItem.ts +0 -331
- package/src/classes/Library/LibraryAiWiki.ts +0 -127
- package/src/classes/Library/LibraryAiWikiItem.ts +0 -79
- package/src/classes/Library/LibraryExport.ts +0 -167
- package/src/classes/Library/LibraryFlags.ts +0 -62
- package/src/classes/Library/LibraryItems.ts +0 -138
- package/src/classes/Library/LibraryList.ts +0 -189
- package/src/classes/Library/LibraryMedia.ts +0 -139
- package/src/classes/Library/LibraryPlugin.ts +0 -73
- package/src/classes/Library/LibraryTypes.ts +0 -130
- package/src/classes/Package/PackageFile.ts +0 -154
- package/src/classes/Package/PackageInit.ts +0 -54
- package/src/classes/Package/PackageItem.ts +0 -329
- package/src/classes/Properties/Properties.ts +0 -175
- package/src/classes/Properties/PropertiesCache.ts +0 -248
- package/src/classes/Properties/PropertiesConfig.ts +0 -213
- package/src/classes/Properties/PropertiesConvector.ts +0 -52
- package/src/classes/Properties/PropertiesFile.ts +0 -522
- package/src/classes/Properties/PropertiesImport.ts +0 -182
- package/src/classes/Properties/PropertiesItems.ts +0 -605
- package/src/classes/Properties/PropertiesKeys.ts +0 -121
- package/src/classes/Properties/PropertiesMain.ts +0 -138
- package/src/classes/Properties/PropertiesPalette.ts +0 -149
- package/src/classes/Properties/PropertiesPath.ts +0 -193
- package/src/classes/Properties/PropertiesScss.ts +0 -261
- package/src/classes/Properties/PropertiesSeparator.ts +0 -118
- package/src/classes/Properties/PropertiesSettings.ts +0 -104
- package/src/classes/Properties/PropertiesStandard.ts +0 -180
- package/src/classes/Properties/PropertiesTool.ts +0 -80
- package/src/classes/Properties/PropertiesTypes.ts +0 -147
- package/src/classes/Properties/PropertiesValues.ts +0 -75
- package/src/classes/Properties/PropertiesWrap.ts +0 -187
- package/src/classes/Properties/convector/convectorColor.ts +0 -27
- package/src/classes/Properties/convector/convectorFontFamilies.ts +0 -18
- package/src/classes/Properties/convector/convectorShadow.ts +0 -61
- package/src/classes/Properties/convector/convectorTypography.ts +0 -19
- package/src/classes/Properties/to/PropertiesToAbstract.ts +0 -51
- package/src/classes/Properties/to/PropertiesToAnimate.ts +0 -59
- package/src/classes/Properties/to/PropertiesToClass.ts +0 -49
- package/src/classes/Properties/to/PropertiesToClone.ts +0 -114
- package/src/classes/Properties/to/PropertiesToComponent.ts +0 -52
- package/src/classes/Properties/to/PropertiesToDrag.ts +0 -231
- package/src/classes/Properties/to/PropertiesToDuplicate.ts +0 -165
- package/src/classes/Properties/to/PropertiesToFull.ts +0 -36
- package/src/classes/Properties/to/PropertiesToLink.ts +0 -259
- package/src/classes/Properties/to/PropertiesToMedia.ts +0 -187
- package/src/classes/Properties/to/PropertiesToMulti.ts +0 -101
- package/src/classes/Properties/to/PropertiesToNone.ts +0 -46
- package/src/classes/Properties/to/PropertiesToPalette.ts +0 -241
- package/src/classes/Properties/to/PropertiesToProperty.ts +0 -31
- package/src/classes/Properties/to/PropertiesToRemove.ts +0 -33
- package/src/classes/Properties/to/PropertiesToReplace.ts +0 -77
- package/src/classes/Properties/to/PropertiesToRoot.ts +0 -40
- package/src/classes/Properties/to/PropertiesToSimilar.ts +0 -128
- package/src/classes/Properties/to/PropertiesToSort.ts +0 -146
- package/src/classes/Properties/to/PropertiesToState.ts +0 -65
- package/src/classes/Properties/to/PropertiesToStyle.ts +0 -52
- package/src/classes/Properties/to/PropertiesToSub.ts +0 -95
- package/src/classes/Properties/to/PropertiesToSubclass.ts +0 -76
- package/src/classes/Properties/to/PropertiesToVar.ts +0 -194
- package/src/classes/Properties/to/PropertiesToVariable.ts +0 -176
- package/src/classes/Styles/Styles.ts +0 -247
- package/src/classes/Styles/StylesClasses.ts +0 -86
- package/src/classes/Styles/StylesProperties.ts +0 -197
- package/src/classes/Styles/StylesRoot.ts +0 -103
- package/src/classes/Styles/StylesTool.ts +0 -112
- package/src/classes/Styles/to/StylesToAbstract.ts +0 -93
- package/src/classes/Styles/to/StylesToAnimate.ts +0 -19
- package/src/classes/Styles/to/StylesToClass.ts +0 -25
- package/src/classes/Styles/to/StylesToClassFull.ts +0 -19
- package/src/classes/Styles/to/StylesToContainer.ts +0 -24
- package/src/classes/Styles/to/StylesToMedia.ts +0 -19
- package/src/classes/Styles/to/StylesToProperty.ts +0 -123
- package/src/classes/Styles/to/StylesToRoot.ts +0 -14
- package/src/classes/Styles/to/StylesToSelector.ts +0 -71
- package/src/classes/Styles/to/StylesToVar.ts +0 -105
- package/src/classes/Styles/to/StylesToVirtual.ts +0 -33
- package/src/composables/useAi.ts +0 -38
- package/src/demo/ai.ts +0 -10
- package/src/functions/getComponentPaths.ts +0 -13
- package/src/functions/getConfigAi.ts +0 -14
- package/src/functions/getConstructorProperties.ts +0 -54
- package/src/functions/getDirname.ts +0 -17
- package/src/functions/getNameDirByPaths.ts +0 -16
- package/src/functions/getPackageJson.ts +0 -19
- package/src/functions/hasNativeDirname.ts +0 -8
- package/src/functions/run.ts +0 -47
- package/src/functions/toPathStandardSep.ts +0 -14
- package/src/library-ai.ts +0 -10
- package/src/library.ts +0 -73
- package/src/media/ai/ai-doc-types.ts +0 -21
- package/src/media/properties/css.ts +0 -634
- package/src/media/properties/cssSelector.ts +0 -74
- package/src/media/properties/cssVirtual.ts +0 -12
- package/src/media/properties/listSort.ts +0 -113
- package/src/media/properties/style.ts +0 -81
- package/src/media/templates/component/DesignComponent.mdx +0 -30
- package/src/media/templates/component/DesignComponent.stories.ts +0 -34
- package/src/media/templates/component/DesignComponent.vue +0 -54
- package/src/media/templates/component/DesignComponentAiWiki.vue +0 -25
- package/src/media/templates/component/index.ts +0 -13
- package/src/media/templates/component/props.ts +0 -27
- package/src/media/templates/component/styleToken.scss +0 -17
- package/src/media/templates/component/wiki.ts +0 -13
- package/src/media/templates/component/wikiData.ts +0 -28
- package/src/media/templates/componentDoc/ComponentDoc.vue +0 -26
- package/src/media/templates/componentDoc/index.ts +0 -12
- package/src/media/templates/componentDoc/materials/README.md +0 -8
- package/src/media/templates/componentDoc/materials/prompt.md +0 -38
- package/src/media/templates/componentDoc/subcomponents/_.gitignore.txt +0 -0
- package/src/media/templates/componentDoc/types.ts +0 -15
- package/src/media/templates/componentDoc/wiki/ComponentDoc.mdx +0 -13
- package/src/media/templates/componentDoc/wiki/ComponentDoc.stories.ts +0 -24
- package/src/media/templates/componentDoc/wiki/prompt.md +0 -41
- package/src/media/templates/constructors/Constructors.ts +0 -33
- package/src/media/templates/constructors/ConstructorsDesign.tsx +0 -129
- package/src/media/templates/constructors/basicTypes.ts +0 -0
- package/src/media/templates/constructors/index.ts +0 -5
- package/src/media/templates/constructors/props.ts +0 -28
- package/src/media/templates/constructors/style.scss +0 -5
- package/src/media/templates/constructors/types.ts +0 -47
- package/src/media/templates/packages/figma/README.md +0 -1
- package/src/media/templates/packages/figma/_.gitignore.txt +0 -29
- package/src/media/templates/packages/figma/ai.sample.config.ts +0 -2
- package/src/media/templates/packages/figma/design.config.json +0 -3
- package/src/media/templates/packages/figma/index.html +0 -12
- package/src/media/templates/packages/figma/manifest.json +0 -25
- package/src/media/templates/packages/figma/package.json +0 -37
- package/src/media/templates/packages/figma/src/App.vue +0 -9
- package/src/media/templates/packages/figma/src/classes/_.gitignore.txt +0 -1
- package/src/media/templates/packages/figma/src/code.ts +0 -16
- package/src/media/templates/packages/figma/src/components/_.gitignore.txt +0 -1
- package/src/media/templates/packages/figma/src/composables/_.gitignore.txt +0 -1
- package/src/media/templates/packages/figma/src/config.ts +0 -0
- package/src/media/templates/packages/figma/src/functions/_.gitignore.txt +0 -1
- package/src/media/templates/packages/figma/src/library.ts +0 -0
- package/src/media/templates/packages/figma/src/main.ts +0 -4
- package/src/media/templates/packages/figma/src/media/_.gitignore.txt +0 -1
- package/src/media/templates/packages/figma/src/storybook/_.gitignore.txt +0 -1
- package/src/media/templates/packages/figma/src/types/_.gitignore.txt +0 -1
- package/src/media/templates/packages/figma/src/vite-env.d.ts +0 -1
- package/src/media/templates/packages/figma/tsconfig.app.json +0 -12
- package/src/media/templates/packages/figma/tsconfig.json +0 -7
- package/src/media/templates/packages/figma/tsconfig.node.json +0 -8
- package/src/media/templates/packages/figma/vite.config.ts +0 -7
- package/src/media/templates/packages/library/README.md +0 -1
- package/src/media/templates/packages/library/_.gitignore.txt +0 -27
- package/src/media/templates/packages/library/ai-description.md +0 -15
- package/src/media/templates/packages/library/design.config.json +0 -3
- package/src/media/templates/packages/library/index.html +0 -12
- package/src/media/templates/packages/library/materials/README.md +0 -8
- package/src/media/templates/packages/library/materials/prompt.md +0 -45
- package/src/media/templates/packages/library/package.json +0 -46
- package/src/media/templates/packages/library/src/App.vue +0 -8
- package/src/media/templates/packages/library/src/classes/_.gitignore.txt +0 -1
- package/src/media/templates/packages/library/src/components/_.gitignore.txt +0 -1
- package/src/media/templates/packages/library/src/composables/_.gitignore.txt +0 -1
- package/src/media/templates/packages/library/src/functions/_.gitignore.txt +0 -1
- package/src/media/templates/packages/library/src/library.ts +0 -0
- package/src/media/templates/packages/library/src/main.ts +0 -6
- package/src/media/templates/packages/library/src/style.scss +0 -0
- package/src/media/templates/packages/library/src/types/_.gitignore.txt +0 -1
- package/src/media/templates/packages/library/src/vite-env.d.ts +0 -1
- package/src/media/templates/packages/library/tsconfig.app.json +0 -11
- package/src/media/templates/packages/library/tsconfig.json +0 -7
- package/src/media/templates/packages/library/tsconfig.node.json +0 -7
- package/src/media/templates/packages/library/vite.config.ts +0 -14
- package/src/media/templates/packages/nitro/README.md +0 -1
- package/src/media/templates/packages/nitro/_.gitignore.txt +0 -28
- package/src/media/templates/packages/nitro/index.html +0 -2
- package/src/media/templates/packages/nitro/package.json +0 -25
- package/src/media/templates/packages/nitro/server/plugins/ui-plugin.ts +0 -7
- package/src/media/templates/packages/nitro/server/routes/api/hello.ts +0 -13
- package/src/media/templates/packages/nitro/src/App.vue +0 -10
- package/src/media/templates/packages/nitro/src/assets/_.gitignore.txt +0 -0
- package/src/media/templates/packages/nitro/src/components/_.gitignore.txt +0 -0
- package/src/media/templates/packages/nitro/src/composables/_.gitignore.txt +0 -0
- package/src/media/templates/packages/nitro/src/entry-client.ts +0 -13
- package/src/media/templates/packages/nitro/src/entry-server.ts +0 -29
- package/src/media/templates/packages/nitro/src/main.ts +0 -14
- package/src/media/templates/packages/nitro/src/pages/HomePage.vue +0 -8
- package/src/media/templates/packages/nitro/src/router.ts +0 -11
- package/src/media/templates/packages/nitro/src/style.scss +0 -0
- package/src/media/templates/packages/nitro/src/templates/main.html +0 -21
- package/src/media/templates/packages/nitro/src/vite-env.d.ts +0 -11
- package/src/media/templates/packages/nitro/tsconfig.app.json +0 -14
- package/src/media/templates/packages/nitro/tsconfig.json +0 -7
- package/src/media/templates/packages/nitro/tsconfig.node.json +0 -12
- package/src/media/templates/packages/nitro/vite.config.ts +0 -17
- package/src/media/templates/packages/project/README.md +0 -1
- package/src/media/templates/packages/project/_.gitignore.txt +0 -28
- package/src/media/templates/packages/project/design.config.json +0 -3
- package/src/media/templates/packages/project/index.html +0 -12
- package/src/media/templates/packages/project/materials/README.md +0 -8
- package/src/media/templates/packages/project/materials/prompt.md +0 -41
- package/src/media/templates/packages/project/package.json +0 -13
- package/src/media/templates/packages/project/public/_.gitignore.txt +0 -0
- package/src/media/templates/packages/project/src/App.vue +0 -12
- package/src/media/templates/packages/project/src/assets/_.gitignore.txt +0 -0
- package/src/media/templates/packages/project/src/components/_.gitignore.txt +0 -0
- package/src/media/templates/packages/project/src/composables/_.gitignore.txt +0 -0
- package/src/media/templates/packages/project/src/main.ts +0 -6
- package/src/media/templates/packages/project/src/style.scss +0 -0
- package/src/media/templates/packages/project/src/vite-env.d.ts +0 -1
- package/src/media/templates/packages/project/tsconfig.app.json +0 -11
- package/src/media/templates/packages/project/tsconfig.json +0 -7
- package/src/media/templates/packages/project/tsconfig.node.json +0 -7
- package/src/media/templates/packages/project/vite.config.ts +0 -7
- package/src/media/templates/prompts/aiCodeGlobalPrompt.en.md +0 -22
- package/src/media/templates/prompts/aiCodeGlobalPrompt.ru.md +0 -21
- package/src/media/templates/prompts/aiCodeVuePrompt.en.md +0 -17
- package/src/media/templates/prompts/aiCodeVuePrompt.ru.md +0 -17
- package/src/media/templates/prompts/aiDocClassPrompt.en.txt +0 -63
- package/src/media/templates/prompts/aiDocClassPrompt.ru.txt +0 -63
- package/src/media/templates/prompts/aiDocComposablePrompt.en.txt +0 -67
- package/src/media/templates/prompts/aiDocComposablePrompt.ru.txt +0 -67
- package/src/media/templates/prompts/aiDocFunctionPrompt.en.txt +0 -57
- package/src/media/templates/prompts/aiDocFunctionPrompt.ru.txt +0 -57
- package/src/media/templates/prompts/componentPrompt.en.txt +0 -182
- package/src/media/templates/prompts/componentPrompt.ru.txt +0 -182
- package/src/media/templates/prompts/demoClassEn.mdx +0 -111
- package/src/media/templates/prompts/demoClassRu.mdx +0 -111
- package/src/media/templates/prompts/demoComponentEn.mdx +0 -282
- package/src/media/templates/prompts/demoComponentRu.mdx +0 -282
- package/src/media/templates/prompts/demoComposableEn.mdx +0 -103
- package/src/media/templates/prompts/demoComposableRu.mdx +0 -103
- package/src/media/templates/prompts/demoDocEn.mdx +0 -30
- package/src/media/templates/prompts/demoDocRu.mdx +0 -30
- package/src/media/templates/viteComponentTemplateConfig.ts +0 -14
- package/src/types/aiTypes.ts +0 -19
- package/src/types/configTypes.ts +0 -69
- package/src/types/designTypes.ts +0 -167
- package/src/types/figmaApiTypes.ts +0 -337
- package/src/types/gitTypes.ts +0 -59
- package/src/types/libraryTypes.ts +0 -49
- package/src/types/propertyTypes.ts +0 -586
- package/src/types/screenshotTypes.ts +0 -55
- package/src/types/webTypes.ts +0 -134
- package/src/vite-env.d.ts +0 -1
package/dist/library.js
ADDED
|
@@ -0,0 +1,1436 @@
|
|
|
1
|
+
import { a as e, c as t, i as n, l as r, n as i, o as a, r as o, s, t as c, u as l } from "./AiZAi-x3CInynJ.js";
|
|
2
|
+
import { n as u, t as d } from "./PropertiesConfig-ChizwW5y.js";
|
|
3
|
+
import { UI_DIRS_FILE_EXPORT as ee, UI_DIRS_LIST_EXPORT as te, UI_DIR_AI_PROMPT_SCREENSHOT as f, UI_DIR_AI_TYPES_LIST as p, UI_DIR_PACKAGES as ne, UI_DIR_RESOURCES as re, UI_FILE_AI_DESCRIPTION as m, UI_FILE_AI_MCP as h, UI_FILE_AI_MCP_ALL as g, UI_FILE_AI_MCP_ALL_TS as ie, UI_FILE_AI_PROMPT_DESCRIPTION as _, UI_FILE_AI_PROMPT_DEVELOPER as v, UI_FILE_AI_PROMPT_INFO as y, UI_FILE_AI_PROMPT_INSTRUCTION as ae, UI_FILE_AI_PROMPT_PROMPT as b, UI_FILE_AI_PROMPT_TYPES as x, UI_FILE_AI_TYPES as S, UI_FILE_PACKAGE as oe, UI_FLAG_NOT_EXPORT as se, UI_MODULES as C } from "./config.js";
|
|
4
|
+
import { a as w, i as ce, n as le, r as ue, t as de } from "./propertyTypes-DflziKuR.js";
|
|
5
|
+
import { n as fe, t as pe } from "./figmaApiTypes-CArSsNW8.js";
|
|
6
|
+
import { Datetime as me, ServerStorage as T, forEach as E, isArray as D, isFilled as O, isObject as he, isString as k, removeCommonPrefix as ge, sleep as _e, toArray as A, toCamelCaseFirst as j } from "@dxtmisha/functional-basic";
|
|
7
|
+
import { execFile as M, execSync as N, spawn as ve } from "node:child_process";
|
|
8
|
+
import { promisify as P } from "node:util";
|
|
9
|
+
import { createHash as ye } from "node:crypto";
|
|
10
|
+
import F from "typescript";
|
|
11
|
+
//#region src/classes/Ai/AiClaudeAgentLite.ts
|
|
12
|
+
var I = class extends l {
|
|
13
|
+
async init() {
|
|
14
|
+
this.ai = {};
|
|
15
|
+
}
|
|
16
|
+
toImages() {
|
|
17
|
+
return [];
|
|
18
|
+
}
|
|
19
|
+
toContents() {
|
|
20
|
+
return this.contents.join("\n\n");
|
|
21
|
+
}
|
|
22
|
+
async response(e, t) {
|
|
23
|
+
let n = [this.toContents(), t].filter(Boolean).join("\n\n");
|
|
24
|
+
try {
|
|
25
|
+
let { query: t } = await import("@anthropic-ai/claude-agent-sdk"), r = t({
|
|
26
|
+
prompt: n,
|
|
27
|
+
options: {
|
|
28
|
+
model: e || void 0,
|
|
29
|
+
env: {
|
|
30
|
+
...process.env,
|
|
31
|
+
ANTHROPIC_API_KEY: this.key
|
|
32
|
+
},
|
|
33
|
+
permissionMode: "acceptEdits",
|
|
34
|
+
allowDangerouslySkipPermissions: !0,
|
|
35
|
+
...this.config
|
|
36
|
+
}
|
|
37
|
+
}), i = "";
|
|
38
|
+
for await (let e of r) e.type === "result" && e.subtype === "success" && (i = e.result);
|
|
39
|
+
return i.trim();
|
|
40
|
+
} catch (e) {
|
|
41
|
+
return console.error("[AiClaudeAgent] Error:", e), "";
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}, L = class extends I {
|
|
45
|
+
constructor() {
|
|
46
|
+
super(...r());
|
|
47
|
+
}
|
|
48
|
+
}, be = "./ai-tmp", R = class e {
|
|
49
|
+
static idFileGlobal = 0;
|
|
50
|
+
createdFiles = [];
|
|
51
|
+
getFileName() {
|
|
52
|
+
return e.idFileGlobal += 1, `${be}/Prompt-${e.idFileGlobal}.txt`;
|
|
53
|
+
}
|
|
54
|
+
createFile(e) {
|
|
55
|
+
let t = this.getFileName();
|
|
56
|
+
return this.createdFiles.push(t), u.writeByPath(t, e.trim()), `Please read the following file as it contains the prompt instructions: @${t}`;
|
|
57
|
+
}
|
|
58
|
+
removeFile() {
|
|
59
|
+
for (let e of this.createdFiles) u.removeFile(e);
|
|
60
|
+
this.createdFiles.length = 0;
|
|
61
|
+
}
|
|
62
|
+
}, z = class extends l {
|
|
63
|
+
tmp = new R();
|
|
64
|
+
async init() {
|
|
65
|
+
this.ai = {};
|
|
66
|
+
}
|
|
67
|
+
toImages() {
|
|
68
|
+
return [];
|
|
69
|
+
}
|
|
70
|
+
toContents() {
|
|
71
|
+
return E(this.contents, (e) => this.tmp.createFile(e));
|
|
72
|
+
}
|
|
73
|
+
async response(e, t) {
|
|
74
|
+
return new Promise((n) => {
|
|
75
|
+
let r = [`${[...this.toContents(), this.tmp.createFile(t)].join("\n\n##################\n\n")} -- Output strictly the code/answer. No preamble, no chatter, no reasoning`, ...e ? ["--model", e] : []];
|
|
76
|
+
try {
|
|
77
|
+
M("claude", r, {
|
|
78
|
+
encoding: "utf8",
|
|
79
|
+
env: { ...process.env }
|
|
80
|
+
}, (e, t, r) => {
|
|
81
|
+
e ? (console.error("Error executing Claude CLI:", r || e.message), n("")) : n(t.trim()), this.tmp.removeFile();
|
|
82
|
+
});
|
|
83
|
+
} catch {
|
|
84
|
+
this.tmp.removeFile();
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}, B = class extends z {
|
|
89
|
+
constructor() {
|
|
90
|
+
super(...r());
|
|
91
|
+
}
|
|
92
|
+
}, V = class extends l {
|
|
93
|
+
tmp = new R();
|
|
94
|
+
async init() {
|
|
95
|
+
this.ai = {};
|
|
96
|
+
}
|
|
97
|
+
toImages() {
|
|
98
|
+
return [];
|
|
99
|
+
}
|
|
100
|
+
toContents() {
|
|
101
|
+
return E(this.contents, (e) => this.tmp.createFile(e));
|
|
102
|
+
}
|
|
103
|
+
async response(e, t) {
|
|
104
|
+
return new Promise((n) => {
|
|
105
|
+
let r = [
|
|
106
|
+
`${[...this.toContents(), this.tmp.createFile(t)].join("\n\n##################\n\n")} -- Output strictly the code/answer. No preamble, no chatter, no reasoning`,
|
|
107
|
+
...e ? ["--model", e] : [],
|
|
108
|
+
"--yolo"
|
|
109
|
+
];
|
|
110
|
+
try {
|
|
111
|
+
M("gemini", r, {
|
|
112
|
+
encoding: "utf8",
|
|
113
|
+
env: { ...process.env }
|
|
114
|
+
}, (e, t, r) => {
|
|
115
|
+
e ? (console.error("Error executing Gemini CLI:", r || e.message), n("")) : n(t.trim()), this.tmp.removeFile();
|
|
116
|
+
});
|
|
117
|
+
} catch {
|
|
118
|
+
this.tmp.removeFile();
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
}, H = class extends V {
|
|
123
|
+
constructor() {
|
|
124
|
+
super(...r());
|
|
125
|
+
}
|
|
126
|
+
}, xe = [
|
|
127
|
+
"--no-sandbox",
|
|
128
|
+
"--disable-setuid-sandbox",
|
|
129
|
+
"--disable-dev-shm-usage"
|
|
130
|
+
], Se = "webp", Ce = 1080, we = 80, Te = 32e4, U = ["networkidle0", "domcontentloaded"], Ee = 1920, W = class {
|
|
131
|
+
url;
|
|
132
|
+
options;
|
|
133
|
+
browser;
|
|
134
|
+
page;
|
|
135
|
+
response;
|
|
136
|
+
pageWidth = -1;
|
|
137
|
+
pageHeight = -1;
|
|
138
|
+
constructor(e, t = {}) {
|
|
139
|
+
this.url = e, this.options = t;
|
|
140
|
+
}
|
|
141
|
+
get args() {
|
|
142
|
+
return this.options.args ?? xe;
|
|
143
|
+
}
|
|
144
|
+
get waitUntil() {
|
|
145
|
+
return this.options.waitUntil ?? U;
|
|
146
|
+
}
|
|
147
|
+
get timeout() {
|
|
148
|
+
return this.options.timeout ?? 32e4;
|
|
149
|
+
}
|
|
150
|
+
get format() {
|
|
151
|
+
return this.options.format ?? "webp";
|
|
152
|
+
}
|
|
153
|
+
get width() {
|
|
154
|
+
return this.options.width ?? 1920;
|
|
155
|
+
}
|
|
156
|
+
get height() {
|
|
157
|
+
return this.options.height ?? 1080;
|
|
158
|
+
}
|
|
159
|
+
get quality() {
|
|
160
|
+
return this.options.quality ?? 80;
|
|
161
|
+
}
|
|
162
|
+
get fullPage() {
|
|
163
|
+
return this.options.fullPage ?? !1;
|
|
164
|
+
}
|
|
165
|
+
get extension() {
|
|
166
|
+
let e = this.format;
|
|
167
|
+
return e === "jpeg" ? ".jpg" : `.${e}`;
|
|
168
|
+
}
|
|
169
|
+
async getBrowser() {
|
|
170
|
+
if (!this.browser) {
|
|
171
|
+
let { launch: e } = await import("puppeteer");
|
|
172
|
+
this.browser = await e({
|
|
173
|
+
headless: !0,
|
|
174
|
+
args: this.args
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
return this.browser;
|
|
178
|
+
}
|
|
179
|
+
async getPage() {
|
|
180
|
+
return this.page || (this.page = await (await this.getBrowser()).newPage(), await this.page.setViewport({
|
|
181
|
+
width: this.width,
|
|
182
|
+
height: this.height
|
|
183
|
+
}), this.page.on("console", (e) => this.toConsole(`Log: ${e.text()}`)), this.page.on("pageerror", (e) => this.toConsole(`Error: ${e?.message}`))), this.page;
|
|
184
|
+
}
|
|
185
|
+
async getResponse() {
|
|
186
|
+
if (!this.response) {
|
|
187
|
+
let e = await (await this.getPage()).goto(this.url, {
|
|
188
|
+
waitUntil: this.waitUntil,
|
|
189
|
+
timeout: this.timeout
|
|
190
|
+
});
|
|
191
|
+
e && e.ok() ? this.response = e : this.toConsole(`Failed to load page: ${this.url}. Status: ${e?.status()}`);
|
|
192
|
+
}
|
|
193
|
+
return this.response;
|
|
194
|
+
}
|
|
195
|
+
async getDom() {
|
|
196
|
+
return await (await this.getPage()).content();
|
|
197
|
+
}
|
|
198
|
+
async getBody() {
|
|
199
|
+
return await this.evaluate(() => document.body.innerHTML) ?? "";
|
|
200
|
+
}
|
|
201
|
+
async getStyles() {
|
|
202
|
+
return await this.evaluate(() => Array.from(document.styleSheets).map((e) => {
|
|
203
|
+
try {
|
|
204
|
+
return Array.from(e.cssRules).map((e) => e.cssText).join("\n");
|
|
205
|
+
} catch (e) {
|
|
206
|
+
return console.error("Error getting CSS rules:", e), "";
|
|
207
|
+
}
|
|
208
|
+
}).join("\n")) ?? "";
|
|
209
|
+
}
|
|
210
|
+
async getMetrics() {
|
|
211
|
+
if (await this.getResponse() && (this.pageWidth === -1 || this.pageHeight === -1)) {
|
|
212
|
+
let e = await this.evaluate(() => ({
|
|
213
|
+
height: document.documentElement.scrollHeight,
|
|
214
|
+
width: document.documentElement.scrollWidth
|
|
215
|
+
}));
|
|
216
|
+
e && (this.pageWidth = e.width, this.pageHeight = e.height);
|
|
217
|
+
}
|
|
218
|
+
return {
|
|
219
|
+
height: this.pageHeight,
|
|
220
|
+
width: this.pageWidth
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
async evaluate(e, ...t) {
|
|
224
|
+
return await (await this.getPage()).evaluate(e, ...t);
|
|
225
|
+
}
|
|
226
|
+
async screenshot(e) {
|
|
227
|
+
return this.fullPage ? await this.screenshotFull(e) : await this.screenshotPages(e), this;
|
|
228
|
+
}
|
|
229
|
+
async reset() {
|
|
230
|
+
return this.page = void 0, this.pageWidth = -1, this.pageHeight = -1, this.response = void 0, this;
|
|
231
|
+
}
|
|
232
|
+
getOutputPath(e, t = 1, n = 1) {
|
|
233
|
+
return this.fullPage ? e + this.extension : e + `-${n}_${t}` + this.extension;
|
|
234
|
+
}
|
|
235
|
+
async saveScreenshot(e) {
|
|
236
|
+
let t = this.format, n = t === "png" ? void 0 : this.quality;
|
|
237
|
+
return await (await this.getPage()).screenshot({
|
|
238
|
+
path: e,
|
|
239
|
+
type: t,
|
|
240
|
+
quality: n,
|
|
241
|
+
fullPage: this.fullPage
|
|
242
|
+
}), this;
|
|
243
|
+
}
|
|
244
|
+
async screenshotPages(e) {
|
|
245
|
+
let { height: t } = await this.getMetrics(), n = this.height, r = Math.ceil(t / n);
|
|
246
|
+
this.toConsole(`Page height: ${t}px, viewport height: ${n}px, total pages: ${r}`);
|
|
247
|
+
for (let t = 0; t < r; t++) {
|
|
248
|
+
let i = t * n, a = this.getOutputPath(e, t + 1, r);
|
|
249
|
+
await this.evaluate((e) => window.scrollTo(0, e), i), await _e(320), await this.saveScreenshot(a), this.toConsole(`Saved screenshot page ${t + 1}/${r} to ${a}`);
|
|
250
|
+
}
|
|
251
|
+
return this;
|
|
252
|
+
}
|
|
253
|
+
async screenshotFull(e) {
|
|
254
|
+
let t = this.getOutputPath(e);
|
|
255
|
+
return await this.saveScreenshot(t), this.toConsole(`Saved full page screenshot to ${t}`), this;
|
|
256
|
+
}
|
|
257
|
+
toConsole(e) {
|
|
258
|
+
console.log("Browser", e);
|
|
259
|
+
}
|
|
260
|
+
}, G = class {
|
|
261
|
+
path;
|
|
262
|
+
data;
|
|
263
|
+
constructor(e) {
|
|
264
|
+
this.path = e, this.data = u.readFile(this.getPath()) ?? {};
|
|
265
|
+
}
|
|
266
|
+
is() {
|
|
267
|
+
return u.is(this.getPath());
|
|
268
|
+
}
|
|
269
|
+
isVersionConsistency(e) {
|
|
270
|
+
return !!e && this.getVersion() === e;
|
|
271
|
+
}
|
|
272
|
+
isTest() {
|
|
273
|
+
return this.get()?.["ui-test"] === !0;
|
|
274
|
+
}
|
|
275
|
+
isNoPublish() {
|
|
276
|
+
let e = this.get();
|
|
277
|
+
return e?.["ui-no-publish"] === !0 || e?.private === !0;
|
|
278
|
+
}
|
|
279
|
+
get() {
|
|
280
|
+
return this.data;
|
|
281
|
+
}
|
|
282
|
+
getName() {
|
|
283
|
+
return this.get()?.name ?? u.joinPath(this.getDir());
|
|
284
|
+
}
|
|
285
|
+
getVersion() {
|
|
286
|
+
return this.get()?.version ?? "0.0.0";
|
|
287
|
+
}
|
|
288
|
+
getScripts() {
|
|
289
|
+
return this.get()?.scripts ?? {};
|
|
290
|
+
}
|
|
291
|
+
getDir() {
|
|
292
|
+
return A(this.path);
|
|
293
|
+
}
|
|
294
|
+
getPath() {
|
|
295
|
+
return [...this.getDir(), oe];
|
|
296
|
+
}
|
|
297
|
+
getCodeBuildOrRecovery() {
|
|
298
|
+
let e = this.getScripts();
|
|
299
|
+
if ("prepublishOnly" in e) return "npm run prepublishOnly";
|
|
300
|
+
if ("build-recovery" in e) return "npm run build-recovery";
|
|
301
|
+
if ("build" in e) return "npm run build";
|
|
302
|
+
}
|
|
303
|
+
getCodePublish() {
|
|
304
|
+
return "publish-to-npm" in this.getScripts() ? "npm run publish-to-npm" : "npm publish --access public";
|
|
305
|
+
}
|
|
306
|
+
}, De = P(M);
|
|
307
|
+
async function K(e, t, n = !1, r = !1) {
|
|
308
|
+
let i = e.getName(), [a, ...o] = t.split(" ");
|
|
309
|
+
try {
|
|
310
|
+
let { stdout: s, stderr: c } = await De(a, o, { cwd: u.joinPath(e.getDir()) });
|
|
311
|
+
return console.log(`Command ${t} for ${i}`), s && n && console.log(s), c && r && console.error(c), !0;
|
|
312
|
+
} catch (e) {
|
|
313
|
+
return console.error(`Error command ${t} for ${i}:`, e), !1;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
//#endregion
|
|
317
|
+
//#region src/classes/Build/BuildPackages.ts
|
|
318
|
+
var q = [
|
|
319
|
+
".",
|
|
320
|
+
"logs",
|
|
321
|
+
"ui-build.log.json"
|
|
322
|
+
], Oe = class {
|
|
323
|
+
path;
|
|
324
|
+
log;
|
|
325
|
+
constructor(e = ne) {
|
|
326
|
+
this.path = e, this.log = u.readFile(q) ?? {};
|
|
327
|
+
}
|
|
328
|
+
async make() {
|
|
329
|
+
let e = this.getList(), t = 0;
|
|
330
|
+
console.info(`Build packages(${e.length})...`);
|
|
331
|
+
for (let n of e) this.isUpdate(n) && await this.build(n) && (this.updateLog(n), t++);
|
|
332
|
+
this.saveLog(), console.info(t > 0 ? `Build packages changed: ${t}` : "Build packages - no changes");
|
|
333
|
+
}
|
|
334
|
+
async build(e) {
|
|
335
|
+
let t = e.getCodeBuildOrRecovery();
|
|
336
|
+
return t ? await K(e, t) : !1;
|
|
337
|
+
}
|
|
338
|
+
isUpdate(e) {
|
|
339
|
+
return !e.isVersionConsistency(this.getVersionLog(e.getName()));
|
|
340
|
+
}
|
|
341
|
+
getList() {
|
|
342
|
+
let e = u.readDir(this.path), t = [];
|
|
343
|
+
for (let n of e) {
|
|
344
|
+
let e = new G([this.path, n]);
|
|
345
|
+
e.is() && !e.isTest() && t.push(e);
|
|
346
|
+
}
|
|
347
|
+
return t.sort((e, t) => (e.get()?.["ui-priority"] ?? 500) - (t.get()?.["ui-priority"] ?? 500));
|
|
348
|
+
}
|
|
349
|
+
getVersionLog(e) {
|
|
350
|
+
return this.log?.[e] ?? "0.0.0";
|
|
351
|
+
}
|
|
352
|
+
updateLog(e) {
|
|
353
|
+
this.log[e.getName()] = e.getVersion();
|
|
354
|
+
}
|
|
355
|
+
saveLog() {
|
|
356
|
+
u.writeByPath(q, this.log);
|
|
357
|
+
}
|
|
358
|
+
}, ke = P(M), Ae = class {
|
|
359
|
+
path;
|
|
360
|
+
constructor(e = ne) {
|
|
361
|
+
this.path = e;
|
|
362
|
+
}
|
|
363
|
+
async make() {
|
|
364
|
+
let e = u.readDir(this.path), t = 0;
|
|
365
|
+
console.info(`Publish packages(${e.length})...`);
|
|
366
|
+
for (let n of e) {
|
|
367
|
+
let e = new G([this.path, n]);
|
|
368
|
+
e.is() && !e.isNoPublish() && await this.isUpdate(e) && await K(e, e.getCodePublish(), !0, !0) && t++;
|
|
369
|
+
}
|
|
370
|
+
console.info(t > 0 ? `Publish packages changed: ${t}` : "Publish packages - no changes");
|
|
371
|
+
}
|
|
372
|
+
async isUpdate(e) {
|
|
373
|
+
let t = await this.getNpmVersion(e.getName());
|
|
374
|
+
return t === void 0 || !e.isVersionConsistency(t);
|
|
375
|
+
}
|
|
376
|
+
async getNpmVersion(e) {
|
|
377
|
+
try {
|
|
378
|
+
let { stdout: t } = await ke("npm", [
|
|
379
|
+
"view",
|
|
380
|
+
e,
|
|
381
|
+
"version"
|
|
382
|
+
]);
|
|
383
|
+
return t.trim() || void 0;
|
|
384
|
+
} catch {
|
|
385
|
+
return;
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
}, je = class {
|
|
389
|
+
file;
|
|
390
|
+
isReading = !1;
|
|
391
|
+
url;
|
|
392
|
+
constructor(e = "./ai-screenshot/screenshot") {
|
|
393
|
+
this.file = e, T.setErrorStatus(!0);
|
|
394
|
+
}
|
|
395
|
+
async make() {
|
|
396
|
+
console.info("Screenshot");
|
|
397
|
+
let e = u.getPathDir(`${this.file}.file`);
|
|
398
|
+
return u.removeDir(e), u.createDir(e), this.makeServer(), this;
|
|
399
|
+
}
|
|
400
|
+
listener = async () => {
|
|
401
|
+
if (this.url && !this.isReading) {
|
|
402
|
+
this.isReading = !0, console.info("URL", this.url);
|
|
403
|
+
let e = new W(this.url, { height: 12288 });
|
|
404
|
+
return await e.screenshot(this.file), u.writeByPath(`${this.file}-code.html`, await e.getBody()), u.writeByPath(`${this.file}-styles.css`, await e.getStyles()), !0;
|
|
405
|
+
}
|
|
406
|
+
return !1;
|
|
407
|
+
};
|
|
408
|
+
makeServer() {
|
|
409
|
+
let e = ve("npm", ["run", "dev"], {
|
|
410
|
+
shell: !0,
|
|
411
|
+
stdio: "pipe"
|
|
412
|
+
});
|
|
413
|
+
return e.stdout?.on("data", (t) => {
|
|
414
|
+
console.log("Server", "start");
|
|
415
|
+
let n = t.toString();
|
|
416
|
+
this.makeUrl(n), this.url && (console.info("Server", "init"), this.listener().then((t) => {
|
|
417
|
+
t && (e.kill(), console.info("Server", "kill"), process.exit(0));
|
|
418
|
+
}));
|
|
419
|
+
}), e.stderr?.on("data", (e) => {
|
|
420
|
+
console.error(`Server Error: ${e.toString()}`);
|
|
421
|
+
}), this;
|
|
422
|
+
}
|
|
423
|
+
makeUrl(e) {
|
|
424
|
+
let t = e.match(/(https?:\/\/localhost\S+)/);
|
|
425
|
+
return t && (this.url = t[1]), this;
|
|
426
|
+
}
|
|
427
|
+
}, Me = /* @__PURE__ */ new Map([
|
|
428
|
+
["claude", () => new s()],
|
|
429
|
+
["claude-agent", () => new L()],
|
|
430
|
+
["claude-cli", () => new B()],
|
|
431
|
+
["gemini", () => new e()],
|
|
432
|
+
["gemini-cli", () => new H()],
|
|
433
|
+
["openai", () => new o()],
|
|
434
|
+
["zai", () => new c()]
|
|
435
|
+
]);
|
|
436
|
+
function J() {
|
|
437
|
+
let e = d.getAiType();
|
|
438
|
+
return Me.get(e)?.();
|
|
439
|
+
}
|
|
440
|
+
//#endregion
|
|
441
|
+
//#region src/classes/Design/DesignTypesAi.ts
|
|
442
|
+
var Y = class {
|
|
443
|
+
dir;
|
|
444
|
+
projectName;
|
|
445
|
+
dirArray;
|
|
446
|
+
constructor(e = d.getTypesTemporaryDirectory()) {
|
|
447
|
+
this.dir = e, this.dirArray = this.dir.split("/"), this.projectName = w()?.name ?? "none";
|
|
448
|
+
}
|
|
449
|
+
isFile(e) {
|
|
450
|
+
return e.endsWith(".d.ts");
|
|
451
|
+
}
|
|
452
|
+
isFileJs(e) {
|
|
453
|
+
return e.endsWith(".js");
|
|
454
|
+
}
|
|
455
|
+
getDirArray() {
|
|
456
|
+
return this.dirArray;
|
|
457
|
+
}
|
|
458
|
+
getMd5(e) {
|
|
459
|
+
return ye("md5").update(e.trim()).digest("hex");
|
|
460
|
+
}
|
|
461
|
+
getProjectName() {
|
|
462
|
+
return this.projectName;
|
|
463
|
+
}
|
|
464
|
+
async toAi(e, t, n) {
|
|
465
|
+
let r = J();
|
|
466
|
+
if (r) {
|
|
467
|
+
n && r.addPrompt(`File JS Code (SUPPLEMENTARY REFERENCE & CONTEXT ONLY):
|
|
468
|
+
The following JavaScript code is provided STRICTLY as supplementary background context to give a full picture of implementation details and logic.
|
|
469
|
+
CRITICAL RESTRICTION: You MUST NOT treat or use this data as "File Content". Do NOT generate, return, or include any classes, methods, functions, or entities from "File JS Code" in the output unless they are explicitly present in "File Content".
|
|
470
|
+
|
|
471
|
+
\`\`\`
|
|
472
|
+
${n}\n\`\`\``), r.addPrompt("You are a world-class senior developer and an exceptional technical writer."), r.addPrompt("CRITICAL DIRECTIVE: No data stored in history, previous chat messages, or prior conversation context must influence the result. Process strictly and exclusively the data provided in the text below."), r.addPrompt(`TASK INSTRUCTIONS & GOAL:
|
|
473
|
+
The following are the exact rules, requirements, and execution instructions for processing the file content:
|
|
474
|
+
|
|
475
|
+
${t}`), r.addPrompt(`File Content (PRIMARY DATA TO PROCESS):
|
|
476
|
+
The following is the primary target file content that you MUST process according to the instructions in the prompt above:
|
|
477
|
+
\`\`\`
|
|
478
|
+
${e}\n\`\`\``);
|
|
479
|
+
let i = await r.generate("go!");
|
|
480
|
+
if (i) return i;
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
async toAiJson(e, t, n) {
|
|
484
|
+
let r = await this.toAi(e, t, n);
|
|
485
|
+
if (r) try {
|
|
486
|
+
let e = r.replace(/```json|```/g, "").trim();
|
|
487
|
+
return JSON.parse(e);
|
|
488
|
+
} catch {
|
|
489
|
+
return;
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
}, X = class {
|
|
493
|
+
temporaryDirectory;
|
|
494
|
+
constructor(e = d.getTypesTemporaryDirectory()) {
|
|
495
|
+
this.temporaryDirectory = e;
|
|
496
|
+
}
|
|
497
|
+
}, Z = class extends X {
|
|
498
|
+
configuration;
|
|
499
|
+
constructor(e = d.getTypesTemporaryDirectory()) {
|
|
500
|
+
super(e);
|
|
501
|
+
}
|
|
502
|
+
is() {
|
|
503
|
+
return u.is(this.getTemporaryDirectory());
|
|
504
|
+
}
|
|
505
|
+
isVue() {
|
|
506
|
+
if (d.isTypesWithoutVue()) return !1;
|
|
507
|
+
let e = d.getTypesPaths(), t = O(e) ? e : ["src"];
|
|
508
|
+
for (let e of t) {
|
|
509
|
+
let t = this.resolveDirectory(e);
|
|
510
|
+
if (u.is(t)) {
|
|
511
|
+
let e = u.readDirRecursive(t);
|
|
512
|
+
for (let n of e) {
|
|
513
|
+
let e = u.joinPath([t, n]);
|
|
514
|
+
if (n.endsWith(".vue") && this.isAllowed(e)) return !0;
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
return !1;
|
|
519
|
+
}
|
|
520
|
+
build() {
|
|
521
|
+
return this.clean(), this.isVue() ? this.buildVue() : this.buildTs(), this;
|
|
522
|
+
}
|
|
523
|
+
clean() {
|
|
524
|
+
let e = this.getTemporaryDirectory();
|
|
525
|
+
return u.is(e) && u.removeDir(e), this;
|
|
526
|
+
}
|
|
527
|
+
isAllowed(e) {
|
|
528
|
+
return this.isFileTs(e) && this.isPath(e) && this.isMatch(e) && !this.isExclude(e);
|
|
529
|
+
}
|
|
530
|
+
isAllowedDeclaration(e) {
|
|
531
|
+
return this.isFileDts(e) && !e.endsWith("main.d.ts") && !e.endsWith("App.d.ts") && !this.isFileTest(e) && this.isPath(e) && this.isMatch(e) && !this.isExclude(e);
|
|
532
|
+
}
|
|
533
|
+
isExclude(e) {
|
|
534
|
+
return this.isPattern(e, d.getTypesExclude());
|
|
535
|
+
}
|
|
536
|
+
isFileDts(e) {
|
|
537
|
+
return e.endsWith(".d.ts");
|
|
538
|
+
}
|
|
539
|
+
isFileTest(e) {
|
|
540
|
+
return e.includes("__tests__") || !!e.match(/\.(test|spec|stories)\.(ts|tsx|js|vue|d\.ts)$/);
|
|
541
|
+
}
|
|
542
|
+
isFileTs(e) {
|
|
543
|
+
return !!((e.endsWith(".ts") || e.endsWith(".tsx") || e.endsWith(".js") || e.endsWith(".vue")) && !this.isFileDts(e) && !this.isFileTest(e));
|
|
544
|
+
}
|
|
545
|
+
isMatch(e) {
|
|
546
|
+
let t = d.getTypesMatch();
|
|
547
|
+
return !O(t) || this.isPattern(e, t);
|
|
548
|
+
}
|
|
549
|
+
isPath(e) {
|
|
550
|
+
let t = d.getTypesPaths();
|
|
551
|
+
return !O(t) || t.some((t) => {
|
|
552
|
+
let n = t.replace(/^[./\\]+/, "").replace(/[/\\]+$/, ""), r = n.replace(/^src[/\\]/, "");
|
|
553
|
+
return e.startsWith(n) || e.startsWith(`./${n}`) || e.startsWith(r) || e.startsWith(`./${r}`) || e.includes(`/${n}/`) || e.includes(`\\${n}\\`) || e.includes(`/${r}/`) || e.includes(`\\${r}\\`);
|
|
554
|
+
});
|
|
555
|
+
}
|
|
556
|
+
isPattern(e, t) {
|
|
557
|
+
return O(t) ? A(t).some((t) => {
|
|
558
|
+
try {
|
|
559
|
+
return new RegExp(t).test(e);
|
|
560
|
+
} catch {
|
|
561
|
+
return e.includes(t);
|
|
562
|
+
}
|
|
563
|
+
}) : !1;
|
|
564
|
+
}
|
|
565
|
+
getTemporaryDirectory() {
|
|
566
|
+
return this.temporaryDirectory;
|
|
567
|
+
}
|
|
568
|
+
getTsConfigName() {
|
|
569
|
+
if (u.is("tsconfig.app.json")) return "tsconfig.app.json";
|
|
570
|
+
if (u.is("tsconfig.json")) return "tsconfig.json";
|
|
571
|
+
}
|
|
572
|
+
getTsConfiguration() {
|
|
573
|
+
if (this.configuration) return this.configuration;
|
|
574
|
+
let e = u.getRoot(), t = this.getTsConfigName();
|
|
575
|
+
if (t) {
|
|
576
|
+
let n = F.findConfigFile(e, F.sys.fileExists, t);
|
|
577
|
+
if (n) {
|
|
578
|
+
let e = F.readConfigFile(n, F.sys.readFile);
|
|
579
|
+
if (!e.error) return this.configuration = F.parseJsonConfigFileContent(e.config, F.sys, u.getPathDir(n), void 0, n, void 0, [{
|
|
580
|
+
extension: ".vue",
|
|
581
|
+
isMixedContent: !0,
|
|
582
|
+
scriptKind: F.ScriptKind.Deferred
|
|
583
|
+
}]), this.configuration;
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
getTsSourceFiles() {
|
|
588
|
+
let e = this.getTsConfiguration();
|
|
589
|
+
if (e && e.fileNames.length > 0) return e.fileNames.filter((e) => this.isAllowed(e));
|
|
590
|
+
let t = d.getTypesPaths(), n = O(t) ? t : ["src"], r = [];
|
|
591
|
+
for (let e of n) {
|
|
592
|
+
let t = this.resolveDirectory(e);
|
|
593
|
+
if (u.is(t)) {
|
|
594
|
+
let e = u.readDirRecursive(t);
|
|
595
|
+
for (let n of e) {
|
|
596
|
+
let e = u.joinPath([t, n]);
|
|
597
|
+
this.isAllowed(e) && r.push(e);
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
return r;
|
|
602
|
+
}
|
|
603
|
+
buildTs() {
|
|
604
|
+
let e = this.getTemporaryDirectory(), t = this.getTsConfiguration(), n = this.getTsSourceFiles();
|
|
605
|
+
if (n.length > 0) {
|
|
606
|
+
let r = t?.options?.rootDir ?? (u.is("src") ? "src" : void 0), i = {
|
|
607
|
+
...t?.options ?? {},
|
|
608
|
+
declaration: !0,
|
|
609
|
+
emitDeclarationOnly: !0,
|
|
610
|
+
noEmit: !1,
|
|
611
|
+
outDir: e,
|
|
612
|
+
...r ? { rootDir: r } : {}
|
|
613
|
+
}, a = F.createCompilerHost(i);
|
|
614
|
+
F.createProgram(n, i, a).emit(), this.cleanExcess();
|
|
615
|
+
}
|
|
616
|
+
return this;
|
|
617
|
+
}
|
|
618
|
+
buildVue() {
|
|
619
|
+
let e = this.getTsConfigName();
|
|
620
|
+
if (e) {
|
|
621
|
+
let t = `npx vue-tsc -p ${e} --declaration --emitDeclarationOnly --outDir ${this.getTemporaryDirectory()} --noEmit false --rootDir src --noEmitOnError false`;
|
|
622
|
+
try {
|
|
623
|
+
N(t, {
|
|
624
|
+
cwd: u.getRoot(),
|
|
625
|
+
stdio: "pipe"
|
|
626
|
+
});
|
|
627
|
+
} catch (e) {
|
|
628
|
+
console.warn("DesignTypesBuild: vue-tsc compilation executed with output", e);
|
|
629
|
+
}
|
|
630
|
+
this.cleanExcess();
|
|
631
|
+
} else this.buildTs();
|
|
632
|
+
return this;
|
|
633
|
+
}
|
|
634
|
+
cleanExcess() {
|
|
635
|
+
let e = this.getTemporaryDirectory();
|
|
636
|
+
if (u.is(e)) {
|
|
637
|
+
let t = u.readDirRecursive(e);
|
|
638
|
+
for (let n of t) this.isAllowedDeclaration(n) || u.removeFile([e, n]);
|
|
639
|
+
}
|
|
640
|
+
return this;
|
|
641
|
+
}
|
|
642
|
+
resolveDirectory(e) {
|
|
643
|
+
let t = e.replace(/^[./\\]+/, "").replace(/[/\\]+$/, "");
|
|
644
|
+
if (u.is(t)) return t;
|
|
645
|
+
let n = u.joinPath(["src", t]);
|
|
646
|
+
return u.is(n) ? n : u.joinPath(t);
|
|
647
|
+
}
|
|
648
|
+
}, Ne = class {
|
|
649
|
+
ai;
|
|
650
|
+
makeTypes;
|
|
651
|
+
prompts;
|
|
652
|
+
fullDescription;
|
|
653
|
+
constructor(e, t, n) {
|
|
654
|
+
this.ai = e, this.makeTypes = t, this.prompts = n;
|
|
655
|
+
}
|
|
656
|
+
is() {
|
|
657
|
+
return u.is(m);
|
|
658
|
+
}
|
|
659
|
+
getFullDescription() {
|
|
660
|
+
return this.fullDescription ?? "";
|
|
661
|
+
}
|
|
662
|
+
async make() {
|
|
663
|
+
let e = this.makeTypes.getFullContent(), t = this.makeTypes.getFullJsContent(), n = await this.prompts.toAiPrompts(), r = `${await this.toAiDescription(e, t)}\n${n}`;
|
|
664
|
+
return this.fullDescription = r, this.saveDescription(r), this;
|
|
665
|
+
}
|
|
666
|
+
saveDescription(e) {
|
|
667
|
+
u.writeByPath(m, e);
|
|
668
|
+
}
|
|
669
|
+
async toAiDescription(e, t) {
|
|
670
|
+
return !O(e) && !O(t) ? "" : await this.ai.toAi(e, "Goal: Generate a concise package overview for an AI coding assistant detailing what this package is, why to study it, and listing its key capabilities.\n\nSTRUCTURE & CONTENT REQUIREMENTS:\n1. Package Description: 1-2 concise sentences explaining what this package is and its core technical purpose.\n2. Triggers for Studying ai-types.md: Maximally concise yet complete explanation of when and why an AI assistant must study \"ai-types.md\" (specific tasks, keywords, or architectural requirements) without losing any essential information.\n3. Key Capabilities: A single comma-separated list of key functional capabilities (e.g. \"Key Capabilities: Form Controls, API Integration, Storage State\") where each item is strictly 1 to 3 words long.\n\nCRITICAL RESTRICTIONS:\n- Triggers for Studying ai-types.md MUST be maximally concise and dense without omitting any technical triggers or information.\n- Key Capabilities MUST be formatted strictly as a single comma-separated list, NOT as bullet points or separate lines.\n- Each item in the Key Capabilities list MUST be strictly 1 to 3 words.\n- Do NOT list individual method, function, or class names.\n- Analyze ONLY the provided type definitions and JS code.\n- Do NOT wrap output in markdown code blocks (```).\n\nOUTPUT REQUIREMENTS:\nReturn ONLY the final description text. No explanations, no code blocks, and no conversational fluff.\n", t) ?? "";
|
|
671
|
+
}
|
|
672
|
+
}, Pe = class {
|
|
673
|
+
ai;
|
|
674
|
+
dir;
|
|
675
|
+
dirDist;
|
|
676
|
+
constructor(e, t = d.getTypesTemporaryDirectory(), n = d.getDistDir()) {
|
|
677
|
+
this.ai = e, this.dir = t, this.dirDist = n;
|
|
678
|
+
}
|
|
679
|
+
}, Fe = class {
|
|
680
|
+
ai;
|
|
681
|
+
dir;
|
|
682
|
+
dirDist;
|
|
683
|
+
listByFilter;
|
|
684
|
+
listByFilterJs;
|
|
685
|
+
listCache;
|
|
686
|
+
constructor(e, t = d.getTypesTemporaryDirectory(), n = d.getDistDir()) {
|
|
687
|
+
this.ai = e, this.dir = t, this.dirDist = n;
|
|
688
|
+
}
|
|
689
|
+
getListByFilter() {
|
|
690
|
+
return this.listByFilter === void 0 && (this.listByFilter = this.getListBy((e) => this.ai.isFile(e), this.getTemporaryDirectory())), this.listByFilter;
|
|
691
|
+
}
|
|
692
|
+
getListByFilterJs() {
|
|
693
|
+
return this.listByFilterJs === void 0 && (this.listByFilterJs = this.getListBy((e) => this.ai.isFileJs(e), this.getDistDirectory())), this.listByFilterJs;
|
|
694
|
+
}
|
|
695
|
+
getListCache() {
|
|
696
|
+
return this.listCache === void 0 && (this.listCache = this.getListBy((e) => this.ai.isFile(e), p)), this.listCache;
|
|
697
|
+
}
|
|
698
|
+
getListAi(e) {
|
|
699
|
+
return E(e, (e) => {
|
|
700
|
+
let t = u.readFileOnly([p, e.path]), n = t ? t.replace(/^\/\/ md5:[^\n]*\n?/, "") : e.content;
|
|
701
|
+
return {
|
|
702
|
+
...e,
|
|
703
|
+
content: n.trim()
|
|
704
|
+
};
|
|
705
|
+
});
|
|
706
|
+
}
|
|
707
|
+
toOneFile(e) {
|
|
708
|
+
return E(e, (e) => e.content).join("\n\n");
|
|
709
|
+
}
|
|
710
|
+
readFile(e, t = this.getTemporaryDirectory()) {
|
|
711
|
+
return u.readFileOnly(this.getPath(e, t));
|
|
712
|
+
}
|
|
713
|
+
save(e) {
|
|
714
|
+
let t = w();
|
|
715
|
+
if (t) {
|
|
716
|
+
let n = t.version ? ` (v${t.version})` : "";
|
|
717
|
+
u.writeByPath(S, [
|
|
718
|
+
`All these methods are in the ${t.name}${n} library.`,
|
|
719
|
+
"",
|
|
720
|
+
e
|
|
721
|
+
].join("\n"));
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
saveFile(e, t = !1) {
|
|
725
|
+
u.writeByPath([p, e.path], `${this.getMd5Header(e.md5, t)}\n${e.content}`);
|
|
726
|
+
}
|
|
727
|
+
saveList(e) {
|
|
728
|
+
return E(e, (e) => {
|
|
729
|
+
let t = [p, e.path], n = u.readFileOnly(t);
|
|
730
|
+
if (!O(n) || !n.startsWith(this.getMd5Header(e.md5))) return this.saveFile(e), e;
|
|
731
|
+
if (!n.startsWith(this.getMd5Header(e.md5, !0))) return e;
|
|
732
|
+
});
|
|
733
|
+
}
|
|
734
|
+
isContent(e) {
|
|
735
|
+
return !!(e && e.includes("export"));
|
|
736
|
+
}
|
|
737
|
+
getList(e = this.getTemporaryDirectory()) {
|
|
738
|
+
return u.is(e) ? u.readDirRecursive(e) : [];
|
|
739
|
+
}
|
|
740
|
+
getListBy(e, t = this.getTemporaryDirectory()) {
|
|
741
|
+
return E(this.getList(t), (n) => {
|
|
742
|
+
if (e(n)) {
|
|
743
|
+
let e = this.readFile(n, t);
|
|
744
|
+
if (this.isContent(e)) return {
|
|
745
|
+
path: n,
|
|
746
|
+
content: e,
|
|
747
|
+
md5: this.ai.getMd5(e)
|
|
748
|
+
};
|
|
749
|
+
}
|
|
750
|
+
});
|
|
751
|
+
}
|
|
752
|
+
getMd5Header(e, t = !1) {
|
|
753
|
+
return `// md5:${e ?? "none"}${t ? " true" : ""}`;
|
|
754
|
+
}
|
|
755
|
+
getPath(e, t = this.getTemporaryDirectory()) {
|
|
756
|
+
return [t, e];
|
|
757
|
+
}
|
|
758
|
+
getTemporaryDirectory() {
|
|
759
|
+
return this.dir;
|
|
760
|
+
}
|
|
761
|
+
getDistDirectory() {
|
|
762
|
+
return this.dirDist;
|
|
763
|
+
}
|
|
764
|
+
}, Ie = class {
|
|
765
|
+
cleanContent(e) {
|
|
766
|
+
let t = F.createSourceFile("clean.d.ts", e, F.ScriptTarget.Latest, !0, F.ScriptKind.TS), n = F.transform(t, [this.getCleanTransformer()]), r = F.createPrinter({ newLine: F.NewLineKind.LineFeed }).printNode(F.EmitHint.Unspecified, n.transformed[0], t);
|
|
767
|
+
return n.dispose(), r.replace(/^\s*\/\/.*$/gm, "").replace(/^\s*[\r\n]/gm, "").trim();
|
|
768
|
+
}
|
|
769
|
+
getCleanTransformer() {
|
|
770
|
+
return (e) => (t) => {
|
|
771
|
+
let n = (t) => {
|
|
772
|
+
if (!(this.isRelativeImport(t) || this.isRelativeExport(t) || this.isNonPublicMember(t))) return F.visitEachChild(t, n, e);
|
|
773
|
+
};
|
|
774
|
+
return F.visitNode(t, n);
|
|
775
|
+
};
|
|
776
|
+
}
|
|
777
|
+
isNonPublicMember(e) {
|
|
778
|
+
return !!(F.canHaveModifiers(e) ? F.getModifiers(e) : void 0)?.some((e) => e.kind === F.SyntaxKind.PrivateKeyword || e.kind === F.SyntaxKind.ProtectedKeyword);
|
|
779
|
+
}
|
|
780
|
+
isRelativeImport(e) {
|
|
781
|
+
return F.isImportDeclaration(e) && F.isStringLiteral(e.moduleSpecifier) && e.moduleSpecifier.text.startsWith(".");
|
|
782
|
+
}
|
|
783
|
+
isRelativeExport(e) {
|
|
784
|
+
return F.isExportDeclaration(e) && e.moduleSpecifier !== void 0 && F.isStringLiteral(e.moduleSpecifier) && e.moduleSpecifier.text.startsWith(".");
|
|
785
|
+
}
|
|
786
|
+
}, Le = class extends Pe {
|
|
787
|
+
fullContent;
|
|
788
|
+
fullJsContent;
|
|
789
|
+
AI_TYPES_CONCURRENCY = d.getAiTypesConcurrency();
|
|
790
|
+
tsTransformer = new Ie();
|
|
791
|
+
files;
|
|
792
|
+
constructor(e, t = d.getTypesTemporaryDirectory(), n = d.getDistDir()) {
|
|
793
|
+
super(e, t, n), this.files = new Fe(this.ai, this.dir, this.dirDist);
|
|
794
|
+
}
|
|
795
|
+
getFullContent() {
|
|
796
|
+
if (this.fullContent === void 0) {
|
|
797
|
+
let e = this.files.getListCache(), t = this.files.getListAi(e);
|
|
798
|
+
this.fullContent = this.files.toOneFile(t);
|
|
799
|
+
}
|
|
800
|
+
return this.fullContent;
|
|
801
|
+
}
|
|
802
|
+
getFullJsContent() {
|
|
803
|
+
return this.fullJsContent === void 0 && (this.fullJsContent = this.files.toOneFile(this.files.getListByFilterJs())), this.fullJsContent;
|
|
804
|
+
}
|
|
805
|
+
async make() {
|
|
806
|
+
let e = this.files.getListByFilter(), t = this.getFullJsContent(), n = this.files.saveList(e);
|
|
807
|
+
return await this.saveListAi(n, t), this.makeSave();
|
|
808
|
+
}
|
|
809
|
+
makeSave() {
|
|
810
|
+
let e = this.getFullContent();
|
|
811
|
+
return this.files.save(e), this;
|
|
812
|
+
}
|
|
813
|
+
hasJSDoc(e) {
|
|
814
|
+
return e.includes("/**");
|
|
815
|
+
}
|
|
816
|
+
cleanContent(e) {
|
|
817
|
+
return this.tsTransformer.cleanContent(e);
|
|
818
|
+
}
|
|
819
|
+
async saveListAi(e, t) {
|
|
820
|
+
let n = e.length;
|
|
821
|
+
if (n === 0) return;
|
|
822
|
+
let r = [...e], i = 0, a = async () => {
|
|
823
|
+
let e;
|
|
824
|
+
for (; (e = r.shift()) !== void 0;) {
|
|
825
|
+
let r = this.cleanContent(e.content);
|
|
826
|
+
O(r) && (i += 1, console.log(`-- processing AI types [${i}/${n}] for ${e.path}...`), r = await this.toAiEdit(r, this.hasJSDoc(r) ? "" : t)), e.content !== r && this.files.saveFile({
|
|
827
|
+
...e,
|
|
828
|
+
content: r
|
|
829
|
+
}, !0);
|
|
830
|
+
}
|
|
831
|
+
};
|
|
832
|
+
await Promise.all(Array.from({ length: Math.min(this.AI_TYPES_CONCURRENCY, n) }, () => a()));
|
|
833
|
+
}
|
|
834
|
+
async toAiEdit(e, t) {
|
|
835
|
+
return await this.ai.toAi(e, "Goal: Optimize TypeScript type definitions for declarations in `File Content`.\n\nSCOPE & CONTEXT:\n- Process STRICTLY entities in `File Content`. Do NOT add unexported entities or code from `File JS Code`.\n- Use `File JS Code` ONLY as reference to understand implementation logic for writing JSDoc descriptions.\n- AI coding agents will rely EXCLUSIVELY on this output. Ensure complete type contracts and clear JSDoc descriptions.\n- Do NOT include file paths, links, or internal imports in the output.\n\nJSDOC RULES:\n- MANDATORY FOR ALL CLASSES, METHODS, FUNCTIONS & ACCESSORS: Every `class`, `declare class`, `abstract class`, `function`, `declare function`, method (public/static/abstract), `constructor`, and `get`/`set` accessor MUST ALWAYS have a JSDoc description.\n * Style: Descriptions MUST be maximally clear and informative, yet maximally short and concise. Avoid fluff.\n * Single-Line Preference: Prefer single-line JSDoc format (`/** Description @keywords search_terms */`) to conserve vertical space and reduce file size.\n * Remove `@return` / `@returns`: STRICTLY REMOVE `@return` and `@returns` tags from all JSDoc comments.\n * `@param` Tag: Include `@param` ONLY if critically necessary to clarify parameter behavior; otherwise omit `@param`.\n * AI Search Keywords: Include relevant search tags/keywords (e.g. `@keywords` tag or search terms) to help AI code search easily discover functionality.\n * Allowed tags: PRESERVE ONLY `@example`, `@remarks`, `@note`, `@warning`, `@keywords`, and critical `@param` tags. Remove `@return`/`@returns` and all other tags.\n * If JSDoc is missing: Generate a clear, concise, search-optimized English JSDoc derived from inspecting `File JS Code`.\n * If JSDoc exists: Optimize, condense, translate to English, and apply tag rules.\n- TYPES, INTERFACES & ENUMS: Delete JSDoc for simple/obvious types; add or keep concise JSDoc for complex types.\n- Place JSDoc directly above declarations. Remove regular inline comments (`//` or `/* */`).\n\nCLEANING & STRUCTURING:\n- Remove internal `import` statements and internal re-exports. Keep external package exports.\n- Delete non-public content (private/protected members, unexported elements). Keep all public API surfaces.\n- Do NOT delete any `type` definitions. Preserve abstract classes.\n- Format output tightly without unnecessary blank lines.\n\nOUTPUT FORMAT:\nReturn ONLY raw TypeScript code corresponding to `File Content`. No markdown, no code blocks (```), no text explanations.\n", t) ?? e;
|
|
836
|
+
}
|
|
837
|
+
}, Re = class {
|
|
838
|
+
ai;
|
|
839
|
+
prompts;
|
|
840
|
+
constructor(e, t) {
|
|
841
|
+
this.ai = e, this.prompts = t;
|
|
842
|
+
}
|
|
843
|
+
is() {
|
|
844
|
+
return u.is(h);
|
|
845
|
+
}
|
|
846
|
+
async make() {
|
|
847
|
+
let e = this.ai.getProjectName(), t = [];
|
|
848
|
+
t.push({
|
|
849
|
+
uri: `${e}/${S}`,
|
|
850
|
+
name: `Type Definitions (${e})`,
|
|
851
|
+
mimeType: "text/markdown",
|
|
852
|
+
description: "TypeScript type definitions and signatures for AI coding assistant."
|
|
853
|
+
}), t.push({
|
|
854
|
+
uri: `${e}/${m}`,
|
|
855
|
+
name: `Project Overview (${e})`,
|
|
856
|
+
mimeType: "text/markdown",
|
|
857
|
+
description: "Project overview, usage guidelines, and mandatory prompt rules for AI coding assistant."
|
|
858
|
+
}), t.push(...this.getScreenshotList(e));
|
|
859
|
+
let n = this.prompts.getCacheList();
|
|
860
|
+
for (let r of n) O(r.name) && O(r.description) && t.push({
|
|
861
|
+
uri: `${e}/${r.path}`,
|
|
862
|
+
name: `${r.name} (${e})`,
|
|
863
|
+
mimeType: "text/markdown",
|
|
864
|
+
description: r.description
|
|
865
|
+
});
|
|
866
|
+
return this.saveMcp(t), this;
|
|
867
|
+
}
|
|
868
|
+
getMimeType(e) {
|
|
869
|
+
return e.endsWith(".webp") ? "image/webp" : e.endsWith(".png") ? "image/png" : e.endsWith(".jpg") || e.endsWith(".jpeg") ? "image/jpeg" : e.endsWith(".svg") ? "image/svg+xml" : e.endsWith(".html") || e.endsWith(".htm") ? "text/html" : e.endsWith(".css") ? "text/css" : e.endsWith(".json") ? "application/json" : e.endsWith(".md") ? "text/markdown" : "text/plain";
|
|
870
|
+
}
|
|
871
|
+
getScreenshotList(e) {
|
|
872
|
+
let t = [];
|
|
873
|
+
if (u.is("ai-screenshot")) {
|
|
874
|
+
let n = u.readDir(f);
|
|
875
|
+
for (let r of n) r.startsWith(".") || t.push({
|
|
876
|
+
uri: `${e}/${f}/${r}`,
|
|
877
|
+
name: `Screenshot: ${r} (${e})`,
|
|
878
|
+
mimeType: this.getMimeType(r),
|
|
879
|
+
description: `Visual reference screenshot / asset (${r}) for ${e}.`
|
|
880
|
+
});
|
|
881
|
+
}
|
|
882
|
+
return t;
|
|
883
|
+
}
|
|
884
|
+
saveMcp(e) {
|
|
885
|
+
u.writeByPath(h, JSON.stringify(e, null, 2));
|
|
886
|
+
}
|
|
887
|
+
}, Q = class {
|
|
888
|
+
promptsDir;
|
|
889
|
+
ai;
|
|
890
|
+
constructor(e = d.getAiResourcesDir(), t) {
|
|
891
|
+
this.promptsDir = e, this.ai = t;
|
|
892
|
+
}
|
|
893
|
+
}, ze = "Goal: Generate a document metadata object in valid JSON format for an AI coding assistant.\n\nCRITICAL RESTRICTIONS:\n- The output MUST be a valid JSON object with keys: \"name\" and \"description\".\n- Field \"name\": Short and concise document title (maximum 4-5 words).\n- Field \"description\": Clear description for an AI agent explaining what exact standards, rules, or tools this file contains and what commercial or technical task it solves (maximum 3 sentences).\n- Do NOT include markdown code block wrappers (```json). Return ONLY the raw JSON string.\n\nEXAMPLES OF GOOD OUTPUT:\n{\n \"name\": \"Coding Standards\",\n \"description\": \"Строгие архитектурные конвенции и стандарты написания кода для продукта\"\n}\n\nOUTPUT REQUIREMENTS:\nReturn ONLY the JSON object. No explanations, no markdown formatting, no conversational text.\n", Be = class extends Q {
|
|
894
|
+
listPrompts;
|
|
895
|
+
cacheList;
|
|
896
|
+
getCacheList() {
|
|
897
|
+
if (this.cacheList === void 0) {
|
|
898
|
+
let e = this.getCacheDir(), t = u.readDirRecursive(e), n = [];
|
|
899
|
+
for (let r of t) if (r.endsWith(".json")) {
|
|
900
|
+
let t = u.readFile([e, r]);
|
|
901
|
+
t && O(t.path) && O(t.name) && O(t.description) && n.push(t);
|
|
902
|
+
}
|
|
903
|
+
this.cacheList = n;
|
|
904
|
+
}
|
|
905
|
+
return this.cacheList;
|
|
906
|
+
}
|
|
907
|
+
getListPrompts() {
|
|
908
|
+
if (this.listPrompts === void 0) {
|
|
909
|
+
let e = u.readDirRecursive(this.promptsDir);
|
|
910
|
+
this.listPrompts = E(e, (e) => {
|
|
911
|
+
if (e.endsWith(".json")) return;
|
|
912
|
+
let t = `${this.promptsDir}/${e}`, n = u.readFileOnly(t);
|
|
913
|
+
if (n) return {
|
|
914
|
+
path: t,
|
|
915
|
+
content: n,
|
|
916
|
+
md5: this.getMd5(n)
|
|
917
|
+
};
|
|
918
|
+
});
|
|
919
|
+
}
|
|
920
|
+
return this.listPrompts;
|
|
921
|
+
}
|
|
922
|
+
async init() {
|
|
923
|
+
await this.make();
|
|
924
|
+
let e = this.getListPrompts(), t = this.getCacheList(), n = [];
|
|
925
|
+
for (let r of e) {
|
|
926
|
+
let e = t.find((e) => e.path === r.path);
|
|
927
|
+
e && O(e.description) && n.push(this.getPromptLine(r.path, e.description));
|
|
928
|
+
}
|
|
929
|
+
return n;
|
|
930
|
+
}
|
|
931
|
+
async make() {
|
|
932
|
+
let e = this.getListPrompts();
|
|
933
|
+
for (let t of e) await this.toAiPromptItem(t);
|
|
934
|
+
return this;
|
|
935
|
+
}
|
|
936
|
+
async toAiPrompts() {
|
|
937
|
+
let e = await this.init();
|
|
938
|
+
return e.length > 0 ? `## Mandatory Rules
|
|
939
|
+
You MUST evaluate whether your task relates to any of the following topics (even if not working directly with this package). If related material is present, you are strictly obligated to read and study the corresponding file before proceeding:
|
|
940
|
+
${e.join("\n")}` : "";
|
|
941
|
+
}
|
|
942
|
+
getCacheDir() {
|
|
943
|
+
return u.joinPath([p, re]);
|
|
944
|
+
}
|
|
945
|
+
getCachePath(e) {
|
|
946
|
+
let t = e.replace(RegExp(`^${this.promptsDir}/`), "").replace(/\.[^/.]+$/, ".json");
|
|
947
|
+
return u.joinPath([this.getCacheDir(), t]);
|
|
948
|
+
}
|
|
949
|
+
getMd5(e) {
|
|
950
|
+
return this.ai.getMd5(e);
|
|
951
|
+
}
|
|
952
|
+
getPromptLine(e, t) {
|
|
953
|
+
return `- '${C}/${this.ai.getProjectName()}/${e}': ${t}`;
|
|
954
|
+
}
|
|
955
|
+
saveCacheItem(e) {
|
|
956
|
+
u.writeByPath(this.getCachePath(e.path), e);
|
|
957
|
+
}
|
|
958
|
+
saveCacheList(e) {
|
|
959
|
+
this.cacheList = e;
|
|
960
|
+
for (let t of e) this.saveCacheItem(t);
|
|
961
|
+
}
|
|
962
|
+
async toAiPromptData(e) {
|
|
963
|
+
return this.ai.toAiJson(e, ze);
|
|
964
|
+
}
|
|
965
|
+
async toAiPromptItem(e) {
|
|
966
|
+
let t = e.md5 ?? this.getMd5(e.content), n = this.getCacheList(), r = n.findIndex((t) => t.path === e.path), i = r >= 0 ? n[r] : void 0;
|
|
967
|
+
if (i && i.md5 === t && O(i.name) && O(i.description)) return {
|
|
968
|
+
prompt: this.getPromptLine(e.path, i.description),
|
|
969
|
+
isChanged: !1
|
|
970
|
+
};
|
|
971
|
+
console.log(`-- processing prompt metadata for ${e.path}...`);
|
|
972
|
+
let a = await this.toAiPromptData(e.content);
|
|
973
|
+
if (a && O(a.name) && O(a.description)) {
|
|
974
|
+
let i = {
|
|
975
|
+
path: e.path,
|
|
976
|
+
md5: t,
|
|
977
|
+
name: a.name,
|
|
978
|
+
description: a.description
|
|
979
|
+
};
|
|
980
|
+
return r >= 0 ? n[r] = i : n.push(i), this.saveCacheItem(i), {
|
|
981
|
+
prompt: this.getPromptLine(e.path, a.description),
|
|
982
|
+
isChanged: !0
|
|
983
|
+
};
|
|
984
|
+
}
|
|
985
|
+
return { isChanged: !1 };
|
|
986
|
+
}
|
|
987
|
+
}, Ve = class {
|
|
988
|
+
promptsDir;
|
|
989
|
+
dir;
|
|
990
|
+
dirDist;
|
|
991
|
+
ai;
|
|
992
|
+
buildTypes;
|
|
993
|
+
description;
|
|
994
|
+
makeTypes;
|
|
995
|
+
mcp;
|
|
996
|
+
prompts;
|
|
997
|
+
constructor(e = d.getAiResourcesDir(), t = d.getTypesTemporaryDirectory(), n = d.getDistDir(), r = {}) {
|
|
998
|
+
this.promptsDir = e, this.dir = t, this.dirDist = n;
|
|
999
|
+
let { DesignTypesBuildConstructor: i = Z, DesignTypesMakeConstructor: a = Le, DesignTypesPromptsConstructor: o = Be } = r;
|
|
1000
|
+
T.setErrorStatus(!0), this.ai = new Y(this.dir), this.buildTypes = new i(this.dir), this.makeTypes = new a(this.ai, this.dir, this.dirDist), this.prompts = new o(this.promptsDir, this.ai), this.description = new Ne(this.ai, this.makeTypes, this.prompts), this.mcp = new Re(this.ai, this.prompts);
|
|
1001
|
+
}
|
|
1002
|
+
async make() {
|
|
1003
|
+
console.log("DesignTypes: making AI types...");
|
|
1004
|
+
try {
|
|
1005
|
+
this.buildTypes.build(), await this.makeTypes.make(), await this.prompts.make(), await this.description.make(), await this.mcp.make();
|
|
1006
|
+
} finally {
|
|
1007
|
+
this.buildTypes.clean();
|
|
1008
|
+
}
|
|
1009
|
+
return console.log("DesignTypes: AI types saved."), this;
|
|
1010
|
+
}
|
|
1011
|
+
async makeSave() {
|
|
1012
|
+
return console.log("DesignTypes: saving AI types from list..."), this.makeTypes.makeSave(), this.description.is() || await this.description.make(), this.mcp.is() || await this.mcp.make(), console.log("DesignTypes: AI types saved."), this;
|
|
1013
|
+
}
|
|
1014
|
+
}, He = /* @__PURE__ */ function(e) {
|
|
1015
|
+
return e.MODIFIED = "M", e.ADDED = "A", e.DELETED = "D", e.RENAMED = "R", e.COPIED = "C", e.UPDATED = "U", e.UNTRACKED = "??", e.IGNORED = "!!", e.BOTH_MODIFIED = "UU", e.ADDED_BY_US = "AU", e.DELETED_BY_US = "DU", e.ADDED_BY_THEM = "UA", e.DELETED_BY_THEM = "UD", e.BOTH_ADDED = "AA", e.BOTH_DELETED = "DD", e.MODIFIED_IN_INDEX = "MM", e.ADDED_IN_INDEX = "AM", e.DELETED_IN_INDEX = "DM", e.RENAMED_IN_INDEX = "RM", e.COPIED_IN_INDEX = "CM", e;
|
|
1016
|
+
}({}), Ue = class {
|
|
1017
|
+
static getList(e) {
|
|
1018
|
+
let t = this.getDirPrefix();
|
|
1019
|
+
return E(this.getFilesPath(), (n) => {
|
|
1020
|
+
if (e && !e(n)) return;
|
|
1021
|
+
let r = this.getDate(this.getFileDate(n));
|
|
1022
|
+
return {
|
|
1023
|
+
path: n,
|
|
1024
|
+
pathByOS: this.splitPath(n),
|
|
1025
|
+
pathFull: `${t}${n}`,
|
|
1026
|
+
date: r,
|
|
1027
|
+
status: void 0
|
|
1028
|
+
};
|
|
1029
|
+
});
|
|
1030
|
+
}
|
|
1031
|
+
static getListPorcelain(e) {
|
|
1032
|
+
let t = this.getDate(), n = this.getDirPrefix();
|
|
1033
|
+
return E(this.getFilesPorcelain(), (r) => {
|
|
1034
|
+
let i = r.replace(/ {2,}/, " ").split(" ", 2), a = i[0], o = i[1] ?? "";
|
|
1035
|
+
if (e && !e(o)) return;
|
|
1036
|
+
let s = ge(o, n), c = this.splitPath(s);
|
|
1037
|
+
return {
|
|
1038
|
+
path: s,
|
|
1039
|
+
pathByOS: c,
|
|
1040
|
+
pathFull: o,
|
|
1041
|
+
date: u.getTime(c) ?? t,
|
|
1042
|
+
status: a
|
|
1043
|
+
};
|
|
1044
|
+
});
|
|
1045
|
+
}
|
|
1046
|
+
static getListUnique(e) {
|
|
1047
|
+
return this.mergeUnique(this.getListPorcelain(e), this.getList(e));
|
|
1048
|
+
}
|
|
1049
|
+
static getListByDirectory(e) {
|
|
1050
|
+
return this.getListUnique((t) => !!(t.match(e) && t.endsWith(".ts") && !t.endsWith(".test.ts")));
|
|
1051
|
+
}
|
|
1052
|
+
static getClassesList() {
|
|
1053
|
+
return this.getListByDirectory("/classes/");
|
|
1054
|
+
}
|
|
1055
|
+
static getFunctionsList() {
|
|
1056
|
+
return this.getListByDirectory("/functions/");
|
|
1057
|
+
}
|
|
1058
|
+
static getFilesPath() {
|
|
1059
|
+
return E(this.exec("git ls-tree -r --name-only HEAD").split("\n"), (e) => e.trim());
|
|
1060
|
+
}
|
|
1061
|
+
static getFilesPorcelain() {
|
|
1062
|
+
return E(this.exec("git status --porcelain").split("\n"), (e) => e.trim());
|
|
1063
|
+
}
|
|
1064
|
+
static getFileDate(e) {
|
|
1065
|
+
return this.exec(`git log -1 --format="%ci" -- "${e}"`);
|
|
1066
|
+
}
|
|
1067
|
+
static getDirPrefix() {
|
|
1068
|
+
return this.exec("git rev-parse --show-prefix");
|
|
1069
|
+
}
|
|
1070
|
+
static getDate(e) {
|
|
1071
|
+
return new me(e).setType("full").standard();
|
|
1072
|
+
}
|
|
1073
|
+
static filterByDirectory(e) {
|
|
1074
|
+
let t = this.getDirPrefix();
|
|
1075
|
+
return e.filter((e) => e.pathFull.startsWith(t));
|
|
1076
|
+
}
|
|
1077
|
+
static mergeUnique(e, t) {
|
|
1078
|
+
let n = [...e];
|
|
1079
|
+
return E(t, (e) => {
|
|
1080
|
+
n.find((t) => t.pathFull === e.pathFull) || n.push(e);
|
|
1081
|
+
}), n;
|
|
1082
|
+
}
|
|
1083
|
+
static splitPath(e) {
|
|
1084
|
+
return e.split("/").filter((e) => e.length > 0);
|
|
1085
|
+
}
|
|
1086
|
+
static exec(e) {
|
|
1087
|
+
return N(e, { encoding: "utf8" }).trim();
|
|
1088
|
+
}
|
|
1089
|
+
}, We = class {
|
|
1090
|
+
source;
|
|
1091
|
+
fileTs;
|
|
1092
|
+
constructor(e = g, t = ie) {
|
|
1093
|
+
this.source = e, this.fileTs = t;
|
|
1094
|
+
}
|
|
1095
|
+
isPrompt() {
|
|
1096
|
+
return u.is(b);
|
|
1097
|
+
}
|
|
1098
|
+
getResources() {
|
|
1099
|
+
let e = [];
|
|
1100
|
+
if (this.isPrompt() && e.push(this.getPromptResource()), D(this.source) && this.source.length > 0 && he(this.source[0])) return e.push(...this.source), e;
|
|
1101
|
+
let t = this.source;
|
|
1102
|
+
if (u.is(t)) {
|
|
1103
|
+
let n = u.readFile(t);
|
|
1104
|
+
D(n) && n.length > 0 && e.push(...n);
|
|
1105
|
+
}
|
|
1106
|
+
return e;
|
|
1107
|
+
}
|
|
1108
|
+
make() {
|
|
1109
|
+
console.log("Generating AI MCP TypeScript resources...");
|
|
1110
|
+
let e = this.getResources();
|
|
1111
|
+
if (e.length > 0) {
|
|
1112
|
+
let t = this.initFile(e);
|
|
1113
|
+
this.write(t), console.log(`Generated ${e.length} MCP resources in ${u.joinPath(this.fileTs)}`);
|
|
1114
|
+
} else console.log("No MCP resources found to generate.");
|
|
1115
|
+
return this;
|
|
1116
|
+
}
|
|
1117
|
+
getImportPath(e) {
|
|
1118
|
+
let t = !e.startsWith("@") && !e.startsWith("./") && !e.startsWith("/") ? `./${e}` : e;
|
|
1119
|
+
return [
|
|
1120
|
+
".md",
|
|
1121
|
+
".html",
|
|
1122
|
+
".css",
|
|
1123
|
+
".scss",
|
|
1124
|
+
".txt",
|
|
1125
|
+
".json",
|
|
1126
|
+
".svg"
|
|
1127
|
+
].some((e) => t.endsWith(e)) ? `${t}?raw` : t;
|
|
1128
|
+
}
|
|
1129
|
+
getPackageConstName(e, t) {
|
|
1130
|
+
let n = e.replace(/^@[^/]+\//, ""), r = `mcp${j(n)}Resources`;
|
|
1131
|
+
if (t.has(r)) {
|
|
1132
|
+
let t = e.replace(/^@/, "").replace("/", "-");
|
|
1133
|
+
r = `mcp${j(t)}Resources`;
|
|
1134
|
+
}
|
|
1135
|
+
return t.add(r), r;
|
|
1136
|
+
}
|
|
1137
|
+
getPackages(e) {
|
|
1138
|
+
let t = /* @__PURE__ */ new Map();
|
|
1139
|
+
return e.forEach((e) => {
|
|
1140
|
+
let n = k(e.uri) ? e.uri : "", r = this.extractPackageName(n);
|
|
1141
|
+
t.has(r) || t.set(r, []), t.get(r)?.push(e);
|
|
1142
|
+
}), t;
|
|
1143
|
+
}
|
|
1144
|
+
getPromptResource() {
|
|
1145
|
+
return {
|
|
1146
|
+
uri: b,
|
|
1147
|
+
name: "System Prompt (dxt-ui)",
|
|
1148
|
+
mimeType: "text/markdown",
|
|
1149
|
+
description: "Consolidated system instructions, coding guidelines, and prompt rules for AI coding assistant."
|
|
1150
|
+
};
|
|
1151
|
+
}
|
|
1152
|
+
escapeString(e) {
|
|
1153
|
+
return `'${e.replace(/\\/g, "\\\\").replace(/'/g, "\\'").replace(/\r/g, "\\r").replace(/\n/g, "\\n")}'`;
|
|
1154
|
+
}
|
|
1155
|
+
extractPackageName(e) {
|
|
1156
|
+
if (e.startsWith("@")) {
|
|
1157
|
+
let t = e.split("/");
|
|
1158
|
+
if (t.length >= 2) return `${t[0]}/${t[1]}`;
|
|
1159
|
+
}
|
|
1160
|
+
let t = e.indexOf("/");
|
|
1161
|
+
return t > 0 ? e.substring(0, t) : "system";
|
|
1162
|
+
}
|
|
1163
|
+
formatItem(e) {
|
|
1164
|
+
let t = [];
|
|
1165
|
+
if (k(e.uri) && t.push(` uri: ${this.escapeString(e.uri)}`), k(e.name) && t.push(` name: ${this.escapeString(e.name)}`), k(e.description) && O(e.description) && t.push(` description: ${this.escapeString(e.description)}`), k(e.mimeType) && O(e.mimeType) && t.push(` mimeType: ${this.escapeString(e.mimeType)}`), k(e.text) && O(e.text) && t.push(` text: ${this.escapeString(e.text)}`), k(e.blob) && O(e.blob) && t.push(` blob: ${this.escapeString(e.blob)}`), k(e.uri) && O(e.uri) && !e.text && !e.blob) {
|
|
1166
|
+
let n = this.getImportPath(e.uri);
|
|
1167
|
+
t.push(` handler: async () => (await import('${n}'))?.default`);
|
|
1168
|
+
}
|
|
1169
|
+
return ` {\n${t.join(",\n")}\n }`;
|
|
1170
|
+
}
|
|
1171
|
+
initFile(e) {
|
|
1172
|
+
let t = this.getPackages(e), n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Map(), i = [
|
|
1173
|
+
"// This file is generated by a script, do not edit.",
|
|
1174
|
+
"",
|
|
1175
|
+
"import type { McpResourceItem } from '@dxtmisha/mcp'"
|
|
1176
|
+
], a = [], o = [];
|
|
1177
|
+
return t.forEach((e, t) => {
|
|
1178
|
+
let s = this.getPackageConstName(t, n);
|
|
1179
|
+
r.set(t, s), o.push(s);
|
|
1180
|
+
let c = e.map((e) => this.formatItem(e)).join(",\n");
|
|
1181
|
+
i.push(""), i.push("/**"), i.push(` * MCP resources for ${t}.`), i.push(" */"), i.push(`export const ${s}: McpResourceItem[] = [`), i.push(c), i.push("]"), a.push(` '${t}': ${s}`);
|
|
1182
|
+
}), i.push(""), i.push("/**"), i.push(" * MCP resources grouped by package name."), i.push(" */"), i.push("export const mcpPackageResources: Record<string, McpResourceItem[]> = {"), i.push(a.join(",\n")), i.push("}"), i.push(""), i.push("/**"), i.push(" * All aggregated MCP resources for McpResource."), i.push(" */"), i.push("export const mcpAllResources: McpResourceItem[] = ["), i.push(o.map((e) => ` ...${e}`).join(",\n")), i.push("]"), i.push(""), i.push("export default mcpAllResources"), i.push(""), i.join("\n");
|
|
1183
|
+
}
|
|
1184
|
+
write(e) {
|
|
1185
|
+
return u.writeByPath(this.fileTs, e, !1), this;
|
|
1186
|
+
}
|
|
1187
|
+
}, Ge = class {
|
|
1188
|
+
dir;
|
|
1189
|
+
constructor(e = []) {
|
|
1190
|
+
this.dir = e;
|
|
1191
|
+
}
|
|
1192
|
+
isMcp() {
|
|
1193
|
+
return u.is(this.getPath(h));
|
|
1194
|
+
}
|
|
1195
|
+
make() {
|
|
1196
|
+
if (this.isMcp()) {
|
|
1197
|
+
let e = u.readFile(this.getPath(h));
|
|
1198
|
+
if (Array.isArray(e) && e.length > 0) return e;
|
|
1199
|
+
}
|
|
1200
|
+
}
|
|
1201
|
+
getPath(e) {
|
|
1202
|
+
return [...this.dir, e];
|
|
1203
|
+
}
|
|
1204
|
+
}, $ = class {
|
|
1205
|
+
dir;
|
|
1206
|
+
itemMcp;
|
|
1207
|
+
constructor(e = []) {
|
|
1208
|
+
this.dir = e, this.itemMcp = new Ge(this.dir);
|
|
1209
|
+
}
|
|
1210
|
+
getDir() {
|
|
1211
|
+
return this.dir;
|
|
1212
|
+
}
|
|
1213
|
+
getMcp() {
|
|
1214
|
+
return this.itemMcp.make();
|
|
1215
|
+
}
|
|
1216
|
+
getProjectName() {
|
|
1217
|
+
return w(this.dir)?.name ?? "none";
|
|
1218
|
+
}
|
|
1219
|
+
isPrompt() {
|
|
1220
|
+
return this.isDescription() || this.isInfo() || this.isTypes() || this.isScreenshot() || this.isDeveloper() || this.isMcp();
|
|
1221
|
+
}
|
|
1222
|
+
isDescription() {
|
|
1223
|
+
return u.is(this.getPath(_));
|
|
1224
|
+
}
|
|
1225
|
+
isDeveloper() {
|
|
1226
|
+
return u.is(this.getPath(v));
|
|
1227
|
+
}
|
|
1228
|
+
isInfo() {
|
|
1229
|
+
return u.is(this.getPath(y));
|
|
1230
|
+
}
|
|
1231
|
+
isMcp() {
|
|
1232
|
+
return this.itemMcp.isMcp();
|
|
1233
|
+
}
|
|
1234
|
+
isScreenshot() {
|
|
1235
|
+
return u.is(this.getPath(f));
|
|
1236
|
+
}
|
|
1237
|
+
isTypes() {
|
|
1238
|
+
return u.is(this.getPath(x));
|
|
1239
|
+
}
|
|
1240
|
+
make() {
|
|
1241
|
+
console.log(this.getProjectName());
|
|
1242
|
+
let e = [
|
|
1243
|
+
this.getDescription(),
|
|
1244
|
+
this.getInfo(),
|
|
1245
|
+
this.getTypes(),
|
|
1246
|
+
this.getScreenshot(),
|
|
1247
|
+
this.getDeveloper()
|
|
1248
|
+
].filter((e) => e !== void 0);
|
|
1249
|
+
if (e.length > 0) {
|
|
1250
|
+
let t = this.getPathString() || ".";
|
|
1251
|
+
return `
|
|
1252
|
+
# ${this.getProjectName()}
|
|
1253
|
+
## Project location: Root directory
|
|
1254
|
+
The project is located at: '${t}'.
|
|
1255
|
+
|
|
1256
|
+
${e.join("\n\n")}
|
|
1257
|
+
`.trim();
|
|
1258
|
+
}
|
|
1259
|
+
}
|
|
1260
|
+
getDescription() {
|
|
1261
|
+
if (this.isDescription()) return console.log("-- Description"), `
|
|
1262
|
+
## Package Description & Module Overview
|
|
1263
|
+
${this.readFile(_)}
|
|
1264
|
+
`.trim();
|
|
1265
|
+
}
|
|
1266
|
+
getDeveloper() {
|
|
1267
|
+
if (this.isDeveloper()) return console.log("-- Developer"), `
|
|
1268
|
+
## Developer Rules (Must Read Before Modifying Code)
|
|
1269
|
+
'${this.getPathString(v)}'
|
|
1270
|
+
`.trim();
|
|
1271
|
+
}
|
|
1272
|
+
getInfo() {
|
|
1273
|
+
if (this.isInfo()) return console.log("-- Info"), `
|
|
1274
|
+
## Package Core Information
|
|
1275
|
+
${this.readFile(y)}
|
|
1276
|
+
`.trim();
|
|
1277
|
+
}
|
|
1278
|
+
getPath(e) {
|
|
1279
|
+
return [...this.dir, e];
|
|
1280
|
+
}
|
|
1281
|
+
getPathString(e) {
|
|
1282
|
+
let t = this.dir.join("/");
|
|
1283
|
+
return e ? t ? `${t}/${e}` : e : t;
|
|
1284
|
+
}
|
|
1285
|
+
getScreenshot() {
|
|
1286
|
+
let e = this.getScreenshotList();
|
|
1287
|
+
if (e) {
|
|
1288
|
+
console.log("-- Screenshot");
|
|
1289
|
+
let t = this.getPathString(f);
|
|
1290
|
+
return `## Component Visual References (Screenshots)
|
|
1291
|
+
${e.map((e) => `- '${t}/${e}'`).join("\n")}
|
|
1292
|
+
`.trim();
|
|
1293
|
+
}
|
|
1294
|
+
}
|
|
1295
|
+
getScreenshotList() {
|
|
1296
|
+
if (this.isScreenshot()) return u.readDir(this.getPath(f));
|
|
1297
|
+
}
|
|
1298
|
+
getTypes() {
|
|
1299
|
+
if (this.isTypes()) return console.log("-- Types"), `
|
|
1300
|
+
## Package Type Definitions (Must Read in Full When Working with Package)
|
|
1301
|
+
'${this.getPathString(x)}'
|
|
1302
|
+
`.trim();
|
|
1303
|
+
}
|
|
1304
|
+
readFile(e) {
|
|
1305
|
+
let t = u.readFileOnly(this.getPath(e));
|
|
1306
|
+
return t ? this.dir.length > 0 ? t.replace(/([ '"`]|^)\.\//g, `$1${this.getPathString()}/`) : t : "";
|
|
1307
|
+
}
|
|
1308
|
+
}, Ke = "### Vue Component Implementation Rules (Vue.js Style Guide)\n\n- **Script Setup**: Use strictly `<script setup lang=\"ts\">`.\n- **Naming**: Component names must be multi-word, match their project path, and use PascalCase.\n- **CSS**: The root CSS class name of the component must match its name (in kebab-case).\n- **Typing**: Mandatory interfaces for Props (`defineProps<{...}>()`) and Emits (`defineEmits<{...}>()`).\n- **Lists (v-for)**: Always use a unique `:key`. Avoid using the array index as a key.\n- **Directives**: Never use `v-if` on the same element as `v-for`.\n- **Reactivity**: Use `ref` for data. Calculate complex logic via `computed`.\n- **Logic**: Extract only complex logic into Composables. Simple logic or calling existing hooks (even multiple) does not need to be extracted into a separate composable.\n- **Templates**: Cleanest possible HTML. No function calls, calculations, or inline styles. If complex logic is needed, split into sub-components.\n- **Props**: One-way data flow. Never mutate incoming props.\n- **Events**: Event names must be strictly in kebab-case.\n- **A11y**: Use semantic HTML and ARIA attributes.\n- **Atomicity**: Components should be minimal and perform only one function. Avoid universal \"Swiss army knife\" components.\n- **UI Styles**: Modifying the styles of ready-made UI components in the library is strictly forbidden. This is a taboo.\n- **Purity**: Write declaratively, avoid \"fluff,\" and save tokens.\n", qe = "### Global Development Principles (AI Code Promise)\n\nStrictly follow these rules for flawless dxt-ui code:\n\n0. **Mandatory Deep Study (CHRONOLOGICAL GUARD)**:\n - **Step 1**: Read/create local `ai-memory.md` strictly in the current package root (e.g., `packages/constructor/`). Using repository root `ai-memory.md` for package files is FORBIDDEN.\n - **Step 2**: Read root `ai-prompt.md` and study descriptions of all mentioned libraries.\n - **Step 3**: Study linked `ai-types.md` and `ai-developer.md` BEFORE proposing plans, inspecting directory structures, or writing code, ONLY if you think that library may be relevant/useful for the current task. If a package is in `node_modules/` but exists locally (e.g., `packages/`), resolve and study the local source instead.\n - Fully read source file contents before modifying them (superficial scans without reading context are forbidden when modifying existing code). Always check existing infrastructure before writing custom logic.\n\n1. **\"Copy-Paste Ready\"**: Generate complete, runnable files with correct imports. No placeholders (e.g., `// rest of code`).\n2. **Zero Hallucinations**: Strictly use `package.json` dependencies. No invented APIs. Ask if unsure.\n3. **Uncompromising TS**: No `any` (use `unknown` or generics). Interfaces for all I/O. `as const`, `readonly`, enums. Use `@ts-expect-error` with comments, never `@ts-ignore`.\n4. **Professional Documentation (TSDoc)**: Document all exported entities (purpose, params, returns). Use [wikiLanguage] by default unless the project defines its own documentation standard. Include examples for complex logic.\n5. **Architectural Consistency**: Respect project structure. Reuse existing infrastructure (always re-study this file before writing custom code). Do not modify global/base UI styles unless explicitly requested.\n6. **Strict Adherence & Optimization (STRICT PROHIBITION OF UNSOLICITED ACTIONS)**: Do STRICTLY and ONLY what is requested in the prompt. Making unsolicited changes, arbitrary refactoring, or modifying unrelated files without explicit instructions is STRICTLY FORBIDDEN. Follow instructions precisely without guessing, proposing technical optimizations only within the approved scope.\n7. **AI Workspace Memory (`ai-memory.md`)**: Apply its rules with highest priority. Update local `ai-memory.md` **ONLY** upon explicit command (e.g., \"remember\") or confirmed architectural rules. When adding rules, only resolve duplicates and direct conflicts — existing rules **MUST NOT be modified, condensed, or deleted**. Changelogs and absolute paths are forbidden (relative only). Store strictly key architectural constraints.\n8. **Package Type Reference (`ai-types.md`)**:\n - **Purpose & Content**: An AI-optimized complete technical reference of a package containing all public TypeScript declarations (classes, methods, functions, types, interfaces, enums, constants) with concise JSDoc and search tags (`@keywords`).\n - **How to Work (Search Before Full Scan)**: Due to the large size of `ai-types.md` files (thousands of lines), do **NOT** read or scan the entire file line-by-line upfront. **First, use text search** (by keywords, `@keywords`, function/class names) to locate required helpers, types, and signatures quickly to save context tokens. Reading the entire file is only needed when performing deep architectural analysis of the whole package.\n - **Code Reuse**: Before writing custom utility logic or types, ALWAYS check `ai-types.md` of relevant packages to discover and reuse existing infrastructure, classes, and helper functions (DRY).\n9. **Build & Test Execution Guard**: Do **NOT** run project builds (`npm run build`, `storybook build`, etc.) or test suites (`npm run test`, `vitest`, etc.) proactively during code authoring or intermediate steps until the developer explicitly confirms that work is completed, asks to run tests/verification, or when entering dedicated debugging and fix mode.\n\n", Je = [C], Ye = class {
|
|
1309
|
+
isMcp;
|
|
1310
|
+
dirs;
|
|
1311
|
+
exFileOnDirs = /^.+\.[^.]{2,4}$/;
|
|
1312
|
+
exNotRead = /^\./;
|
|
1313
|
+
constructor(e = [], t = !1) {
|
|
1314
|
+
this.isMcp = t, this.dirs = [...Je, ...e];
|
|
1315
|
+
}
|
|
1316
|
+
make() {
|
|
1317
|
+
console.log("Generating AI prompt...");
|
|
1318
|
+
let e = this.getList(), t = [
|
|
1319
|
+
"# System Role: AI Coding Assistant & Project Analyzer\nConsolidated documentation, architectural guidelines, and mandatory rules for the project.",
|
|
1320
|
+
this.getGlobalPrompt(),
|
|
1321
|
+
this.getVuePrompt()
|
|
1322
|
+
], n = [];
|
|
1323
|
+
e.length > 0 && e.forEach((e) => {
|
|
1324
|
+
let r = e.make();
|
|
1325
|
+
if (r && t.push(r), this.isMcp) {
|
|
1326
|
+
let t = e.getMcp();
|
|
1327
|
+
t && n.push(...t);
|
|
1328
|
+
}
|
|
1329
|
+
});
|
|
1330
|
+
let r = this.getInstruction();
|
|
1331
|
+
r && t.push(r), t.push(this.getAuditPrompt()), this.write(t), this.isMcp && (this.writeMcp(n), new We().make()), console.log("end");
|
|
1332
|
+
}
|
|
1333
|
+
isFileOnDirs(e) {
|
|
1334
|
+
return e.some((e) => this.exFileOnDirs.test(e));
|
|
1335
|
+
}
|
|
1336
|
+
getAuditPrompt() {
|
|
1337
|
+
return "## Mandatory Final Self-Audit (CRITICAL GUARD & STRICT COMPLIANCE)\n\n🔴 **STOP! BEFORE DECLARING WORK COMPLETE OR ENDING YOUR TURN, YOU MUST AUDIT ALL CODE!** 🔴\n\n1. **Mandatory Full Re-Study**: Inspect EVERY single line of code created or modified in this task.\n2. **Rule-by-Rule Compliance Check**: Cross-reference all code changes against ALL architectural conventions, coding standards, JSDoc/TSDoc guidelines, and package rules defined in `ai-prompt.md`.\n3. **Zero Ignored Rules**: Ensure NO project rule, typing constraint, or code structure guideline was bypassed, forgotten, or ignored.\n4. **Self-Correction**: If any discrepancy, missing typing, bad JSDoc formatting, or rule violation is found during this audit, fix it IMMEDIATELY before concluding your turn.";
|
|
1338
|
+
}
|
|
1339
|
+
getInstruction() {
|
|
1340
|
+
if (u.is("ai-instruction.md")) return `
|
|
1341
|
+
## High-Priority Directives (Overrides Base Rules)
|
|
1342
|
+
${u.readFileOnly(ae)}
|
|
1343
|
+
`.trim();
|
|
1344
|
+
}
|
|
1345
|
+
getVuePrompt() {
|
|
1346
|
+
return `
|
|
1347
|
+
## Vue Component Implementation Rules
|
|
1348
|
+
${Ke}
|
|
1349
|
+
`.trim();
|
|
1350
|
+
}
|
|
1351
|
+
getGlobalPrompt() {
|
|
1352
|
+
return `
|
|
1353
|
+
## Global Code Implementation Rules
|
|
1354
|
+
${qe}
|
|
1355
|
+
`.trim();
|
|
1356
|
+
}
|
|
1357
|
+
getList(e = this.dirs, t = [], n = d.getPromptScanDepth()) {
|
|
1358
|
+
if (n <= 0) return [];
|
|
1359
|
+
let r = [];
|
|
1360
|
+
if (t.length === 0) {
|
|
1361
|
+
let e = this.getRootItem();
|
|
1362
|
+
e && r.push(e);
|
|
1363
|
+
}
|
|
1364
|
+
for (let i of e) {
|
|
1365
|
+
if (this.exNotRead.test(i)) continue;
|
|
1366
|
+
let e = [...t, i], a = u.readDir(e);
|
|
1367
|
+
if (!this.isFileOnDirs(a) || i === "node_modules") r.push(...this.getList(a, e, n - 1));
|
|
1368
|
+
else {
|
|
1369
|
+
let t = new $(e);
|
|
1370
|
+
t.isPrompt() && r.push(t);
|
|
1371
|
+
}
|
|
1372
|
+
}
|
|
1373
|
+
return r;
|
|
1374
|
+
}
|
|
1375
|
+
getRootItem() {
|
|
1376
|
+
let e = new $([]);
|
|
1377
|
+
if (e.isPrompt()) return e;
|
|
1378
|
+
}
|
|
1379
|
+
write(e) {
|
|
1380
|
+
return u.writeByPath(b, e.join("\n\n---\n\n")), this;
|
|
1381
|
+
}
|
|
1382
|
+
writeMcp(e) {
|
|
1383
|
+
return u.writeByPath(g, e), this;
|
|
1384
|
+
}
|
|
1385
|
+
}, Xe = class {
|
|
1386
|
+
make() {
|
|
1387
|
+
console.log("Library export"), u.writeByPath(ee, `${this.initFile().trim()}\r\n`), console.log("\r\nfinish");
|
|
1388
|
+
}
|
|
1389
|
+
getPath(e) {
|
|
1390
|
+
return ["src", e];
|
|
1391
|
+
}
|
|
1392
|
+
isExport(e) {
|
|
1393
|
+
return !u.joinPath(e).match(".test.") && !this.getFile(e).match(se);
|
|
1394
|
+
}
|
|
1395
|
+
getDirectory() {
|
|
1396
|
+
let e = [];
|
|
1397
|
+
return te.forEach((t) => {
|
|
1398
|
+
let n = this.getPath(t), r = u.readDirRecursiveWithIndex(n);
|
|
1399
|
+
r.length > 0 && e.push({
|
|
1400
|
+
name: t,
|
|
1401
|
+
path: n,
|
|
1402
|
+
files: r
|
|
1403
|
+
});
|
|
1404
|
+
}), e;
|
|
1405
|
+
}
|
|
1406
|
+
getName(e) {
|
|
1407
|
+
return e.replace(/^[a-z]/, (e) => e.toUpperCase());
|
|
1408
|
+
}
|
|
1409
|
+
getFile(e) {
|
|
1410
|
+
return u.readFile(e) ?? "";
|
|
1411
|
+
}
|
|
1412
|
+
initFile() {
|
|
1413
|
+
let e = this.getDirectory(), t = [this.initStyles()], n = [];
|
|
1414
|
+
return e.forEach((e) => {
|
|
1415
|
+
let r = e.name;
|
|
1416
|
+
n.push(""), n.push(`// ${this.getName(r)}`), console.log(r), e.files.forEach((i) => {
|
|
1417
|
+
if (this.isExport([...e.path, i])) {
|
|
1418
|
+
if (console.log(` ${i}`), i.match(/\.ts$/)) n.push(`export * from './${r}/${i.replace(/\.ts$/, "")}'`);
|
|
1419
|
+
else if (i.match(/\.vue$/)) {
|
|
1420
|
+
let e = i.replace(/\.vue$/, "").replace(/^(.*?)([^/]+)$/, "$2");
|
|
1421
|
+
t.push(`import _${e} from './${r}/${i}'`), n.push(`export const ${e} = _${e}`);
|
|
1422
|
+
}
|
|
1423
|
+
}
|
|
1424
|
+
});
|
|
1425
|
+
}), t.join("\r\n").trim() + "\r\n\r\n" + n.join("\r\n").trim();
|
|
1426
|
+
}
|
|
1427
|
+
initStyles() {
|
|
1428
|
+
let e = [];
|
|
1429
|
+
return ["style.scss", "style.css"].forEach((t) => {
|
|
1430
|
+
let n = ["src", t];
|
|
1431
|
+
u.is(n) && e.push(`import './${t}'`);
|
|
1432
|
+
}), e.join("\r\n") + "\r\n";
|
|
1433
|
+
}
|
|
1434
|
+
};
|
|
1435
|
+
//#endregion
|
|
1436
|
+
export { l as AiAbstract, s as AiClaude, L as AiClaudeAgent, I as AiClaudeAgentLite, B as AiClaudeCli, z as AiClaudeCliLite, t as AiClaudeLite, e as AiGoogle, H as AiGoogleCli, V as AiGoogleCliLite, a as AiGoogleLite, o as AiOpenAi, n as AiOpenAiLite, c as AiZAi, i as AiZAiLite, R as ApiTmp, W as BrowserItem, Oe as BuildPackages, Ae as BuildPublishPackages, je as DesignScreenshot, Ve as DesignTypes, Y as DesignTypesAi, Z as DesignTypesBuild, X as DesignTypesBuildAbstract, Ne as DesignTypesDescription, Le as DesignTypesMake, Pe as DesignTypesMakeAbstract, Fe as DesignTypesMakeFile, Ie as DesignTypesMakeTsTransformer, Re as DesignTypesMcp, Be as DesignTypesPrompts, Q as DesignTypesPromptsAbstract, pe as FIGMA_API_URL, fe as FigmaApiEndpoint, Ue as GitRead, He as GitStatus, We as LibraryAiMcp, Ge as LibraryAiMcpItem, Ye as LibraryAiPrompt, $ as LibraryAiPromptItem, Xe as LibraryExport, G as PackageFile, ce as PackageInit, u as PropertiesFile, de as PropertyCategory, le as PropertyKey, ue as PropertyType, xe as SCREENSHOT_ARGS, Se as SCREENSHOT_FORMAT, Ce as SCREENSHOT_HEIGHTS, we as SCREENSHOT_QUALITY, Te as SCREENSHOT_TIMEOUT, U as SCREENSHOT_WAIT_UNTIL, Ee as SCREENSHOT_WIDTHS, w as getPackageJson, K as run, J as useAi };
|