@dxtmisha/scripts 0.9.1 → 0.10.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.
Files changed (36) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/package.json +2 -1
  3. package/src/classes/Ai/AiClaudeAgent.ts +16 -0
  4. package/src/classes/Ai/AiClaudeAgentLite.ts +86 -0
  5. package/src/classes/Ai/AiClaudeCliLite.ts +29 -65
  6. package/src/classes/Ai/AiClaudeLite.ts +19 -7
  7. package/src/classes/Ai/AiGoogleCliLite.ts +27 -64
  8. package/src/classes/Ai/AiOpenAi.ts +26 -0
  9. package/src/classes/Ai/AiOpenAiLite.ts +107 -0
  10. package/src/classes/Ai/AiZAi.ts +17 -0
  11. package/src/classes/Ai/AiZAiLite.ts +26 -0
  12. package/src/classes/Ai/ApiTmp.ts +43 -0
  13. package/src/classes/Build/BuildPackages.ts +33 -7
  14. package/src/classes/Design/DesignComponent.ts +1 -1
  15. package/src/classes/Library/LibraryAiPromptItem.ts +36 -2
  16. package/src/composables/useAi.ts +15 -0
  17. package/src/config.ts +2 -0
  18. package/src/demo/ai.ts +10 -0
  19. package/src/library-ai.ts +4 -4
  20. package/src/library.ts +67 -54
  21. package/src/media/templates/componentDoc/wiki/prompt.txt +7 -2
  22. package/src/media/templates/prompts/aiCodeGlobalPrompt.en.txt +19 -0
  23. package/src/media/templates/prompts/aiCodeGlobalPrompt.ru.txt +21 -0
  24. package/src/types/configTypes.ts +9 -2
  25. package/src/classes/Component/__tests__/ComponentCreator.test.ts +0 -71
  26. package/src/classes/Component/__tests__/ComponentItem.test.ts +0 -71
  27. package/src/classes/Git/__tests__/GitRead.test.ts +0 -70
  28. package/src/composables/__tests__/useAi.test.ts +0 -75
  29. package/src/functions/__tests__/getComponentPaths.test.ts +0 -19
  30. package/src/functions/__tests__/getConfigAi.test.ts +0 -26
  31. package/src/functions/__tests__/getConstructorProperties.test.ts +0 -51
  32. package/src/functions/__tests__/getDirname.test.ts +0 -31
  33. package/src/functions/__tests__/getNameDirByPaths.test.ts +0 -40
  34. package/src/functions/__tests__/getPackageJson.test.ts +0 -34
  35. package/src/functions/__tests__/hasNativeDirname.test.ts +0 -18
  36. package/src/functions/__tests__/toPathStandardSep.test.ts +0 -31
