@dxtmisha/scripts 0.8.1 → 0.8.3
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/package.json +1 -1
- package/src/classes/Design/DesignComponent.ts +1 -1
- package/src/classes/Design/DesignConstructor.ts +1 -1
- package/src/classes/Design/DesignReplace.ts +1 -1
- package/src/classes/Design/DesignUi.ts +4 -4
- package/src/classes/Design/DesignWikiStormItem.ts +48 -8
- package/src/classes/Library/LibraryAiPrompt.ts +17 -0
- package/src/media/templates/prompts/aiCodeGlobalPrompt.en.txt +40 -0
- package/src/media/templates/prompts/aiCodeGlobalPrompt.ru.txt +40 -0
- package/src/types/webTypes.ts +1 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxtmisha/scripts",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.8.
|
|
4
|
+
"version": "0.8.3",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Development scripts and CLI tools for DXT UI projects - automated component generation, library building and project management tools",
|
|
7
7
|
"keywords": [
|
|
@@ -793,7 +793,7 @@ export class DesignComponent extends DesignCommand {
|
|
|
793
793
|
this.updatePackage(
|
|
794
794
|
`exports|${name}`,
|
|
795
795
|
{
|
|
796
|
-
types: `./dist/library/${this.getFullName()}.d.ts`,
|
|
796
|
+
types: `./dist/src/library/${this.getFullName()}.d.ts`,
|
|
797
797
|
default: `./dist/${this.getFullName()}.js`
|
|
798
798
|
}
|
|
799
799
|
)
|
|
@@ -195,7 +195,7 @@ export class DesignConstructor extends DesignCommand {
|
|
|
195
195
|
this.updatePackage(
|
|
196
196
|
`exports|${name}`,
|
|
197
197
|
{
|
|
198
|
-
types: `./dist/constructors/${command}/index.d.ts`,
|
|
198
|
+
types: `./dist/src/constructors/${command}/index.d.ts`,
|
|
199
199
|
default: `./dist/${this.getNameMin()}.js`
|
|
200
200
|
}
|
|
201
201
|
)
|
|
@@ -215,7 +215,7 @@ export class DesignReplace {
|
|
|
215
215
|
&& !this.isNoMark(mark, name)
|
|
216
216
|
) {
|
|
217
217
|
const typesString = !constructor && !types.match(/string|boolean/) && types.match(/'/)
|
|
218
|
-
? `string |
|
|
218
|
+
? `${types}` // string |
|
|
219
219
|
: types
|
|
220
220
|
|
|
221
221
|
templates.push(`${name}?: ${typesString}`)
|
|
@@ -106,15 +106,15 @@ export class DesignUi {
|
|
|
106
106
|
|
|
107
107
|
if (packageJson?.exports) {
|
|
108
108
|
packageJson.exports['.'] = {
|
|
109
|
-
types: './dist/library/types.d.ts',
|
|
109
|
+
types: './dist/src/library/types.d.ts',
|
|
110
110
|
default: './dist/types.js'
|
|
111
111
|
}
|
|
112
112
|
packageJson.exports['./plugin'] = {
|
|
113
|
-
types: './dist/library/plugin.d.ts',
|
|
113
|
+
types: './dist/src/library/plugin.d.ts',
|
|
114
114
|
default: './dist/plugin.js'
|
|
115
115
|
}
|
|
116
116
|
packageJson.exports['./media'] = {
|
|
117
|
-
types: './dist/library/media.d.ts',
|
|
117
|
+
types: './dist/src/library/media.d.ts',
|
|
118
118
|
default: './dist/media.js'
|
|
119
119
|
}
|
|
120
120
|
packageJson.exports['./style.css'] = './dist/style.css'
|
|
@@ -123,7 +123,7 @@ export class DesignUi {
|
|
|
123
123
|
sass: './ui-properties.scss',
|
|
124
124
|
default: './ui-properties.scss'
|
|
125
125
|
}
|
|
126
|
-
packageJson.exports['./types.d.ts'] = './dist/library/types.d.ts'
|
|
126
|
+
packageJson.exports['./types.d.ts'] = './dist/src/library/types.d.ts'
|
|
127
127
|
packageJson['web-types'] = './dist/web-types.json'
|
|
128
128
|
|
|
129
129
|
PropertiesFile.writeByPath(UI_FILE_PACKAGE, packageJson)
|
|
@@ -7,6 +7,13 @@ import { PropertiesFile } from '../Properties/PropertiesFile'
|
|
|
7
7
|
|
|
8
8
|
import type { LibraryData } from '../../types/libraryTypes'
|
|
9
9
|
import type { WebTypesAttributeItem, WebTypesAttributes, WebTypesEvents, WebTypesSlots, WebTypesTagItem } from '../../types/webTypes'
|
|
10
|
+
import { forEach } from '@dxtmisha/functional-basic'
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* List of basic types that do not need to be wrapped in quotes for web-types/
|
|
14
|
+
* Список базовых типов, которые не нужно оборачивать в кавычки для web-types
|
|
15
|
+
*/
|
|
16
|
+
const BASE_TYPES = /^(boolean|number|string|null|any|void|object|unknown|never)$/
|
|
10
17
|
|
|
11
18
|
/**
|
|
12
19
|
* Resolver for extracting and formatting IDE metadata for a specific component.
|
|
@@ -78,13 +85,14 @@ export class DesignWikiStormItem {
|
|
|
78
85
|
* @param item prop item / элемент свойства
|
|
79
86
|
*/
|
|
80
87
|
getAttribute(item: WikiStorybookProp): WebTypesAttributeItem {
|
|
88
|
+
const type = this.prepareType(item.getType())
|
|
81
89
|
return {
|
|
82
90
|
name: item.getName(),
|
|
83
91
|
description: item.getDescription(),
|
|
84
|
-
default: item.getDefaultValue(),
|
|
92
|
+
// default: item.getDefaultValue(),
|
|
85
93
|
value: {
|
|
86
94
|
kind: 'expression',
|
|
87
|
-
type
|
|
95
|
+
type
|
|
88
96
|
}
|
|
89
97
|
}
|
|
90
98
|
}
|
|
@@ -120,8 +128,8 @@ export class DesignWikiStormItem {
|
|
|
120
128
|
|
|
121
129
|
data.slots.forEach(
|
|
122
130
|
props => slots.push({
|
|
123
|
-
name: props.name,
|
|
124
|
-
description: props.description,
|
|
131
|
+
'name': props.name,
|
|
132
|
+
'description': props.description,
|
|
125
133
|
'vue-properties': props.properties ?? []
|
|
126
134
|
})
|
|
127
135
|
)
|
|
@@ -186,10 +194,12 @@ export class DesignWikiStormItem {
|
|
|
186
194
|
const filePath = this.getPaths(['wikiData.ts'])
|
|
187
195
|
|
|
188
196
|
if (PropertiesFile.is(filePath)) {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
197
|
+
try {
|
|
198
|
+
const wiki: Record<string, any> = await import(filePath.join('/'))
|
|
199
|
+
this.dataComponent = Object.values(wiki).find(item => 'component' in item)
|
|
200
|
+
} catch (error) {
|
|
201
|
+
console.error(filePath, error)
|
|
202
|
+
}
|
|
193
203
|
}
|
|
194
204
|
}
|
|
195
205
|
|
|
@@ -222,6 +232,36 @@ export class DesignWikiStormItem {
|
|
|
222
232
|
]
|
|
223
233
|
}
|
|
224
234
|
|
|
235
|
+
/**
|
|
236
|
+
* Formats a type string for web-types.
|
|
237
|
+
*
|
|
238
|
+
* Форматирует строку типа для web-types.
|
|
239
|
+
* @param type original type string / исходная строка типа
|
|
240
|
+
*/
|
|
241
|
+
protected prepareType(type?: string): string | undefined {
|
|
242
|
+
if (type) {
|
|
243
|
+
return forEach(
|
|
244
|
+
type.split('|'),
|
|
245
|
+
(item) => {
|
|
246
|
+
const trimmed = item.trim()
|
|
247
|
+
|
|
248
|
+
if (trimmed === 'undefined') {
|
|
249
|
+
return undefined
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
if (BASE_TYPES.test(trimmed)) {
|
|
253
|
+
return trimmed
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
return `'${trimmed}'`
|
|
257
|
+
}
|
|
258
|
+
)
|
|
259
|
+
.join(' | ')
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
return type
|
|
263
|
+
}
|
|
264
|
+
|
|
225
265
|
/**
|
|
226
266
|
* Initializes the wiki object.
|
|
227
267
|
*
|
|
@@ -8,6 +8,7 @@ import { PropertiesFile } from '../Properties/PropertiesFile'
|
|
|
8
8
|
import { LibraryAiPromptItem } from './LibraryAiPromptItem'
|
|
9
9
|
|
|
10
10
|
import vuePromptText from '../../media/templates/prompts/aiCodeVuePrompt.en.txt?raw'
|
|
11
|
+
import globalPromptText from '../../media/templates/prompts/aiCodeGlobalPrompt.en.txt?raw'
|
|
11
12
|
|
|
12
13
|
const LIBRARY_AI_PROMPT_LIST_DIRS = [
|
|
13
14
|
UI_MODULES
|
|
@@ -65,6 +66,7 @@ It is critically important to strictly follow all the prompts and instructions l
|
|
|
65
66
|
- If you do not know something or lack information, state it explicitly rather than making assumptions.
|
|
66
67
|
- Be sure to study package.json to know which packages are available and rely exclusively on them when writing code.
|
|
67
68
|
`.trim(),
|
|
69
|
+
this.getGlobalPrompt(),
|
|
68
70
|
this.getVuePrompt()
|
|
69
71
|
]
|
|
70
72
|
|
|
@@ -133,6 +135,21 @@ ${vuePromptText}
|
|
|
133
135
|
`.trim()
|
|
134
136
|
}
|
|
135
137
|
|
|
138
|
+
/**
|
|
139
|
+
* Retrieves the global code implementation prompt.
|
|
140
|
+
*
|
|
141
|
+
* Получает глобальный промпт по реализации кода.
|
|
142
|
+
* @returns formatted global prompt or undefined / отформатированный глобальный промпт или undefined
|
|
143
|
+
* @protected
|
|
144
|
+
*/
|
|
145
|
+
protected getGlobalPrompt(): string {
|
|
146
|
+
return `
|
|
147
|
+
## Global code implementation rules
|
|
148
|
+
The global rules for code implementation are listed below. These instructions are mandatory for ensuring high-quality, professional-grade development across the entire project.
|
|
149
|
+
${globalPromptText}
|
|
150
|
+
`.trim()
|
|
151
|
+
}
|
|
152
|
+
|
|
136
153
|
/**
|
|
137
154
|
* Recursively scans directories to collect LibraryAiPromptItem instances.
|
|
138
155
|
*
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
### Global Development Principles (AI Code Promise)
|
|
2
|
+
|
|
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
|
+
|
|
5
|
+
1. **"Copy-Paste Ready" Principle**:
|
|
6
|
+
- Generate code that can be copied and run without a single manual edit.
|
|
7
|
+
- All imports must be absolute or correct relative paths.
|
|
8
|
+
- No `// ... rest of the code`, no `// imports here`. Only the complete, working file.
|
|
9
|
+
|
|
10
|
+
2. **Zero Tolerance for Hallucinations**:
|
|
11
|
+
- Use only the libraries and versions specified in the project's `package.json`.
|
|
12
|
+
- Do not invent API methods that do not exist in the current versions of dependencies.
|
|
13
|
+
- If information is insufficient, it is better to ask or point out the limitation than to hallucinate.
|
|
14
|
+
|
|
15
|
+
3. **Clean Code Standards**:
|
|
16
|
+
- **DRY & KISS**: Avoid duplication, write as simply and clearly as possible.
|
|
17
|
+
- **SOLID**: Every module, class, or function must have one clear responsibility.
|
|
18
|
+
- **Declarative Approach**: Prefer a declarative programming style (array functional methods, composition).
|
|
19
|
+
|
|
20
|
+
4. **Uncompromising TypeScript**:
|
|
21
|
+
- No `any`. Use `unknown` if the type is truly unknown, or create generic types.
|
|
22
|
+
- Always define interfaces for input and output data.
|
|
23
|
+
- Use `as const`, `readonly`, and enums/union types to increase reliability.
|
|
24
|
+
|
|
25
|
+
5. **Professional Documentation (TSDoc)**:
|
|
26
|
+
- Accompany all exported entities with TSDoc comments in the [wikiLanguage] language.
|
|
27
|
+
- Describe the purpose, parameters, return values, and potential exceptions.
|
|
28
|
+
- Usage examples in comments are encouraged for complex functions.
|
|
29
|
+
|
|
30
|
+
6. **Architectural Consistency**:
|
|
31
|
+
- Respect the project structure. If it is standard in the project to move logic into `composables` or `utils`, follow that pattern.
|
|
32
|
+
- Do not modify global styles or styles of base UI components unless explicitly requested.
|
|
33
|
+
|
|
34
|
+
7. **Security and Performance**:
|
|
35
|
+
- Write error-proof code (guard clauses, optional chaining `?.`, nullish coalescing `??`).
|
|
36
|
+
- Avoid redundant calculations in loops and heavy operations in reactive dependencies.
|
|
37
|
+
|
|
38
|
+
8. **Aesthetics and Conciseness**:
|
|
39
|
+
- The code must be beautiful. Use logical indentation and group code by meaning.
|
|
40
|
+
- Save tokens by avoiding redundant comments where the code speaks for itself.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
### Глобальные принципы разработки (AI Code Promise)
|
|
2
|
+
|
|
3
|
+
Твоя главная цель — генерировать безупречный, промышленный код, который соответствует стандартам dxt-ui. Ты обещаешь следовать этим правилам неукоснительно:
|
|
4
|
+
|
|
5
|
+
1. **Принцип «Copy-Paste Ready» (Готовность к использованию)**:
|
|
6
|
+
- Генерируй код, который можно скопировать и запустить без единой правки.
|
|
7
|
+
- Все импорты должны быть абсолютными или корректными относительными.
|
|
8
|
+
- Никаких `// ... остальной код`, никаких `// импорты здесь`. Только полный, рабочий файл.
|
|
9
|
+
|
|
10
|
+
2. **Нулевая толерантность к галлюцинациям**:
|
|
11
|
+
- Используй только те библиотеки и версии, которые указаны в `package.json` проекта.
|
|
12
|
+
- Не выдумывай методы API, которых не существует в текущих версиях зависимостей.
|
|
13
|
+
- Если информации недостаточно — лучше спроси или укажи на ограничение, чем галлюцинируй.
|
|
14
|
+
|
|
15
|
+
3. **Стандарты чистого кода (Clean Code)**:
|
|
16
|
+
- **DRY & KISS**: Избегай дублирования, пиши максимально просто и понятно.
|
|
17
|
+
- **SOLID**: Каждый модуль, класс или функция должны иметь одну четкую ответственность.
|
|
18
|
+
- **Декларативность**: Отдавай предпочтение декларативному стилю программирования (функциональные методы массивов, композиция).
|
|
19
|
+
|
|
20
|
+
4. **Бескомпромиссный TypeScript**:
|
|
21
|
+
- Никаких `any`. Используй `unknown`, если тип действительно неизвестен, или создавай generic-типы.
|
|
22
|
+
- Всегда определяй интерфейсы для входных и выходных данных.
|
|
23
|
+
- Используй `as const`, `readonly` и перечисления (enums/union types) для повышения надежности.
|
|
24
|
+
|
|
25
|
+
5. **Профессиональное документирование (TSDoc)**:
|
|
26
|
+
- Сопровождай все экспортируемые сущности комментариями TSDoc на [wikiLanguage] языке.
|
|
27
|
+
- Описывай назначение, параметры, возвращаемые значения и возможные исключения.
|
|
28
|
+
- Примеры использования в комментариях приветствуются для сложных функций.
|
|
29
|
+
|
|
30
|
+
6. **Архитектурная консистентность**:
|
|
31
|
+
- Соблюдай структуру проекта. Если в проекте принято выносить логику в `composables` или `utils` — следуй этому паттерну.
|
|
32
|
+
- Не изменяй глобальные стили или стили базовых UI-компонентов, если это не было явно запрошено.
|
|
33
|
+
|
|
34
|
+
7. **Безопасность и Производительность**:
|
|
35
|
+
- Пиши код, защищенный от ошибок (guard clauses, опциональная цепочка `?.`, nullish coalescing `??`).
|
|
36
|
+
- Избегай лишних вычислений в циклах и тяжелых операций в реактивных зависимостях.
|
|
37
|
+
|
|
38
|
+
8. **Эстетика и Лаконичность**:
|
|
39
|
+
- Код должен быть красивым. Используй логические отступы и группировку кода по смыслу.
|
|
40
|
+
- Экономь токены, избегая избыточных комментариев там, где код говорит сам за себя.
|
package/src/types/webTypes.ts
CHANGED
|
@@ -25,7 +25,7 @@ export type WebTypesProperties = WebTypesProperty[]
|
|
|
25
25
|
*
|
|
26
26
|
* Вид значения атрибута.
|
|
27
27
|
*/
|
|
28
|
-
export type WebTypesAttributeKind = 'expression' | 'string'
|
|
28
|
+
export type WebTypesAttributeKind = 'expression' | 'plainText' | 'string'
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
31
|
* Attribute definition for a tag.
|