openprompt-lang 0.3.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/LICENSE +21 -0
- package/README.md +663 -0
- package/bin/cli.js +110 -0
- package/bin/lint.js +50 -0
- package/docs/COMMANDS.md +229 -0
- package/docs/COMMITS/INDEX.md +11 -0
- package/docs/COMMITS/v0.1.0-existing.md +31 -0
- package/docs/COMMITS/v0.1.0-inicial.md +50 -0
- package/docs/COMMITS/v0.1.0-readme.md +24 -0
- package/docs/COMMITS/v0.2.0-strict-db-templates.md +50 -0
- package/docs/COMMITS/v0.3.0-parser-fixes-vscode.md +67 -0
- package/docs/COMMITS/v0.3.0-versioning-component.md +44 -0
- package/docs/DEPENDENCIES.md +45 -0
- package/docs/FRAMEWORK.md +1741 -0
- package/docs/SYNTAX.md +359 -0
- package/docs/VERSIONING.md +150 -0
- package/docs/referencia-metodologia/Anexos Finales Documentos de Respaldo y Estandarizaci/303/263n.md" +90 -0
- package/docs/referencia-metodologia/Cotizaciones.md +84 -0
- package/docs/referencia-metodologia/Example.md +1 -0
- package/docs/referencia-metodologia/ExtractorInformacion.py +78 -0
- package/docs/referencia-metodologia/Fase - 1 .- Desarrollo de la Metodolog/303/255a.md" +67 -0
- package/docs/referencia-metodologia/Fase - 2 .- Levantamiento de requisitos generales y traduccion a la IA.md +64 -0
- package/docs/referencia-metodologia/Fase - 3 .- Prototipado visual con IA (Figma Maker o equivalentes).md +64 -0
- package/docs/referencia-metodologia/Fase - 4 .- Especificacion de requisitos e iteracion con el cliente.md +58 -0
- package/docs/referencia-metodologia/Fase - 5 .- Estructuracion y maquetado de funciones (Scaffolding).md +118 -0
- package/docs/referencia-metodologia/Fase - 6 .- Estructuracion del backlog y division de tareas.md +48 -0
- package/docs/referencia-metodologia/Fase - 7 .- Desarrollo activo, pruebas y control de versiones.md +98 -0
- package/docs/referencia-metodologia/Fase - 8 .- Entrega, capacitaci/303/263n y mantenimiento.md" +55 -0
- package/docs/referencia-metodologia/Figma prompt template.md +130 -0
- package/docs/referencia-metodologia/Framework de Desarrollo Asistido por IA.md +1741 -0
- package/docs/referencia-metodologia/Indice General.md +83 -0
- package/docs/referencia-metodologia/Prompt refactorizar o creacion desde cero.md +50 -0
- package/docs/referencia-metodologia/docs/CONVENCIONES_DB.md +410 -0
- package/docs/referencia-metodologia/docs/CONVENCIONES_DOCUMENTACION.md +209 -0
- package/docs/referencia-metodologia/docs/PROMPTS/INDEX.md +73 -0
- package/docs/referencia-metodologia/docs/PROMPTS/PLANTILLAS/01-hook-supabase.md +79 -0
- package/docs/referencia-metodologia/docs/PROMPTS/PLANTILLAS/02-componente-ui.md +82 -0
- package/docs/referencia-metodologia/docs/PROMPTS/PLANTILLAS/03-pagina-feature.md +70 -0
- package/docs/referencia-metodologia/docs/PROMPTS/PLANTILLAS/04-comando-tauri.md +56 -0
- package/docs/referencia-metodologia/docs/PROMPTS/PLANTILLAS/05-store-zustand.md +74 -0
- package/docs/referencia-metodologia/docs/PROMPTS/PLANTILLAS/06-servicio-supabase.md +74 -0
- package/docs/referencia-metodologia/docs/PROMPTS/PLANTILLAS/07-formulario-validacion.md +63 -0
- package/docs/referencia-metodologia/docs/PROMPTS/PLANTILLAS/08-hook-capacitor.md +65 -0
- package/docs/referencia-metodologia/docs/PROMPTS/PLANTILLAS/09-refactor-division.md +51 -0
- package/docs/referencia-metodologia/docs/PROMPTS/PLANTILLAS/10-scaffolding-inicial.md +79 -0
- package/docs/referencia-metodologia/docs/PROMPTS/PLANTILLAS/11-supabase-crud-service.md +114 -0
- package/docs/referencia-metodologia/docs/PROMPTS/PLANTILLAS/12-supabase-hook-usetable.md +143 -0
- package/docs/referencia-metodologia/docs/PROMPTS/PLANTILLAS/13-tauri-command-rust.md +84 -0
- package/docs/referencia-metodologia/docs/PROMPTS/PLANTILLAS/14-tauri-wrapper-typescript.md +92 -0
- package/docs/referencia-metodologia/docs/PROMPTS/PLANTILLAS/15-documentar-tabla-db.md +50 -0
- package/docs/referencia-metodologia/docs/PROMPTS/PLANTILLAS/16-diagrama-arquitectura.md +60 -0
- package/docs/referencia-metodologia/docs/PROMPTS/PLANTILLAS/17-documentar-api-rpc.md +56 -0
- package/docs/referencia-metodologia/docs/PROMPTS/STACK/ionic-capacitor.md +52 -0
- package/docs/referencia-metodologia/docs/PROMPTS/STACK/react-web-puro.md +46 -0
- package/docs/referencia-metodologia/docs/PROMPTS/STACK/tauri-desktop.md +53 -0
- package/package.json +56 -0
- package/schemas/prompt-lang.json +98 -0
- package/src/commands/component.js +326 -0
- package/src/commands/context.js +206 -0
- package/src/commands/figma.js +63 -0
- package/src/commands/init.js +373 -0
- package/src/commands/suggest.js +31 -0
- package/src/commands/validate.js +183 -0
- package/src/generators/figma-prompt.js +56 -0
- package/src/utils/ai.js +143 -0
- package/src/utils/annotations.js +510 -0
- package/src/utils/config.js +60 -0
- package/vscode-extension/README.md +31 -0
- package/vscode-extension/language-configuration.json +7 -0
- package/vscode-extension/package.json +62 -0
- package/vscode-extension/snippets/promptlang.json +105 -0
- package/vscode-extension/syntaxes/annotations.tmGrammar.json +39 -0
- package/vscode-extension/syntaxes/promptlang.tmGrammar.json +14 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 openPrompt-Lang
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,663 @@
|
|
|
1
|
+
# OpenPrompt-Lang
|
|
2
|
+
|
|
3
|
+
Framework de anotaciones para desarrollo asistido por IA. Sistema de anotaciones `@kind`, `@contract`, `@limit`, etc. para guiar a la IA en proyectos React + TypeScript.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
openPrompt-Lang --version
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Índice
|
|
12
|
+
|
|
13
|
+
- [Instalación](#instalación)
|
|
14
|
+
- [Anotaciones PromptLang (directorio completo)](#anotaciones-promptlang-directorio-completo)
|
|
15
|
+
- [Tags de definición](#tags-de-definición)
|
|
16
|
+
- [Tags de contrato](#tags-de-contrato)
|
|
17
|
+
- [Tags de restricción](#tags-de-restricción)
|
|
18
|
+
- [Tags de composición](#tags-de-composición)
|
|
19
|
+
- [Tags de plataforma](#tags-de-plataforma)
|
|
20
|
+
- [Tags de alcance](#tags-de-alcance)
|
|
21
|
+
- [Tags de testing](#tags-de-testing)
|
|
22
|
+
- [Tags de metadata](#tags-de-metadata)
|
|
23
|
+
- [Comandos CLI](#comandos-cli)
|
|
24
|
+
- [Tutorial: Empezar desde 0](#tutorial-empezar-desde-0)
|
|
25
|
+
- [Tutorial: Refactorizar proyecto existente](#tutorial-refactorizar-proyecto-existente)
|
|
26
|
+
- [Configuración (prompt-lang.json)](#configuración-prompt-langjson)
|
|
27
|
+
- [Validación cruzada](#validación-cruzada)
|
|
28
|
+
- [Scripts descriptivos](#scripts-descriptivos)
|
|
29
|
+
- [Estructura del proyecto](#estructura-del-proyecto)
|
|
30
|
+
- [Sistema de componentes](#sistema-de-componentes)
|
|
31
|
+
- [VS Code Extension](#vs-code-extension)
|
|
32
|
+
- [Versionado (SemVer)](#versionado-semver)
|
|
33
|
+
- [Documentación](#documentación)
|
|
34
|
+
- [Publicación en npm](#publicación-en-npm)
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## Instalación
|
|
39
|
+
|
|
40
|
+
### Linux / macOS
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
# Instalación global
|
|
44
|
+
npm install -g openprompt-lang
|
|
45
|
+
|
|
46
|
+
# Si no tienes permisos globales:
|
|
47
|
+
npm config set prefix ~/.npm-global
|
|
48
|
+
export PATH="$HOME/.npm-global/bin:$PATH" # agrega a ~/.bashrc o ~/.zshrc
|
|
49
|
+
npm install -g openprompt-lang
|
|
50
|
+
|
|
51
|
+
# Verificar
|
|
52
|
+
openPrompt-Lang --version
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Windows (PowerShell)
|
|
56
|
+
|
|
57
|
+
```powershell
|
|
58
|
+
# Instalación global
|
|
59
|
+
npm install -g openprompt-lang
|
|
60
|
+
|
|
61
|
+
# Si no tienes permisos globales (ejecutar como Administrador una vez):
|
|
62
|
+
npm config set prefix "${env:APPDATA}\npm"
|
|
63
|
+
# O crear carpeta local:
|
|
64
|
+
mkdir "$env:USERPROFILE\.npm-global" -Force
|
|
65
|
+
npm config set prefix "$env:USERPROFILE\.npm-global"
|
|
66
|
+
# Agregar al PATH (PowerShell profile):
|
|
67
|
+
[Environment]::SetEnvironmentVariable("Path", "$env:USERPROFILE\.npm-global\bin;" + $env:Path, "User")
|
|
68
|
+
# O desde cmd/símbolo del sistema:
|
|
69
|
+
:: setx PATH "%USERPROFILE%\.npm-global\bin;%PATH%"
|
|
70
|
+
|
|
71
|
+
# Verificar
|
|
72
|
+
openPrompt-Lang --version
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Alternativa: npx (sin instalar)
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
npx openprompt-lang --help
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
> El paquete está publicado en npm: `npx openprompt-lang --help`
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## Anotaciones PromptLang (directorio completo)
|
|
86
|
+
|
|
87
|
+
Las anotaciones se escriben como comentarios en el código. La IA las interpreta para entender restricciones, contratos y contexto del archivo.
|
|
88
|
+
|
|
89
|
+
### Sintaxis general
|
|
90
|
+
|
|
91
|
+
```typescript
|
|
92
|
+
// @nombre(args)
|
|
93
|
+
// @nombre(key: value, key2: value2)
|
|
94
|
+
|
|
95
|
+
/* Formato multilinea */
|
|
96
|
+
/*
|
|
97
|
+
* @use(kind, contract, deps)
|
|
98
|
+
* @kind(service)
|
|
99
|
+
* @contract(in: DTO -> out: Result @error: ServiceError)
|
|
100
|
+
*/
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### @use — Declaración de tags (OBLIGATORIO)
|
|
104
|
+
|
|
105
|
+
Primer tag de todo archivo. Declara qué tags se usan.
|
|
106
|
+
|
|
107
|
+
| Sintaxis | Significado |
|
|
108
|
+
|---|---|
|
|
109
|
+
| `@use(*)` | Todos los tags disponibles |
|
|
110
|
+
| `@use(kind, contract)` | Solo los tags listados |
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
### Tags de definición
|
|
115
|
+
|
|
116
|
+
#### @kind — Tipo de elemento
|
|
117
|
+
|
|
118
|
+
```
|
|
119
|
+
@kind(tipo)
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
| Valor | Descripción | Tags requeridos | Tags prohibidos | Límite default |
|
|
123
|
+
|---|---|---|---|---|
|
|
124
|
+
| `hook` | Custom hook React | `@contract` | `@props` | 80 líneas |
|
|
125
|
+
| `component` | Componente UI | `@props` (recomendado) | `@contract` | 120 líneas |
|
|
126
|
+
| `page` | Página completa | `@compose` | — | 200 líneas |
|
|
127
|
+
| `service` | Servicio / API | `@contract` | `@props`, `@state` | 150 líneas |
|
|
128
|
+
| `store` | Estado global | `@deps(zustand)` | — | 100 líneas |
|
|
129
|
+
| `util` | Función utilitaria | — | `@state` | 100 líneas |
|
|
130
|
+
| `type` | Interfaz / tipo | — | `@limit`, `@state` | — |
|
|
131
|
+
| `layout` | Componente de layout | — | — | 150 líneas |
|
|
132
|
+
| `feature` | Módulo completo | `@compose` | — | — |
|
|
133
|
+
|
|
134
|
+
#### @pattern — Patrón de diseño
|
|
135
|
+
|
|
136
|
+
```
|
|
137
|
+
@pattern(nombre)
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
Valores: `compound`, `composition`, `generic`, `render-prop`, `provider`, `singleton`
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
### Tags de contrato
|
|
145
|
+
|
|
146
|
+
#### @contract — Interfaz de función (hooks / services)
|
|
147
|
+
|
|
148
|
+
```
|
|
149
|
+
@contract(in: tipos -> out: tipo @error: tipo)
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
```
|
|
153
|
+
@contract(in: email, password -> out: User @error: AuthError)
|
|
154
|
+
@contract(in: ProductDTO -> out: Product @error: ValidationError)
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
#### @props — Props de componente
|
|
158
|
+
|
|
159
|
+
```
|
|
160
|
+
@props({ "nombre": "tipo", "nombre2?": "tipo", "nombre3": "tipo" })
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
> **Importante:** `@props` acepta dos formatos:
|
|
164
|
+
> ```typescript
|
|
165
|
+
> // Formato JSON (estricto):
|
|
166
|
+
> ✅ @props({ "name": "string", "age?": "number", "label": "string" })
|
|
167
|
+
>
|
|
168
|
+
> // Formato TypeScript (recomendado, más legible):
|
|
169
|
+
> ✅ @props({ name: string, age?: number, label: string })
|
|
170
|
+
>
|
|
171
|
+
> // ❌ Mezclar ambos no funciona:
|
|
172
|
+
> ❌ @props({ "name": string })
|
|
173
|
+
> ```
|
|
174
|
+
|
|
175
|
+
```
|
|
176
|
+
@props({ "name": "string", "age?": "number", "label": "string" })
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
#### @state — Estados visuales
|
|
180
|
+
|
|
181
|
+
```
|
|
182
|
+
@state(loading, empty, error, success, idle, submitting)
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
### Tags de restricción
|
|
188
|
+
|
|
189
|
+
#### @limit — Límites del archivo
|
|
190
|
+
|
|
191
|
+
```
|
|
192
|
+
@limit(lines: 120, functions: 3, params: 2, complexity: 5, nesting: 3)
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
#### @forbidden — Prohibiciones explícitas
|
|
196
|
+
|
|
197
|
+
```
|
|
198
|
+
@forbidden(any, css-modules, class-components)
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
---
|
|
202
|
+
|
|
203
|
+
### Tags de composición
|
|
204
|
+
|
|
205
|
+
#### @compose — Dependencias internas
|
|
206
|
+
|
|
207
|
+
```
|
|
208
|
+
@compose(Header, DataTable, Sidebar)
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
Requerido en `@kind(page)`.
|
|
212
|
+
|
|
213
|
+
#### @deps — Dependencias externas
|
|
214
|
+
|
|
215
|
+
```
|
|
216
|
+
@deps(@external: [supabase, zod], @internal: [utils], @forbidden: [axios])
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
| Sub-tag | Descripción |
|
|
220
|
+
|---|---|
|
|
221
|
+
| `@external` | Librerías npm/pip/cargo |
|
|
222
|
+
| `@internal` | Módulos del mismo proyecto |
|
|
223
|
+
| `@forbidden` | Librerías prohibidas |
|
|
224
|
+
| `@peer` | Peer dependencies |
|
|
225
|
+
|
|
226
|
+
---
|
|
227
|
+
|
|
228
|
+
### Tags de plataforma
|
|
229
|
+
|
|
230
|
+
#### @platform — Target de ejecución
|
|
231
|
+
|
|
232
|
+
```
|
|
233
|
+
@platform(web, mobile, desktop)
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
Compatibilidad:
|
|
237
|
+
|
|
238
|
+
| Plataforma | @capacitor/* | @tauri-apps/* |
|
|
239
|
+
|---|---|---|
|
|
240
|
+
| `web` | ❌ Prohibido | ❌ Prohibido |
|
|
241
|
+
| `mobile` | ✅ Permitido | ❌ Prohibido |
|
|
242
|
+
| `desktop` | ❌ Prohibido | ✅ Permitido |
|
|
243
|
+
|
|
244
|
+
---
|
|
245
|
+
|
|
246
|
+
### Tags de alcance
|
|
247
|
+
|
|
248
|
+
#### @scope — Impacto del módulo
|
|
249
|
+
|
|
250
|
+
```
|
|
251
|
+
@scope(module: auth, affects: [login, register], breaking: false)
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
---
|
|
255
|
+
|
|
256
|
+
### Tags de testing
|
|
257
|
+
|
|
258
|
+
#### @test — Requisitos de testing
|
|
259
|
+
|
|
260
|
+
```
|
|
261
|
+
@test(@unit, @integration, @mock: [servicio], @coverage: 80)
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
---
|
|
265
|
+
|
|
266
|
+
### Tags de metadata
|
|
267
|
+
|
|
268
|
+
#### @meta — Metadatos del archivo
|
|
269
|
+
|
|
270
|
+
```
|
|
271
|
+
@meta(@version: "1.0.0", @author: "dev", @tags: [auth, supabase])
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
---
|
|
275
|
+
|
|
276
|
+
### Ejemplos completos
|
|
277
|
+
|
|
278
|
+
```typescript
|
|
279
|
+
// @use(kind, contract, limit, deps, platform, scope, meta)
|
|
280
|
+
// @kind(hook)
|
|
281
|
+
// @limit(lines: 75, params: 1)
|
|
282
|
+
// @contract(in: email, password -> out: user, token @error: AuthError)
|
|
283
|
+
// @deps(@external: [supabase], @forbidden: [axios])
|
|
284
|
+
// @platform(web)
|
|
285
|
+
// @scope(module: auth, affects: [login, register, session])
|
|
286
|
+
// @meta(@version: "1.0.0", @tags: [auth, supabase])
|
|
287
|
+
export function useAuth() { ... }
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
```typescript
|
|
291
|
+
// @use(kind, props, state, limit, pattern)
|
|
292
|
+
// @kind(component)
|
|
293
|
+
// @props({ "variant": "string", "size": "string", "children": "ReactNode", "disabled?": "boolean" })
|
|
294
|
+
// @state(idle, disabled, loading)
|
|
295
|
+
// @limit(lines: 90, functions: 2)
|
|
296
|
+
// @pattern(composition)
|
|
297
|
+
export function Button(props: ButtonProps) { ... }
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
> 📖 **Especificación completa:** `docs/SYNTAX.md`
|
|
301
|
+
|
|
302
|
+
---
|
|
303
|
+
|
|
304
|
+
## Comandos CLI
|
|
305
|
+
|
|
306
|
+
| Comando | Descripción |
|
|
307
|
+
|---|---|
|
|
308
|
+
| `openPrompt-Lang init --name miapp` | Crea proyecto desde 0 con scaffolding completo + scripts descriptivos |
|
|
309
|
+
| `openPrompt-Lang init --existing` | Configura proyecto existente (solo archivos de config) |
|
|
310
|
+
| `openPrompt-Lang context --output contexto.md` | Extrae todo el código + anotaciones para dar contexto a la IA |
|
|
311
|
+
| `openPrompt-Lang validate` | Valida anotaciones y ejecuta pipeline de verificación |
|
|
312
|
+
| `openPrompt-Lang figma` | Genera prompt para diseño Figma |
|
|
313
|
+
| `openPrompt-Lang suggest "descripción"` | IA sugiere stack y estructura según descripción |
|
|
314
|
+
| `openPrompt-Lang component init` | Inicializa biblioteca de componentes reutilizables |
|
|
315
|
+
| `openPrompt-Lang component list` | Lista componentes disponibles (proyecto + biblioteca) |
|
|
316
|
+
| `openPrompt-Lang component add <nombre>` | Agrega componente de la biblioteca al proyecto |
|
|
317
|
+
| `openPrompt-Lang component manifest` | Muestra el manifiesto de la biblioteca |
|
|
318
|
+
|
|
319
|
+
> 📖 **Comandos y opciones detallados:** `docs/COMMANDS.md`
|
|
320
|
+
|
|
321
|
+
---
|
|
322
|
+
|
|
323
|
+
## Tutorial: Empezar desde 0
|
|
324
|
+
|
|
325
|
+
### Paso 1: Inicializar el proyecto
|
|
326
|
+
|
|
327
|
+
```bash
|
|
328
|
+
openPrompt-Lang init --name mi-app-web
|
|
329
|
+
cd mi-app-web
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
Esto crea:
|
|
333
|
+
```
|
|
334
|
+
mi-app-web/
|
|
335
|
+
├── src/ # Scaffolding: components/, hooks/, features/, services/, store/, ...
|
|
336
|
+
├── docs/ # BACKLOG/, COMMITS/, LOGS/, PROMPTS/
|
|
337
|
+
├── scripts/
|
|
338
|
+
│ └── validate.sh # Pipeline de validación pre-commit
|
|
339
|
+
├── package.json # Scripts descriptivos (dev:start, test:unit, validate:all...)
|
|
340
|
+
├── prompt-lang.json # Configuración del framework
|
|
341
|
+
├── AGENTS.md # Contexto para la IA
|
|
342
|
+
└── .gitignore
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
### Paso 2: Inicializar Vite + React + TS
|
|
346
|
+
|
|
347
|
+
```bash
|
|
348
|
+
npm create vite@latest . -- --template react-ts
|
|
349
|
+
npm install
|
|
350
|
+
npm install tailwindcss @tailwindcss/vite
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
Luego copia los scripts descriptivos del `package.json` generado o usa `--existing` para mergearlos.
|
|
354
|
+
|
|
355
|
+
### Paso 3: Anotar tu primer hook
|
|
356
|
+
|
|
357
|
+
```typescript
|
|
358
|
+
// src/hooks/useAuth.ts
|
|
359
|
+
// @use(kind, contract, limit, deps)
|
|
360
|
+
// @kind(hook)
|
|
361
|
+
// @limit(lines: 60, params: 1)
|
|
362
|
+
// @contract(in: email, password -> out: User | null @error: string)
|
|
363
|
+
// @deps(@external: [supabase])
|
|
364
|
+
export function useAuth() {
|
|
365
|
+
// ...
|
|
366
|
+
}
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
### Paso 4: Validar
|
|
370
|
+
|
|
371
|
+
```bash
|
|
372
|
+
openPrompt-Lang validate
|
|
373
|
+
npm run type:check
|
|
374
|
+
npm run test:unit
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
### Paso 5: Extraer contexto para la IA
|
|
378
|
+
|
|
379
|
+
```bash
|
|
380
|
+
openPrompt-Lang context --output contexto.md
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
Pasa ese `contexto.md` a la IA junto con `docs/referencia-metodologia/` para que entienda el proyecto completo.
|
|
384
|
+
|
|
385
|
+
---
|
|
386
|
+
|
|
387
|
+
## Tutorial: Refactorizar proyecto existente
|
|
388
|
+
|
|
389
|
+
### Paso 1: Configurar
|
|
390
|
+
|
|
391
|
+
```bash
|
|
392
|
+
cd mi-proyecto-ya-iniciado
|
|
393
|
+
openPrompt-Lang init --existing
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
Esto detecta automáticamente el stack y crea solo:
|
|
397
|
+
- `prompt-lang.json` (config con stack detectado)
|
|
398
|
+
- `AGENTS.md` (contexto para IA con tecnologías reales)
|
|
399
|
+
|
|
400
|
+
Te preguntará:
|
|
401
|
+
- ¿Agregar scripts descriptivos al `package.json`? (merge sin romper)
|
|
402
|
+
- ¿Crear `docs/BACKLOG`, `COMMITS`, `LOGS`?
|
|
403
|
+
|
|
404
|
+
### Paso 2: Anotar los archivos a refactorizar
|
|
405
|
+
|
|
406
|
+
Empieza por los archivos que vas a tocar:
|
|
407
|
+
|
|
408
|
+
```typescript
|
|
409
|
+
// @use(kind, contract, limit)
|
|
410
|
+
// @kind(service)
|
|
411
|
+
// @limit(lines: 100)
|
|
412
|
+
// @contract(in: UserDTO -> out: User @error: ApiError)
|
|
413
|
+
export async function createUser(data: UserDTO): Promise<User> { ... }
|
|
414
|
+
```
|
|
415
|
+
|
|
416
|
+
### Paso 3: Validar solo lo que cambiaste
|
|
417
|
+
|
|
418
|
+
```bash
|
|
419
|
+
openPrompt-Lang validate src/services/userService.ts
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
### Paso 4: Generar contexto para la IA
|
|
423
|
+
|
|
424
|
+
```bash
|
|
425
|
+
openPrompt-Lang context --output contexto.md --scope auth
|
|
426
|
+
```
|
|
427
|
+
|
|
428
|
+
Filtra por módulo (`@scope`) para no saturar a la IA con código no relevante.
|
|
429
|
+
|
|
430
|
+
### Paso 5: Refactorizar
|
|
431
|
+
|
|
432
|
+
Pasa el `contexto.md` a la IA con instrucciones específicas (qué refactorizar, qué patrones usar, límites).
|
|
433
|
+
|
|
434
|
+
---
|
|
435
|
+
|
|
436
|
+
## Configuración (prompt-lang.json)
|
|
437
|
+
|
|
438
|
+
```json
|
|
439
|
+
{
|
|
440
|
+
"name": "mi-app",
|
|
441
|
+
"version": "0.1.0",
|
|
442
|
+
"stack": {
|
|
443
|
+
"base": ["react", "typescript", "vite", "tailwind"],
|
|
444
|
+
"extensions": ["supabase", "ionic"]
|
|
445
|
+
},
|
|
446
|
+
"profile": "senior",
|
|
447
|
+
"annotations": { "enabled": true, "strict": false },
|
|
448
|
+
"docs": { "commits": true, "logs": true, "backlog": true },
|
|
449
|
+
"extractor": {
|
|
450
|
+
"ignore": [".env", "*.local", "dist", "node_modules"],
|
|
451
|
+
"output": "contexto.md"
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
```
|
|
455
|
+
|
|
456
|
+
| Campo | Descripción |
|
|
457
|
+
|---|---|
|
|
458
|
+
| `stack.base` | Tecnologías base del proyecto |
|
|
459
|
+
| `stack.extensions` | Extensiones opcionales (supabase, ionic, tauri) |
|
|
460
|
+
| `profile` | Perfil del dev: senior, mid, junior |
|
|
461
|
+
| `annotations.strict` | Si `true`, falla en warnings (no solo errores) |
|
|
462
|
+
| `components.source` | Ruta de componentes del proyecto (`src/components/ui`) |
|
|
463
|
+
| `components.library` | Ruta de la biblioteca de componentes reutilizables |
|
|
464
|
+
| `extractor.ignore` | Patrones a ignorar al extraer contexto |
|
|
465
|
+
|
|
466
|
+
---
|
|
467
|
+
|
|
468
|
+
## Validación cruzada
|
|
469
|
+
|
|
470
|
+
El CLI valida relaciones entre tags automáticamente:
|
|
471
|
+
|
|
472
|
+
| @kind | @contract | @props | @state | @compose | @limit default |
|
|
473
|
+
|---|---|---|---|---|---|
|
|
474
|
+
| `hook` | REQUERIDO | PROHIBIDO | — | — | 80 |
|
|
475
|
+
| `component` | PROHIBIDO | RECOMENDADO | RECOMENDADO | — | 120 |
|
|
476
|
+
| `page` | — | — | — | REQUERIDO | 200 |
|
|
477
|
+
| `service` | REQUERIDO | PROHIBIDO | PROHIBIDO | — | 150 |
|
|
478
|
+
| `store` | — | — | — | — | 100 |
|
|
479
|
+
| `type` | — | — | PROHIBIDO | — | N/A |
|
|
480
|
+
|
|
481
|
+
Además:
|
|
482
|
+
- `@platform(web)` + `@deps(@capacitor/*)` → **ERROR**
|
|
483
|
+
- `@platform(mobile)` + `@deps(@tauri-apps/*)` → **ERROR**
|
|
484
|
+
- `@scope(breaking: true)` → commit debe ser breaking change `!`
|
|
485
|
+
- `@forbidden(any)` → warning si se detecta `any` en el código
|
|
486
|
+
- `@state(error)` sin `@contract(@error)` → warning (solo en `hook`/`service`, no en `component`/`page`)
|
|
487
|
+
|
|
488
|
+
---
|
|
489
|
+
|
|
490
|
+
## Scripts descriptivos
|
|
491
|
+
|
|
492
|
+
Generados automáticamente por `npm init` (o mergeables con `--existing`).
|
|
493
|
+
|
|
494
|
+
| Script | Comando real | Propósito |
|
|
495
|
+
|---|---|---|
|
|
496
|
+
| `npm run dev:start` | `vite` | Servidor de desarrollo |
|
|
497
|
+
| `npm run dev:preview` | `vite preview` | Vista previa del build |
|
|
498
|
+
| `npm run build:prod` | `vite build` | Build producción |
|
|
499
|
+
| `npm run build:analyze` | `vite build --analyze` | Build con análisis de bundle |
|
|
500
|
+
| `npm run lint:check` | `eslint src --ext .ts,.tsx` | Verificar lint |
|
|
501
|
+
| `npm run lint:fix` | `eslint src --ext .ts,.tsx --fix` | Auto-corregir lint |
|
|
502
|
+
| `npm run type:check` | `tsc --noEmit` | Verificar tipos TypeScript |
|
|
503
|
+
| `npm run quality:doctor` | `npx react-doctor check ./src` | Auditoría React |
|
|
504
|
+
| `npm run test:unit` | `vitest run` | Tests unitarios |
|
|
505
|
+
| `npm run test:watch` | `vitest` | Tests en modo watch |
|
|
506
|
+
| `npm run test:coverage` | `vitest run --coverage` | Tests con cobertura |
|
|
507
|
+
| `npm run validate:all` | lint + typecheck + doctor + test | Pipeline completo |
|
|
508
|
+
|
|
509
|
+
---
|
|
510
|
+
|
|
511
|
+
## Estructura del proyecto
|
|
512
|
+
|
|
513
|
+
```
|
|
514
|
+
openPrompt-Lang/
|
|
515
|
+
├── bin/cli.js ← Entry point del CLI
|
|
516
|
+
├── src/
|
|
517
|
+
│ ├── commands/
|
|
518
|
+
│ │ ├── init.js ← init + --existing
|
|
519
|
+
│ │ ├── context.js ← Extractor de contexto
|
|
520
|
+
│ │ ├── validate.js ← Validador de anotaciones
|
|
521
|
+
│ │ ├── figma.js ← Generador de prompts Figma
|
|
522
|
+
│ │ └── suggest.js ← Sugerencia de stack vía IA
|
|
523
|
+
│ └── utils/
|
|
524
|
+
│ ├── annotations.js ← Parser + validador de anotaciones
|
|
525
|
+
│ ├── config.js ← Loader de prompt-lang.json + detectStack
|
|
526
|
+
│ └── ai.js ← Módulo de IA (OpenAI / opencode)
|
|
527
|
+
├── tests/
|
|
528
|
+
│ ├── annotations.test.js ← ~65 tests de parser y validador
|
|
529
|
+
│ └── config.test.js ← Tests de configuración
|
|
530
|
+
├── docs/
|
|
531
|
+
│ ├── COMMANDS.md ← Documentación completa de comandos
|
|
532
|
+
│ ├── SYNTAX.md ← Especificación del lenguaje PromptLang
|
|
533
|
+
│ ├── DEPENDENCIES.md ← Dependencias y versiones
|
|
534
|
+
│ ├── FRAMEWORK.md ← Framework spec (acceso rápido)
|
|
535
|
+
│ └── referencia-metodologia/ ← Metodología completa (17 archivos)
|
|
536
|
+
│ ├── Indice General.md
|
|
537
|
+
│ ├── Fase - 1.md a Fase - 8.md
|
|
538
|
+
│ ├── docs/PROMPTS/ ← Biblioteca de prompts reutilizables
|
|
539
|
+
│ └── ...
|
|
540
|
+
├── vscode-extension/ ← Extensión VS Code (highlighting + snippets)
|
|
541
|
+
├── schemas/
|
|
542
|
+
│ └── prompt-lang.json ← JSON Schema para la configuración
|
|
543
|
+
├── package.json
|
|
544
|
+
└── .gitignore
|
|
545
|
+
```
|
|
546
|
+
|
|
547
|
+
---
|
|
548
|
+
|
|
549
|
+
## Documentación
|
|
550
|
+
|
|
551
|
+
| Archivo | Contenido |
|
|
552
|
+
|---|---|
|
|
553
|
+
| `docs/SYNTAX.md` | Especificación completa del lenguaje de anotaciones PromptLang |
|
|
554
|
+
| `docs/COMMANDS.md` | Todos los comandos, opciones y configuración del CLI |
|
|
555
|
+
| `docs/DEPENDENCIES.md` | Dependencias del proyecto, versiones y notas técnicas |
|
|
556
|
+
| `docs/FRAMEWORK.md` | Framework spec — catálogo de patrones y metodología |
|
|
557
|
+
| `docs/VERSIONING.md` | Convención de versionado SemVer (MAJOR/MINOR/PATCH, pre-release) |
|
|
558
|
+
| `docs/referencia-metodologia/` | Metodología completa: fases, patrones, templates de prompts |
|
|
559
|
+
| `docs/referencia-metodologia/docs/CONVENCIONES_DB.md` | 18 prácticas de base de datos (RLS, índices, batch, etc.) |
|
|
560
|
+
| `docs/referencia-metodologia/docs/CONVENCIONES_DOCUMENTACION.md` | Estándar de documentación (tablas DB, Mermaid, contratos RPC) |
|
|
561
|
+
| `docs/referencia-metodologia/docs/PROMPTS/` | Biblioteca de prompts reutilizables (17 plantillas + 3 stacks) |
|
|
562
|
+
| `vscode-extension/` | Extensión VS Code: syntax highlighting y snippets para anotaciones |
|
|
563
|
+
| `schemas/prompt-lang.json` | JSON Schema para validar `prompt-lang.json` |
|
|
564
|
+
|
|
565
|
+
---
|
|
566
|
+
|
|
567
|
+
## Versionado (SemVer)
|
|
568
|
+
|
|
569
|
+
openPrompt-Lang sigue [SemVer estricto](docs/VERSIONING.md):
|
|
570
|
+
|
|
571
|
+
| Bump | Cuándo | Ejemplo |
|
|
572
|
+
|---|---|---|
|
|
573
|
+
| **MAJOR** | Breaking changes en API, CLI o anotaciones | `1.0.0` → `2.0.0` |
|
|
574
|
+
| **MINOR** | Nuevas funcionalidades, comandos, tags | `0.2.0` → `0.3.0` |
|
|
575
|
+
| **PATCH** | Fixes, docs, refactors sin cambio de API | `0.2.0` → `0.2.1` |
|
|
576
|
+
|
|
577
|
+
Pre-release: `1.0.0-alpha.1`, `1.0.0-beta.1`, `1.0.0-rc.1`
|
|
578
|
+
|
|
579
|
+
> 📖 **Especificación completa:** `docs/VERSIONING.md`
|
|
580
|
+
|
|
581
|
+
---
|
|
582
|
+
|
|
583
|
+
## Sistema de componentes
|
|
584
|
+
|
|
585
|
+
openPrompt-Lang incluye un sistema de **biblioteca de componentes reutilizables**:
|
|
586
|
+
|
|
587
|
+
- **`component init`** — Crea una biblioteca con ejemplos (Button, ConfirmModal, Input)
|
|
588
|
+
- **`component list`** — Muestra componentes del proyecto y de la biblioteca
|
|
589
|
+
- **`component add <nombre>`** — Copia un componente de la biblioteca al proyecto
|
|
590
|
+
- Los componentes incluyen UX patterns: `ConfirmModal` para acciones destructivas, `Button` con variante `danger`, etc.
|
|
591
|
+
- Configurable en `prompt-lang.json` → `components.library`
|
|
592
|
+
|
|
593
|
+
---
|
|
594
|
+
|
|
595
|
+
## VS Code Extension
|
|
596
|
+
|
|
597
|
+
openPrompt-Lang incluye una extensión para VS Code en `vscode-extension/` con resaltado de sintaxis y snippets.
|
|
598
|
+
|
|
599
|
+
### Instalación
|
|
600
|
+
|
|
601
|
+
**Opción 1 — Desde el paquete npm (recomendada):**
|
|
602
|
+
|
|
603
|
+
```bash
|
|
604
|
+
# La extensión está dentro del paquete npm instalado
|
|
605
|
+
code --install-extension ./node_modules/openprompt-lang/vscode-extension/
|
|
606
|
+
```
|
|
607
|
+
|
|
608
|
+
**Opción 2 — Desde el repositorio local:**
|
|
609
|
+
|
|
610
|
+
```bash
|
|
611
|
+
cd ruta/a/openPrompt-Lang/vscode-extension/
|
|
612
|
+
code --install-extension .
|
|
613
|
+
```
|
|
614
|
+
|
|
615
|
+
**Opción 3 — Empaquetar como .vsix:**
|
|
616
|
+
|
|
617
|
+
```bash
|
|
618
|
+
cd ruta/a/openPrompt-Lang/vscode-extension/
|
|
619
|
+
npx @vscode/vsce package
|
|
620
|
+
code --install-extension openprompt-lang-*.vsix
|
|
621
|
+
```
|
|
622
|
+
|
|
623
|
+
### Funcionalidades
|
|
624
|
+
|
|
625
|
+
- **Syntax highlighting**: todos los tags (`@kind`, `@props`, `@contract`, etc.) se resaltan en comentarios de TypeScript/JavaScript
|
|
626
|
+
- **Snippets**: escribe `@kind-` y autocompleta:
|
|
627
|
+
- `@kind-hook` → hook con `@contract`
|
|
628
|
+
- `@kind-component` → componente con `@props`
|
|
629
|
+
- `@kind-service` → servicio con `@contract` + `@platform`
|
|
630
|
+
- `@kind-page` → página con `@compose`
|
|
631
|
+
- `@kind-store` → store Zustand
|
|
632
|
+
- `@use-header` → declaración `@use()`
|
|
633
|
+
- `@props-ts` → props con sintaxis TypeScript
|
|
634
|
+
|
|
635
|
+
### Requisitos
|
|
636
|
+
|
|
637
|
+
- VS Code >= 1.85.0
|
|
638
|
+
- La extensión se activa automáticamente en archivos `.ts` y `.tsx`
|
|
639
|
+
|
|
640
|
+
---
|
|
641
|
+
|
|
642
|
+
## Publicación en npm
|
|
643
|
+
|
|
644
|
+
```bash
|
|
645
|
+
# 1. Build (si aplica)
|
|
646
|
+
npm run build
|
|
647
|
+
|
|
648
|
+
# 2. Test
|
|
649
|
+
npm test
|
|
650
|
+
|
|
651
|
+
# 3. Versionar (e.g. 0.3.0 → 0.4.0 para nuevas features)
|
|
652
|
+
npm version minor -m "feat: %s"
|
|
653
|
+
|
|
654
|
+
# 4. Publicar
|
|
655
|
+
npm publish --access public
|
|
656
|
+
|
|
657
|
+
# 5. Tag de release
|
|
658
|
+
git push --follow-tags
|
|
659
|
+
```
|
|
660
|
+
|
|
661
|
+
> ⚠️ Requiere cuenta npm: `npm login` primero.
|
|
662
|
+
>
|
|
663
|
+
> Pre-release: `npm publish --tag next`
|