@@ -31,18 +31,14 @@ export class BuildPackages {
31
31
  * Сканирует директорию пакетов и собирает каждый пакет, содержащий package.json.
32
32
  */
33
33
  async make(): Promise<void> {
34
- const list = PropertiesFile.readDir(this.path)
34
+ const list = this.getList()
35
35
  let changed = 0
36
36
 
37
37
  console.info(`Build packages(${list.length})...`)
38
38
 
39
- for (const folder of list) {
40
- const packageFile = new PackageFile([this.path, folder])
41
-
39
+ for (const packageFile of list) {
42
40
  if (
43
- packageFile.is()
44
- && !packageFile.isTest()
45
- && this.isUpdate(packageFile)
41
+ this.isUpdate(packageFile)
46
42
  && await this.build(packageFile)
47
43
  ) {
48
44
  this.updateLog(packageFile)
@@ -80,6 +76,36 @@ export class BuildPackages {
80
76
  )
81
77
  }
82
78
 
79
+ /**
80
+ * Scans the packages directory and returns a list of packages sorted by the ui-priority property in package.json.
81
+ * If a package does not have a priority, it defaults to 500.
82
+ *
83
+ * Сканирует директорию пакетов и возвращает список пакетов, отсортированный по свойству ui-priority в package.json.
84
+ * Если у пакета нет приоритета, по умолчанию устанавливается значение 500.
85
+ * @returns sorted list of package files / отсортированный список файлов пакетов
86
+ */
87
+ private getList(): PackageFile[] {
88
+ const list = PropertiesFile.readDir(this.path)
89
+ const packages: PackageFile[] = []
90
+
91
+ for (const folder of list) {
92
+ const packageFile = new PackageFile([this.path, folder])
93
+
94
+ if (
95
+ packageFile.is()
96
+ && !packageFile.isTest()
97
+ ) {
98
+ packages.push(packageFile)
99
+ }
100
+ }
101
+
102
+ return packages.sort((a, b) => {
103
+ const priorityA = a.get()?.['ui-priority'] ?? 500
104
+ const priorityB = b.get()?.['ui-priority'] ?? 500
105
+ return priorityA - priorityB
106
+ })
107
+ }
108
+
83
109
  /**
84
110
  * Returns the cached version of the package from the build log.
85
111
  *
@@ -270,7 +270,7 @@ export class DesignComponent extends DesignCommand {
270
270
  const option = prop.option
271
271
  let item: string = ''
272
272
 
273
- item += `{ name: '${prop.name}', type: '${prop.type}'`
273
+ item += `{ name: '${prop.name}', type: '${prop.type.replace('| undefined', '').trim()}'`
274
274
 
275
275
  if (
276
276
  option
@@ -5,7 +5,8 @@ import {
5
5
  UI_FILE_AI_PROMPT_DESCRIPTION,
6
6
  UI_FILE_AI_PROMPT_INFO,
7
7
  UI_FILE_AI_PROMPT_TYPES,
8
- UI_FILE_PACKAGE
8
+ UI_FILE_PACKAGE,
9
+ UI_FILE_AI_PROMPT_DEVELOPER
9
10
  } from '../../config'
10
11
 
11
12
  /**
@@ -53,6 +54,7 @@ export class LibraryAiPromptItem {
53
54
  || this.isInfo()
54
55
  || this.isTypes()
55
56
  || this.isScreenshot()
57
+ || this.isDeveloper()
56
58
  }
57
59
 
58
60
  /**
@@ -65,6 +67,16 @@ export class LibraryAiPromptItem {
65
67
  return PropertiesFile.is(this.getPath(UI_FILE_AI_PROMPT_DESCRIPTION))
66
68
  }
67
69
 
70
+ /**
71
+ * Checks if the developer prompt file exists.
72
+ *
73
+ * Проверяет, существует ли файл промпта разработчика.
74
+ * @returns true if developer prompt file exists / true, если файл промпта разработчика существует
75
+ */
76
+ isDeveloper(): boolean {
77
+ return PropertiesFile.is(this.getPath(UI_FILE_AI_PROMPT_DEVELOPER))
78
+ }
79
+
68
80
  /**
69
81
  * Checks if the information file exists.
70
82
  *
@@ -108,7 +120,8 @@ export class LibraryAiPromptItem {
108
120
  this.getDescription(),
109
121
  this.getInfo(),
110
122
  this.getTypes(),
111
- this.getScreenshot()
123
+ this.getScreenshot(),
124
+ this.getDeveloper()
112
125
  ].filter(item => item !== undefined) as string[]
113
126
 
114
127
  if (data.length > 0) {
@@ -201,6 +214,27 @@ ${this.readFile(UI_FILE_AI_PROMPT_DESCRIPTION)}
201
214
  return undefined
202
215
  }
203
216
 
217
+ /**
218
+ * Formats and returns the developer prompt section.
219
+ *
220
+ * Форматирует и возвращает секцию промпта для разработчика.
221
+ * @returns formatted developer prompt or undefined / отформатированный промпт разработчика или undefined
222
+ * @protected
223
+ */
224
+ protected getDeveloper(): string | undefined {
225
+ if (this.isDeveloper()) {
226
+ console.log('-- Developer')
227
+
228
+ return `
229
+ ## Mandatory Study Before Development
230
+ Before developing, modifying, or implementing any code for /${this.getPathString()}, you MUST first study the architectural rules and instructions located in the following file:
231
+ '${this.getPathString()}/${UI_FILE_AI_PROMPT_DEVELOPER}'
232
+ `.trim()
233
+ }
234
+
235
+ return undefined
236
+ }
237
+
204
238
  /**
205
239
  * Formats and returns the info section for the prompt.
206
240
  *
@@ -1,8 +1,13 @@
1
1
  import { PropertiesConfig } from '../classes/Properties/PropertiesConfig'
2
2
 
3
3
  import { AiAbstract } from '../classes/Ai/AiAbstract'
4
+ import { AiClaude } from '../classes/Ai/AiClaude'
5
+ import { AiClaudeAgent } from '../classes/Ai/AiClaudeAgent'
6
+ import { AiClaudeCli } from '../classes/Ai/AiClaudeCli'
4
7
  import { AiGoogle } from '../classes/Ai/AiGoogle'
5
8
  import { AiGoogleCli } from '../classes/Ai/AiGoogleCli'
9
+ import { AiOpenAi } from '../classes/Ai/AiOpenAi'
10
+ import { AiZAi } from '../classes/Ai/AiZAi'
6
11
 
7
12
  /**
8
13
  * Composable to obtain an AI instance based on configuration.
@@ -13,10 +18,20 @@ export function useAi(): AiAbstract | undefined {
13
18
  const type = PropertiesConfig.getAiType()
14
19
 
15
20
  switch (type) {
21
+ case 'claude':
22
+ return new AiClaude()
23
+ case 'claude-agent':
24
+ return new AiClaudeAgent()
25
+ case 'claude-cli':
26
+ return new AiClaudeCli()
16
27
  case 'gemini':
17
28
  return new AiGoogle()
18
29
  case 'gemini-cli':
19
30
  return new AiGoogleCli()
31
+ case 'openai':
32
+ return new AiOpenAi()
33
+ case 'zai':
34
+ return new AiZAi()
20
35
  }
21
36
 
22
37
  return undefined
package/src/config.ts CHANGED
@@ -90,6 +90,8 @@ export const UI_FILE_AI_PROMPT_INSTRUCTION = 'ai-instruction.txt'
90
90
  export const UI_FILE_AI_PROMPT_PROMPT = 'ai-prompt.txt'
91
91
  /** AI prompt types file name / Название файла с типами промпта AI */
92
92
  export const UI_FILE_AI_PROMPT_TYPES = 'ai-types.txt'
93
+ /** AI prompt developer file name / Название файла для разработчика AI */
94
+ export const UI_FILE_AI_PROMPT_DEVELOPER = 'ai-developer.txt'
93
95
 
94
96
  /** File name for storing the list of flags/ Название файла для хранения списка флагов */
95
97
  export const UI_FILE_NAME_FLAGS = 'flags'
package/src/demo/ai.ts ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env vite-node
2
+
3
+ import { useAi } from '../composables/useAi'
4
+
5
+ const ai = useAi()
6
+
7
+ ai?.generate('Who are you?')
8
+ .then((response) => {
9
+ console.log('ai response: ', response)
10
+ })
package/src/library-ai.ts CHANGED
@@ -2,9 +2,9 @@
2
2
  export * from './classes/Ai/AiAbstract'
3
3
  export * from './classes/Ai/AiGoogleLite'
4
4
  export * from './classes/Ai/AiGoogle'
5
- export * from './classes/Ai/AiGoogleCliLite'
6
- export * from './classes/Ai/AiGoogleCli'
7
5
  export * from './classes/Ai/AiClaudeLite'
8
6
  export * from './classes/Ai/AiClaude'
9
- export * from './classes/Ai/AiClaudeCliLite'
10
- export * from './classes/Ai/AiClaudeCli'
7
+ export * from './classes/Ai/AiOpenAiLite'
8
+ export * from './classes/Ai/AiOpenAi'
9
+ export * from './classes/Ai/AiZAiLite'
10
+ export * from './classes/Ai/AiZAi'
package/src/library.ts CHANGED
@@ -1,54 +1,67 @@
1
- // Classes
2
- export * from './classes/Ai/AiAbstract'
3
- export * from './classes/Ai/AiClaude'
4
- export * from './classes/Ai/AiClaudeCli'
5
- export * from './classes/Ai/AiClaudeCliLite'
6
- export * from './classes/Ai/AiClaudeLite'
7
- export * from './classes/Ai/AiDoc'
8
- export * from './classes/Ai/AiDocItem'
9
- export * from './classes/Ai/AiDocItemAbstract'
10
- export * from './classes/Ai/AiDocItemClasses'
11
- export * from './classes/Ai/AiDocItemComposables'
12
- export * from './classes/Ai/AiDocType'
13
- export * from './classes/Ai/AiGoogle'
14
- export * from './classes/Ai/AiGoogleCli'
15
- export * from './classes/Ai/AiGoogleCliLite'
16
- export * from './classes/Ai/AiGoogleLite'
17
- export * from './classes/BrowserItem'
18
- export * from './classes/Build/BuildFunctional'
19
- export * from './classes/BuildItem'
20
- export * from './classes/Design/DesignFigma'
21
- export * from './classes/Design/DesignScreenshot'
22
- export * from './classes/Design/DesignTypes'
23
- export * from './classes/Design/DesignTypescript'
24
- export * from './classes/Design/DesignWikiStorm'
25
- export * from './classes/Design/DesignWikiStormItem'
26
- export * from './classes/FigmaApi'
27
- export * from './classes/Git/GitRead'
28
- export * from './classes/Library/LibraryAiWiki'
29
- export * from './classes/Library/LibraryAiWikiItem'
30
- export * from './classes/Library/LibraryExport'
31
- export * from './classes/Library/LibraryList'
32
- export * from './classes/Library/LibraryPlugin'
33
- export * from './classes/Library/LibraryTypes'
34
- export * from './classes/Properties/PropertiesFile'
35
-
36
- // Composables
37
- export * from './composables/useAi'
38
-
39
- // Functions
40
- export * from './functions/getConfigAi'
41
- export * from './functions/getDirname'
42
- export * from './functions/getPackageJson'
43
- export * from './functions/hasNativeDirname'
44
-
45
- // Types
46
- export * from './types/aiTypes'
47
- export * from './types/configTypes'
48
- export * from './types/designTypes'
49
- export * from './types/figmaApiTypes'
50
- export * from './types/gitTypes'
51
- export * from './types/libraryTypes'
52
- export * from './types/propertyTypes'
53
- export * from './types/screenshotTypes'
54
- export * from './types/webTypes'
1
+ // Classes
2
+ export * from './classes/Ai/AiAbstract'
3
+ export * from './classes/Ai/AiClaude'
4
+ export * from './classes/Ai/AiClaudeAgent'
5
+ export * from './classes/Ai/AiClaudeAgentLite'
6
+ export * from './classes/Ai/AiClaudeCli'
7
+ export * from './classes/Ai/AiClaudeCliLite'
8
+ export * from './classes/Ai/AiClaudeLite'
9
+ export * from './classes/Ai/AiDoc'
10
+ export * from './classes/Ai/AiDocItem'
11
+ export * from './classes/Ai/AiDocItemAbstract'
12
+ export * from './classes/Ai/AiDocItemClasses'
13
+ export * from './classes/Ai/AiDocItemComposables'
14
+ export * from './classes/Ai/AiDocType'
15
+ export * from './classes/Ai/AiGoogle'
16
+ export * from './classes/Ai/AiGoogleCli'
17
+ export * from './classes/Ai/AiGoogleCliLite'
18
+ export * from './classes/Ai/AiGoogleLite'
19
+ export * from './classes/Ai/AiOpenAi'
20
+ export * from './classes/Ai/AiOpenAiLite'
21
+ export * from './classes/Ai/AiZAi'
22
+ export * from './classes/Ai/AiZAiLite'
23
+ export * from './classes/Ai/ApiTmp'
24
+ export * from './classes/BrowserItem'
25
+ export * from './classes/Build/BuildFunctional'
26
+ export * from './classes/Build/BuildPackages'
27
+ export * from './classes/Build/BuildPublishPackages'
28
+ export * from './classes/BuildItem'
29
+ export * from './classes/Design/DesignFigma'
30
+ export * from './classes/Design/DesignScreenshot'
31
+ export * from './classes/Design/DesignTypes'
32
+ export * from './classes/Design/DesignTypescript'
33
+ export * from './classes/Design/DesignWikiStorm'
34
+ export * from './classes/Design/DesignWikiStormItem'
35
+ export * from './classes/FigmaApi'
36
+ export * from './classes/Git/GitRead'
37
+ export * from './classes/Library/LibraryAiPrompt'
38
+ export * from './classes/Library/LibraryAiPromptItem'
39
+ export * from './classes/Library/LibraryAiWiki'
40
+ export * from './classes/Library/LibraryAiWikiItem'
41
+ export * from './classes/Library/LibraryExport'
42
+ export * from './classes/Library/LibraryList'
43
+ export * from './classes/Library/LibraryPlugin'
44
+ export * from './classes/Library/LibraryTypes'
45
+ export * from './classes/Package/PackageFile'
46
+ export * from './classes/Properties/PropertiesFile'
47
+
48
+ // Composables
49
+ export * from './composables/useAi'
50
+
51
+ // Functions
52
+ export * from './functions/getConfigAi'
53
+ export * from './functions/getDirname'
54
+ export * from './functions/getPackageJson'
55
+ export * from './functions/hasNativeDirname'
56
+ export * from './functions/run'
57
+
58
+ // Types
59
+ export * from './types/aiTypes'
60
+ export * from './types/configTypes'
61
+ export * from './types/designTypes'
62
+ export * from './types/figmaApiTypes'
63
+ export * from './types/gitTypes'
64
+ export * from './types/libraryTypes'
65
+ export * from './types/propertyTypes'
66
+ export * from './types/screenshotTypes'
67
+ export * from './types/webTypes'
@@ -2,12 +2,17 @@ Task Goal:
2
2
  The primary goal is to write comprehensive, high-quality documentation for the Vue 3 component.
3
3
 
4
4
  Component Resolution & Analysis:
5
- If the source files of the component were not directly attached or provided in the prompt, they are located in the parent directory (one folder above the current "wiki" folder). In this case, you must thoroughly locate and study the component's main Vue file, its properties/types files, styling sheets, and all reachable dependencies to fully understand its features, internal logic, and behavior in its entirety.
5
+ If the component source files are not directly attached, they are located in the parent directory (one folder above this "wiki" folder). Locate and study the main Vue file, types/props, styles, and dependencies until you fully understand how the component works. Once you have a complete understanding of its behavior and interface, further deep-dive study of outer dependencies is not required.
6
6
 
7
7
  Mandatory Instruction:
8
- You must read and strictly follow the basic rules, coding standards, and templates specified in:
8
+ You must read and deeply study the detailed descriptions, rules, coding standards, and templates specified in:
9
9
  node_modules/@dxtmisha/scripts/src/media/templates/prompts/componentPrompt.en.txt
10
10
 
11
+ You must strictly follow those instructions. However, make sure you save your outputs in the correct target locations:
12
+ - Documentation & playground changes (including MDX files and `stories.ts` playground configurations) must be saved inside this current directory (the "wiki" folder).
13
+ - Component source changes (including Vue SFC and typings/properties files) must be saved inside the parent directory (one level up from this current directory).
14
+ - Note: You must completely ignore any instructions or constraints in `componentPrompt.en.txt` regarding how the final result/output should be returned or structured (specifically ignore rules 5-8, the requirement to split the response into 5 parts separated by "#########", and the prohibition on writing or modifying files). Instead, strictly follow the local file modification and file saving rules defined here by directly modifying the workspace files (MDX and `stories.ts` in the current folder, and Vue SFC and `types.ts` in the parent folder).
15
+
11
16
  All constraints, formatting standards, and styling helper classes described in that file must be adhered to without exception.
12
17
  (Warning: If this file is not accessible, missing, or cannot be read, you do not need to study or follow the instructions from it; instead, proceed with standard high-quality documentation practices.)
13
18
 
@@ -2,6 +2,17 @@
2
2
 
3
3
  Your primary goal is to generate flawless, industrial-grade code that adheres to dxt-ui standards. You promise to follow these rules strictly:
4
4
 
5
+ 0. **Mandatory Deep Study**:
6
+ - Before developing anything for any project or package, you MUST study it completely to fully understand its architecture and stylistic guidelines.
7
+ - Before modifying or fixing any file, you MUST fully study its internal structure and logic first.
8
+ - If any instructions, paths, or files are specified as located inside `node_modules/` or any other external/linked directory, you MUST first check if this package exists locally in the workspace (for example, under `packages/`). If it does exist locally, you MUST resolve the paths to the local workspace package directory and study/modify the local source files instead.
9
+ - **CRITICAL FIRST STEP:** If any project, module, or instruction contains links or references to specific files (e.g. types, developer guides, descriptions), you MUST study all these referenced files as your absolute first action. As soon as you start working with a project, or notice that it is imported/used in the code you are working with, you must immediately read and study all these referenced files before doing any planning, proposing code changes, or writing code. This is mandatory and applies even if the files are located in `node_modules/` (always resolve them to the local workspace directory first if they exist locally).
10
+ - **STRICT BLOCKING GUARD (CHRONOLOGICAL ORDER RULES):**
11
+ 1. Identify all package paths involved in the user request (e.g. `/packages/constructor/...` maps to `@dxtmisha/constructor`).
12
+ 2. Scan the prompt for sections corresponding to those packages.
13
+ 3. Identify all paths to auxiliary documentation/types mentioned in those sections (e.g., `ai-types.txt`, `ai-developer.txt`).
14
+ 4. You MUST use the `view_file` tool to read and study ALL of these referenced files BEFORE calling `list_dir` on component sub-folders, writing any plans/checklists, or proposing/making code changes. Bypassing this order is a critical protocol violation.
15
+
5
16
  1. **"Copy-Paste Ready" Principle**:
6
17
  - Generate code that can be copied and run without a single manual edit.
7
18
  - All imports must be absolute or correct relative paths.
@@ -16,6 +27,9 @@ Your primary goal is to generate flawless, industrial-grade code that adheres to
16
27
  - **DRY & KISS**: Avoid duplication, write as simply and clearly as possible.
17
28
  - **SOLID**: Every module, class, or function must have one clear responsibility.
18
29
  - **Declarative Approach**: Prefer a declarative programming style (array functional methods, composition).
30
+ - **No Abbreviations**: Do not use shortened or abbreviated names for variables, properties, arguments, methods, classes, etc. (e.g., do not use `el`, `rect1`/`r1`, `dx`/`dy`, `val`, `temp`). All identifiers must be descriptive, complete, and self-explanatory.
31
+ - **Optimization and Clarity**: Write code that is highly optimized, performant, and clean, ensuring it is easy to read and understand.
32
+ - **Single Responsibility (KISS/SOLID)**: Avoid creating large "mega-functions" or monolithic blocks. Each function must be concise and perform exactly one focused task (1 function = 1 functionality).
19
33
 
20
34
  4. **Uncompromising TypeScript**:
21
35
  - No `any`. Use `unknown` if the type is truly unknown, or create generic types.
@@ -38,3 +52,8 @@ Your primary goal is to generate flawless, industrial-grade code that adheres to
38
52
  8. **Aesthetics and Conciseness**:
39
53
  - The code must be beautiful. Use logical indentation and group code by meaning.
40
54
  - Save tokens by avoiding redundant comments where the code speaks for itself.
55
+
56
+ 9. **Strict Adherence to Instructions**:
57
+ - Perform all operations strictly in accordance with the provided commands and instructions.
58
+ - Avoid guessing, improvisation, or performing any unrequested or extra actions.
59
+ - Strictly adhere to the plan, checklists, and execution steps.
@@ -2,6 +2,19 @@
2
2
 
3
3
  Твоя главная цель — генерировать безупречный, промышленный код, который соответствует стандартам dxt-ui. Ты обещаешь следовать этим правилам неукоснительно:
4
4
 
5
+ 0. **Обязательное глубокое изучение**:
6
+ - Прежде чем разрабатывать что-либо для любого проекта или пакета, ты ОБЯЗАН полностью изучить его, чтобы детально понять его архитектуру и стилистику.
7
+ - Прежде чем изменять или исправлять любой файл, ты ОБЯЗАН полностью изучить его внутреннюю структуру и логику.
8
+ - Если в инструкциях, путях или файлах указано расположение внутри `node_modules/` или любой другой внешней/привязанной директории, ты ОБЯЗАН сначала проверить, существует ли этот пакет локально в рабочей области (например, в каталоге `packages/`). Если пакет существует локально, ты ОБЯЗАН переопределить пути на локальный каталог пакета рабочей области и изучать/изменять локальные исходные файлы вместо указанных.
9
+ - **КРИТИЧЕСКИЙ ПЕРВЫЙ ШАГ:** Если какой-либо проект, модуль или инструкция содержит ссылки или пути к конкретным файлам (например, типы, руководства для разработчиков, описания), ты ОБЯЗАН подробно изучить все эти файлы по ссылкам в первую очередь. Как только ты начинаешь работу с проектом или видишь, что он импортируется/используется в коде, над которым ты работаешь, ты должен незамедлительно прочитать и изучить все эти файлы по ссылкам, прежде чем приступать к планированию, предложению изменений или написанию кода. Это требование обязательно и распространяется в том числе на файлы, находящиеся в `node_modules/` (всегда сначала переопределяй пути на локальный каталог рабочей области, если они существуют локально).
10
+ - **БЛОКИРУЮЩИЙ КОНТРОЛЬ ПОСЛЕДОВАТЕЛЬНОСТИ (ПРАВИЛО ХРОНОЛОГИИ):**
11
+ 1. Определи все пути пакетов, связанных с запросом (например, `/packages/constructor/...` относится к `@dxtmisha/constructor`).
12
+ 2. Найди в промпте секции, соответствующие этим пакетам.
13
+ 3. Выпиши все пути к вспомогательным файлам типов и руководств, упомянутые в этих секциях (например, `ai-types.txt`, `ai-developer.txt`).
14
+ 4. Ты ОБЯЗАН использовать инструмент `view_file` для чтения и изучения ВСЕХ этих файлов ДО ТОГО, как вызывать `list_dir` для папок компонентов, писать какие-либо планы/чек-листы или вносить/предлагать изменения в код. Нарушение этой последовательности является критическим нарушением протокола.
15
+
16
+
17
+
5
18
  1. **Принцип «Copy-Paste Ready» (Готовность к использованию)**:
6
19
  - Генерируй код, который можно скопировать и запустить без единой правки.
7
20
  - Все импорты должны быть абсолютными или корректными относительными.
@@ -16,6 +29,9 @@
16
29
  - **DRY & KISS**: Избегай дублирования, пиши максимально просто и понятно.
17
30
  - **SOLID**: Каждый модуль, класс или функция должны иметь одну четкую ответственность.
18
31
  - **Декларативность**: Отдавай предпочтение декларативному стилю программирования (функциональные методы массивов, композиция).
32
+ - **Никаких сокращений**: Запрещено использовать сокращенные имена для переменных, свойств, аргументов, методов, классов и т. д. (например, нельзя использовать `el`, `rect1`/`r1`, `dx`/`dy`, `val`, `temp`). Все идентификаторы должны быть информативными, полными и самодокументируемыми.
33
+ - **Оптимизация и понятность**: Код должен быть максимально оптимизированным, производительным и понятным, обеспечивающим легкое чтение и поддержку.
34
+ - **Принцип единой ответственности**: Избегай создания больших «мега-функций» или монолитных блоков. Каждая функция должна быть лаконичной и решать ровно одну задачу (1 функция — 1 функционал).
19
35
 
20
36
  4. **Бескомпромиссный TypeScript**:
21
37
  - Никаких `any`. Используй `unknown`, если тип действительно неизвестен, или создавай generic-типы.
@@ -38,3 +54,8 @@
38
54
  8. **Эстетика и Лаконичность**:
39
55
  - Код должен быть красивым. Используй логические отступы и группировку кода по смыслу.
40
56
  - Экономь токены, избегая избыточных комментариев там, где код говорит сам за себя.
57
+
58
+ 9. **Строгое следование инструкциям**:
59
+ - Выполняй все действия строго в соответствии с предоставленными командами и инструкциями.
60
+ - Никакой самодеятельности, додумывания или выполнения лишних/незапрошенных действий.
61
+ - Строго придерживайся планов, чек-листов и шагов выполнения.
@@ -1,5 +1,12 @@
1
1
  /** AI type for content generation / Тип ИИ для генерации контента */
2
- export type AiType = 'gemini' | 'gemini-cli'
2
+ export type AiType
3
+ = | 'claude'
4
+ | 'claude-cli'
5
+ | 'claude-agent'
6
+ | 'gemini'
7
+ | 'gemini-cli'
8
+ | 'openai'
9
+ | 'zai'
3
10
 
4
11
  /** Configuration structure for the design system UI project / Структура конфигурации для проекта дизайн-системы UI */
5
12
  export type DesignUiConfig = {
@@ -40,7 +47,7 @@ export type DesignUiConfig = {
40
47
  packagePrefix?: string
41
48
 
42
49
  /** AI type for generating content / Тип ИИ для генерации контента */
43
- aiType?: 'gemini'
50
+ aiType?: AiType
44
51
 
45
52
  /** AI model for generating content / Модель ИИ для генерации контента */
46
53
  aiModel?: string
@@ -1,71 +0,0 @@
1
- import { describe, expect, it, vi, beforeEach } from 'vitest'
2
- import { ComponentCreator } from '../ComponentCreator'
3
- import { PropertiesFile } from '../../Properties/PropertiesFile'
4
- import { ComponentItem } from '../ComponentItem'
5
- import { getComponentPaths } from '../../../functions/getComponentPaths'
6
- import { UI_DIRS_COMPONENTS } from '../../../config'
7
-
8
- vi.mock('../../Properties/PropertiesFile', () => ({
9
- PropertiesFile: {
10
- readDirOnlyRecursive: vi.fn(),
11
- readDir: vi.fn()
12
- }
13
- }))
14
-
15
- vi.mock('../ComponentItem', () => ({
16
- ComponentItem: vi.fn().mockImplementation(function () {
17
- return {
18
- make: vi.fn()
19
- }
20
- })
21
- }))
22
-
23
- vi.mock('../../../functions/getComponentPaths', () => ({
24
- getComponentPaths: vi.fn(path => [path, 'full'])
25
- }))
26
-
27
- describe('ComponentCreator', () => {
28
- let creator: ComponentCreator
29
-
30
- beforeEach(() => {
31
- vi.clearAllMocks()
32
- creator = new ComponentCreator()
33
- })
34
-
35
- it('make should call ComponentItem.make for each empty directory', () => {
36
- vi.mocked(PropertiesFile.readDirOnlyRecursive).mockReturnValue(['dir1', 'dir2', 'dir3'])
37
- vi.mocked(PropertiesFile.readDir).mockImplementation((path) => {
38
- if (Array.isArray(path) && path[0] === 'dir2') return ['file.ts']
39
- return []
40
- })
41
-
42
- creator.make()
43
-
44
- expect(ComponentItem).toHaveBeenCalledWith('dir1')
45
- expect(ComponentItem).not.toHaveBeenCalledWith('dir2')
46
- expect(ComponentItem).toHaveBeenCalledWith('dir3')
47
-
48
- const mockInstance1 = vi.mocked(ComponentItem).mock.results[0]?.value
49
- const mockInstance2 = vi.mocked(ComponentItem).mock.results[1]?.value
50
-
51
- expect(mockInstance1?.make).toHaveBeenCalled()
52
- expect(mockInstance2?.make).toHaveBeenCalled()
53
- })
54
-
55
- it('getDirs should return only empty directories', () => {
56
- vi.mocked(PropertiesFile.readDirOnlyRecursive).mockReturnValue(['empty', 'not-empty'])
57
- vi.mocked(PropertiesFile.readDir).mockImplementation((path) => {
58
- if (Array.isArray(path) && path[0] === 'not-empty') return ['index.ts']
59
- return []
60
- })
61
-
62
- // Access protected method for testing
63
- const dirs = (creator as any).getDirs()
64
-
65
- expect(dirs).toContain('empty')
66
- expect(dirs).not.toContain('not-empty')
67
- expect(dirs).toHaveLength(1)
68
- expect(PropertiesFile.readDirOnlyRecursive).toHaveBeenCalledWith(UI_DIRS_COMPONENTS)
69
- expect(getComponentPaths).toHaveBeenCalledWith('empty')
70
- })
71
- })
@@ -1,71 +0,0 @@
1
- import { describe, expect, it, vi, beforeEach } from 'vitest'
2
- import { ComponentItem } from '../ComponentItem'
3
- import { PropertiesFile } from '../../Properties/PropertiesFile'
4
- import { toKebabCase } from '@dxtmisha/functional-basic'
5
-
6
- vi.mock('../../Properties/PropertiesFile', () => ({
7
- PropertiesFile: {
8
- splitForDir: vi.fn(path => path.split('/')),
9
- readFile: vi.fn(),
10
- writeByPath: vi.fn(),
11
- chmod: vi.fn(),
12
- readDirRecursive: vi.fn()
13
- }
14
- }))
15
-
16
- vi.mock('../../../functions/getComponentPaths', () => ({
17
- getComponentPaths: vi.fn(path => [path, 'full'])
18
- }))
19
-
20
- describe('ComponentItem', () => {
21
- let item: ComponentItem
22
- const mockPath = 'src/components/TestComponent'
23
-
24
- beforeEach(() => {
25
- vi.clearAllMocks()
26
- item = new ComponentItem(mockPath)
27
- })
28
-
29
- it('getName should return the last part of the path', () => {
30
- const name = (item as any).getName()
31
- expect(name).toBe('TestComponent')
32
- expect(PropertiesFile.splitForDir).toHaveBeenCalledWith(mockPath)
33
- })
34
-
35
- it('getProjectName should return package name or "Project"', () => {
36
- vi.mocked(PropertiesFile.readFile).mockReturnValue({ name: 'test-project' })
37
- const projectName = (item as any).getProjectName()
38
- expect(projectName).toBe('test-project')
39
-
40
- vi.mocked(PropertiesFile.readFile).mockReturnValue(undefined)
41
- expect((item as any).getProjectName()).toBe('Project')
42
- })
43
-
44
- it('replacement should replace placeholders correctly', () => {
45
- vi.mocked(PropertiesFile.readFile).mockReturnValue({ name: 'test-project' })
46
- const content = 'Name: ComponentDoc, kebab: component-doc, project: [project], path: [path]'
47
- const result = (item as any).replacement(content)
48
-
49
- expect(result).toContain('Name: TestComponent')
50
- expect(result).toContain(`kebab: ${toKebabCase('TestComponent')}`)
51
- expect(result).toContain('project: test-project')
52
- expect(result).toContain(`path: ${mockPath}`)
53
- })
54
-
55
- it('make should read templates and write files with replacements', () => {
56
- vi.mocked(PropertiesFile.readDirRecursive).mockReturnValue(['Template.ts'])
57
- vi.mocked(PropertiesFile.readFile).mockImplementation((path) => {
58
- if (Array.isArray(path) && path.includes('package.json')) return { name: 'test-project' }
59
- return 'export class ComponentDoc {}'
60
- })
61
-
62
- item.make()
63
-
64
- expect(PropertiesFile.readDirRecursive).toHaveBeenCalled()
65
- expect(PropertiesFile.writeByPath).toHaveBeenCalledWith(
66
- expect.arrayContaining([mockPath, 'Template.ts']),
67
- 'export class TestComponent {}'
68
- )
69
- expect(PropertiesFile.chmod).toHaveBeenCalled()
70
- })
71
- })