@dxtmisha/scripts 0.10.15 → 0.11.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 +30 -0
- package/bin/design-types-save.ts +9 -0
- package/package.json +2 -1
- package/src/classes/Design/DesignTypes.ts +41 -520
- package/src/classes/Design/DesignTypesAi.ts +135 -0
- package/src/classes/Design/DesignTypesDescription.ts +109 -0
- package/src/classes/Design/DesignTypesMake.ts +460 -0
- package/src/classes/Design/DesignTypesMcp.ts +90 -0
- package/src/classes/Design/DesignTypesPrompts.ts +289 -0
- package/src/config.ts +2 -0
- package/src/library.ts +73 -68
- package/src/media/templates/packages/library/_.gitignore.txt +2 -0
- package/src/media/templates/prompts/aiCodeVuePrompt.en.md +1 -1
- package/src/media/templates/prompts/aiCodeVuePrompt.ru.md +1 -1
- package/src/types/designTypes.ts +37 -0
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { getPackageJson } from '../../functions/getPackageJson'
|
|
2
|
+
import { useAi } from '../../composables/useAi'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Class for handling low-level AI interactions, directory configuration, and prompt execution.
|
|
6
|
+
*
|
|
7
|
+
* Класс для низкоуровневого взаимодействия с ИИ, конфигурации директории и выполнения промптов.
|
|
8
|
+
*/
|
|
9
|
+
export class DesignTypesAi {
|
|
10
|
+
/** Cached project name / Кэшированное название проекта */
|
|
11
|
+
protected projectName: string
|
|
12
|
+
|
|
13
|
+
/** Array of directory path segments / Массив сегментов пути директории */
|
|
14
|
+
protected readonly dirArray: string[]
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Constructor for DesignTypesAi.
|
|
18
|
+
*
|
|
19
|
+
* Конструктор для DesignTypesAi.
|
|
20
|
+
* @param dir input directory path containing declaration files / входной путь к директории, содержащей файлы деклараций
|
|
21
|
+
* @param isRaw flag disabling AI processing / флаг отключения ИИ обработки
|
|
22
|
+
*/
|
|
23
|
+
constructor(
|
|
24
|
+
protected readonly dir: string = 'dist',
|
|
25
|
+
protected readonly isRaw: boolean = false
|
|
26
|
+
) {
|
|
27
|
+
this.dirArray = this.dir.split('/')
|
|
28
|
+
this.projectName = getPackageJson()?.name ?? 'none'
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Returns the array of directory path segments.
|
|
33
|
+
*
|
|
34
|
+
* Возвращает массив сегментов пути директории.
|
|
35
|
+
* @returns directory path segments / сегменты пути директории
|
|
36
|
+
*/
|
|
37
|
+
getDirArray(): string[] {
|
|
38
|
+
return this.dirArray
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Returns the project name from package.json.
|
|
43
|
+
*
|
|
44
|
+
* Возвращает название проекта из package.json.
|
|
45
|
+
* @returns project name or 'none' / название проекта или 'none'
|
|
46
|
+
*/
|
|
47
|
+
getProjectName(): string {
|
|
48
|
+
return this.projectName
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Sends content and a prompt to the AI for processing.
|
|
53
|
+
*
|
|
54
|
+
* Отправляет контент и промпт ИИ для обработки.
|
|
55
|
+
* @param content content for processing / контент для обработки
|
|
56
|
+
* @param prompt instructions for the AI / инструкции для ИИ
|
|
57
|
+
* @param code code to optimize / код для оптимизации
|
|
58
|
+
* @returns AI generated content or undefined / сгенерированный ИИ контент или undefined
|
|
59
|
+
*/
|
|
60
|
+
async toAi(
|
|
61
|
+
content: string,
|
|
62
|
+
prompt: string,
|
|
63
|
+
code?: string
|
|
64
|
+
): Promise<string | undefined> {
|
|
65
|
+
if (this.isRaw) {
|
|
66
|
+
return undefined
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const ai = useAi()
|
|
70
|
+
|
|
71
|
+
if (ai) {
|
|
72
|
+
if (code) {
|
|
73
|
+
ai.addPrompt(
|
|
74
|
+
`File JS Code (SUPPLEMENTARY REFERENCE & CONTEXT ONLY):\n`
|
|
75
|
+
+ `The following JavaScript code is provided STRICTLY as supplementary background context to give a full picture of implementation details and logic.\n`
|
|
76
|
+
+ `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".\n\n`
|
|
77
|
+
+ '```\n'
|
|
78
|
+
+ `${code}\n`
|
|
79
|
+
+ '```'
|
|
80
|
+
)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
ai.addPrompt('You are a world-class senior developer and an exceptional technical writer.')
|
|
84
|
+
ai.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.')
|
|
85
|
+
ai.addPrompt(
|
|
86
|
+
`TASK INSTRUCTIONS & GOAL:\n`
|
|
87
|
+
+ `The following are the exact rules, requirements, and execution instructions for processing the file content:\n\n`
|
|
88
|
+
+ `${prompt}`
|
|
89
|
+
)
|
|
90
|
+
ai.addPrompt(
|
|
91
|
+
`File Content (PRIMARY DATA TO PROCESS):\n`
|
|
92
|
+
+ `The following is the primary target file content that you MUST process according to the instructions in the prompt above:\n`
|
|
93
|
+
+ '```\n'
|
|
94
|
+
+ `${content}\n`
|
|
95
|
+
+ '```'
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
const generate = await ai.generate('go!')
|
|
99
|
+
|
|
100
|
+
if (generate) {
|
|
101
|
+
return generate
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return undefined
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Sends content and a prompt to the AI for processing and parses the resulting JSON response.
|
|
110
|
+
*
|
|
111
|
+
* Отправляет контент и промпт ИИ для обработки и парсит полученный JSON-ответ.
|
|
112
|
+
* @param content content for processing / контент для обработки
|
|
113
|
+
* @param prompt instructions for the AI / инструкции для ИИ
|
|
114
|
+
* @param code code to optimize / код для оптимизации
|
|
115
|
+
* @returns parsed JSON object or undefined / распарсенный JSON объект или undefined
|
|
116
|
+
*/
|
|
117
|
+
async toAiJson<T>(
|
|
118
|
+
content: string,
|
|
119
|
+
prompt: string,
|
|
120
|
+
code?: string
|
|
121
|
+
): Promise<T | undefined> {
|
|
122
|
+
const generate = await this.toAi(content, prompt, code)
|
|
123
|
+
|
|
124
|
+
if (generate) {
|
|
125
|
+
try {
|
|
126
|
+
const cleaned = generate.replace(/```json|```/g, '').trim()
|
|
127
|
+
return JSON.parse(cleaned) as T
|
|
128
|
+
} catch {
|
|
129
|
+
return undefined
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return undefined
|
|
134
|
+
}
|
|
135
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { PropertiesFile } from '../Properties/PropertiesFile'
|
|
2
|
+
import { DesignTypesAi } from './DesignTypesAi'
|
|
3
|
+
import { DesignTypesMake } from './DesignTypesMake'
|
|
4
|
+
import { DesignTypesPrompts } from './DesignTypesPrompts'
|
|
5
|
+
|
|
6
|
+
import { UI_FILE_AI_DESCRIPTION } from '../../config'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Class for generating, processing, and saving AI project descriptions.
|
|
10
|
+
*
|
|
11
|
+
* Класс для генерации, обработки и сохранения описания проекта ИИ.
|
|
12
|
+
*/
|
|
13
|
+
export class DesignTypesDescription {
|
|
14
|
+
/** Cached full description content / Кэшированный полный контент описания */
|
|
15
|
+
protected fullDescription?: string
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Constructor for DesignTypesDescription.
|
|
19
|
+
*
|
|
20
|
+
* Конструктор для DesignTypesDescription.
|
|
21
|
+
* @param ai instance of DesignTypesAi for AI interactions / экземпляр DesignTypesAi для ИИ взаимодействия
|
|
22
|
+
* @param makeTypes instance of DesignTypesMake for type definitions content access / экземпляр DesignTypesMake для доступа к контенту определений типов
|
|
23
|
+
* @param prompts instance of DesignTypesPrompts for prompt list management / экземпляр DesignTypesPrompts для управления списком промптов
|
|
24
|
+
* @param isRaw flag disabling AI processing / флаг отключения ИИ обработки
|
|
25
|
+
*/
|
|
26
|
+
constructor(
|
|
27
|
+
protected readonly ai: DesignTypesAi,
|
|
28
|
+
protected readonly makeTypes: DesignTypesMake,
|
|
29
|
+
protected readonly prompts: DesignTypesPrompts,
|
|
30
|
+
protected readonly isRaw: boolean = false
|
|
31
|
+
) { }
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Returns the generated full description content.
|
|
35
|
+
*
|
|
36
|
+
* Возвращает сгенерированный полный контент описания.
|
|
37
|
+
* @returns full description string / строка полного описания
|
|
38
|
+
*/
|
|
39
|
+
getFullDescription(): string {
|
|
40
|
+
return this.fullDescription ?? ''
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Generates and saves AI description file.
|
|
45
|
+
*
|
|
46
|
+
* Генерирует и сохраняет файл описания ИИ.
|
|
47
|
+
* @returns current instance / текущий экземпляр
|
|
48
|
+
*/
|
|
49
|
+
async make(): Promise<this> {
|
|
50
|
+
let fullDescription = ''
|
|
51
|
+
|
|
52
|
+
if (!this.isRaw) {
|
|
53
|
+
const fullContent = this.makeTypes.getFullContent()
|
|
54
|
+
const fullJsContent = this.makeTypes.getFullJsContent()
|
|
55
|
+
const promptsText = await this.prompts.toAiPrompts()
|
|
56
|
+
|
|
57
|
+
const aiDescription = await this.toAiDescription(fullContent, fullJsContent)
|
|
58
|
+
|
|
59
|
+
fullDescription = `${aiDescription}\n${promptsText}`
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
this.fullDescription = fullDescription
|
|
63
|
+
this.saveDescription(fullDescription)
|
|
64
|
+
|
|
65
|
+
return this
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Saves the AI-generated project description to a file.
|
|
70
|
+
*
|
|
71
|
+
* Сохраняет сгенерированное ИИ описание проекта в файл.
|
|
72
|
+
* @param content content to save / контент для сохранения
|
|
73
|
+
*/
|
|
74
|
+
protected saveDescription(content: string): void {
|
|
75
|
+
PropertiesFile.writeByPath(
|
|
76
|
+
UI_FILE_AI_DESCRIPTION,
|
|
77
|
+
content
|
|
78
|
+
)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Generates a project description and usage guidelines using AI.
|
|
83
|
+
*
|
|
84
|
+
* Генерирует описание проекта и рекомендации по использованию с помощью ИИ.
|
|
85
|
+
* @param content cleaned type definitions / очищенные определения типов
|
|
86
|
+
* @param code JS code for analysis / JS код для анализа
|
|
87
|
+
* @returns project description string / строка описания проекта
|
|
88
|
+
*/
|
|
89
|
+
protected async toAiDescription(content: string, code?: string): Promise<string> {
|
|
90
|
+
const generate = await this.ai.toAi(
|
|
91
|
+
content,
|
|
92
|
+
'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\n'
|
|
93
|
+
+ 'STRUCTURE & CONTENT REQUIREMENTS:\n'
|
|
94
|
+
+ '1. Package Description: 1-2 concise sentences explaining what this package is and its core technical purpose.\n'
|
|
95
|
+
+ '2. Triggers for Studying ai-types.md: Clear explanation of when and why an AI assistant must study "ai-types.md" (specific tasks, keywords, or architectural requirements).\n'
|
|
96
|
+
+ '3. Key Capabilities: A list of key functional capabilities where each item is strictly 1 to 3 words long (e.g. "Form Controls", "API Integration", "Storage State").\n\n'
|
|
97
|
+
+ 'CRITICAL RESTRICTIONS:\n'
|
|
98
|
+
+ '- Each item in the Key Capabilities list MUST be strictly 1 to 3 words.\n'
|
|
99
|
+
+ '- Do NOT list individual method, function, or class names.\n'
|
|
100
|
+
+ '- Analyze ONLY the provided type definitions and JS code.\n'
|
|
101
|
+
+ '- Do NOT wrap output in markdown code blocks (```).\n\n'
|
|
102
|
+
+ 'OUTPUT REQUIREMENTS:\n'
|
|
103
|
+
+ 'Return ONLY the final description text. No explanations, no code blocks, and no conversational fluff.',
|
|
104
|
+
code
|
|
105
|
+
)
|
|
106
|
+
|
|
107
|
+
return generate ?? ''
|
|
108
|
+
}
|
|
109
|
+
}
|