claude-agent-framework 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/README.md +128 -0
- package/bin/claude-framework +3 -0
- package/framework/agents/design-lead.md +240 -0
- package/framework/agents/product-owner.md +179 -0
- package/framework/agents/tech-lead.md +226 -0
- package/framework/commands/ayuda.md +127 -0
- package/framework/commands/a/303/261adir.md +98 -0
- package/framework/commands/backup.md +397 -0
- package/framework/commands/cambiar.md +110 -0
- package/framework/commands/cloud.md +457 -0
- package/framework/commands/code.md +142 -0
- package/framework/commands/debug.md +334 -0
- package/framework/commands/deploy.md +383 -0
- package/framework/commands/deshacer.md +120 -0
- package/framework/commands/estado.md +218 -0
- package/framework/commands/explica.md +227 -0
- package/framework/commands/feature.md +120 -0
- package/framework/commands/git.md +427 -0
- package/framework/commands/historial.md +202 -0
- package/framework/commands/learn.md +408 -0
- package/framework/commands/movil.md +245 -0
- package/framework/commands/nuevo.md +118 -0
- package/framework/commands/plan.md +134 -0
- package/framework/commands/prd.md +113 -0
- package/framework/commands/probar.md +148 -0
- package/framework/commands/revisar.md +208 -0
- package/framework/commands/seeds.md +230 -0
- package/framework/commands/seguridad.md +226 -0
- package/framework/commands/tasks.md +157 -0
- package/framework/skills/architecture/algorithms.md +970 -0
- package/framework/skills/architecture/clean-code.md +1080 -0
- package/framework/skills/architecture/design-patterns.md +1984 -0
- package/framework/skills/architecture/functional-programming.md +972 -0
- package/framework/skills/architecture/solid.md +991 -0
- package/framework/skills/cloud/cloud-aws.md +848 -0
- package/framework/skills/cloud/cloud-azure.md +931 -0
- package/framework/skills/cloud/cloud-gcp.md +848 -0
- package/framework/skills/cloud/message-queues.md +1229 -0
- package/framework/skills/core/accessibility.md +401 -0
- package/framework/skills/core/api.md +474 -0
- package/framework/skills/core/authentication.md +306 -0
- package/framework/skills/core/authorization.md +388 -0
- package/framework/skills/core/background-jobs.md +341 -0
- package/framework/skills/core/caching.md +473 -0
- package/framework/skills/core/code-review.md +341 -0
- package/framework/skills/core/controllers.md +290 -0
- package/framework/skills/core/cua.md +285 -0
- package/framework/skills/core/documentation.md +472 -0
- package/framework/skills/core/file-uploads.md +351 -0
- package/framework/skills/core/hotwire-native.md +296 -0
- package/framework/skills/core/hotwire.md +278 -0
- package/framework/skills/core/i18n.md +334 -0
- package/framework/skills/core/imports-exports.md +750 -0
- package/framework/skills/core/infrastructure.md +337 -0
- package/framework/skills/core/models.md +228 -0
- package/framework/skills/core/notifications.md +672 -0
- package/framework/skills/core/payments.md +581 -0
- package/framework/skills/core/performance.md +361 -0
- package/framework/skills/core/rails-scaffold.md +131 -0
- package/framework/skills/core/search.md +518 -0
- package/framework/skills/core/security.md +565 -0
- package/framework/skills/core/seeds.md +307 -0
- package/framework/skills/core/seo.md +542 -0
- package/framework/skills/core/testing.md +393 -0
- package/framework/skills/core/views.md +260 -0
- package/framework/skills/core/websockets.md +564 -0
- package/framework/skills/data/advanced-sql.md +1204 -0
- package/framework/skills/data/nosql.md +1141 -0
- package/framework/skills/devops/containers-advanced.md +1237 -0
- package/framework/skills/devops/debugging.md +834 -0
- package/framework/skills/devops/git-workflow.md +752 -0
- package/framework/skills/devops/networking.md +932 -0
- package/framework/skills/devops/shell-scripting.md +1132 -0
- package/framework/sub-agents/architecture-patterns-agent.md +1450 -0
- package/framework/sub-agents/cloud-agent.md +677 -0
- package/framework/sub-agents/data.md +504 -0
- package/framework/sub-agents/debugging-agent.md +554 -0
- package/framework/sub-agents/devops.md +483 -0
- package/framework/sub-agents/docs.md +176 -0
- package/framework/sub-agents/frontend-dev.md +349 -0
- package/framework/sub-agents/git-workflow-agent.md +697 -0
- package/framework/sub-agents/integrations.md +630 -0
- package/framework/sub-agents/native-dev.md +434 -0
- package/framework/sub-agents/qa.md +138 -0
- package/framework/sub-agents/rails-dev.md +375 -0
- package/framework/sub-agents/security.md +526 -0
- package/framework/sub-agents/ui.md +437 -0
- package/framework/sub-agents/ux.md +284 -0
- package/framework/templates/api-spec.md +500 -0
- package/framework/templates/component-spec.md +248 -0
- package/framework/templates/feature.json +13 -0
- package/framework/templates/model-spec.md +318 -0
- package/framework/templates/prd-template.md +80 -0
- package/framework/templates/task-plan.md +122 -0
- package/framework/templates/task-user-story.md +52 -0
- package/framework/templates/technical-spec.md +260 -0
- package/framework/templates/user-story.md +95 -0
- package/package.json +42 -0
- package/project-templates/CLAUDE.md +42 -0
- package/project-templates/contexts/architecture.md +25 -0
- package/project-templates/contexts/conventions.md +46 -0
- package/project-templates/contexts/design-system.md +47 -0
- package/project-templates/contexts/requirements.md +38 -0
- package/project-templates/contexts/stack.md +30 -0
- package/project-templates/history/active/models.md +11 -0
- package/project-templates/history/changelog.md +15 -0
- package/project-templates/workspace/.gitkeep +0 -0
- package/src/cli.js +52 -0
- package/src/init.js +104 -0
- package/src/status.js +75 -0
- package/src/update.js +88 -0
|
@@ -0,0 +1,408 @@
|
|
|
1
|
+
# Comando: /learn
|
|
2
|
+
|
|
3
|
+
Sugiere mejoras al código actual y proporciona recursos de aprendizaje.
|
|
4
|
+
|
|
5
|
+
## Uso
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
/learn [área]
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Parámetros
|
|
12
|
+
|
|
13
|
+
- Sin argumentos: muestra áreas disponibles
|
|
14
|
+
- `architecture`: patrones arquitectónicos y organización de código
|
|
15
|
+
- `testing`: mejoras en estrategia de testing
|
|
16
|
+
- `security`: prácticas de seguridad
|
|
17
|
+
- `performance`: optimización de rendimiento
|
|
18
|
+
- `patterns`: patrones de diseño aplicables
|
|
19
|
+
|
|
20
|
+
## Flujo de trabajo
|
|
21
|
+
|
|
22
|
+
### Paso 1: Sin argumentos - Mostrar áreas disponibles
|
|
23
|
+
|
|
24
|
+
```markdown
|
|
25
|
+
# Áreas de Aprendizaje
|
|
26
|
+
|
|
27
|
+
¿Sobre qué área te gustaría aprender y mejorar?
|
|
28
|
+
|
|
29
|
+
1. **architecture** - Patrones arquitectónicos, organización de código, SOLID
|
|
30
|
+
2. **testing** - Estrategias de testing, TDD, cobertura
|
|
31
|
+
3. **security** - Seguridad web, OWASP, protección de datos
|
|
32
|
+
4. **performance** - Optimización, caching, queries eficientes
|
|
33
|
+
5. **patterns** - Patrones de diseño, refactoring
|
|
34
|
+
|
|
35
|
+
Escribe `/learn [área]` para comenzar.
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Paso 2: Analizar código actual
|
|
39
|
+
|
|
40
|
+
Para cada área, analizar el código del proyecto buscando:
|
|
41
|
+
|
|
42
|
+
1. **Oportunidades de mejora**
|
|
43
|
+
- Código que podría beneficiarse de patrones
|
|
44
|
+
- Áreas donde se repite lógica
|
|
45
|
+
- Complejidad innecesaria
|
|
46
|
+
|
|
47
|
+
2. **Buenas prácticas existentes**
|
|
48
|
+
- Reconocer lo que ya está bien hecho
|
|
49
|
+
- Reforzar patrones positivos
|
|
50
|
+
|
|
51
|
+
3. **Prioridad de mejoras**
|
|
52
|
+
- Alto impacto, bajo esfuerzo primero
|
|
53
|
+
- Mejoras que desbloquean otras
|
|
54
|
+
|
|
55
|
+
### Paso 3: Generar reporte según área
|
|
56
|
+
|
|
57
|
+
## `/learn architecture`
|
|
58
|
+
|
|
59
|
+
### Análisis
|
|
60
|
+
|
|
61
|
+
```markdown
|
|
62
|
+
## Análisis de Arquitectura
|
|
63
|
+
|
|
64
|
+
### Estado Actual
|
|
65
|
+
- Estructura de directorios: [evaluación]
|
|
66
|
+
- Separación de responsabilidades: [evaluación]
|
|
67
|
+
- Dependencias entre módulos: [evaluación]
|
|
68
|
+
|
|
69
|
+
### Oportunidades de Mejora
|
|
70
|
+
|
|
71
|
+
#### 1. [Mejora identificada]
|
|
72
|
+
**Prioridad**: Alta/Media/Baja
|
|
73
|
+
**Esfuerzo**: Alto/Medio/Bajo
|
|
74
|
+
|
|
75
|
+
**Situación actual:**
|
|
76
|
+
```ruby
|
|
77
|
+
# Código actual
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
**Mejora sugerida:**
|
|
81
|
+
```ruby
|
|
82
|
+
# Código mejorado
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
**Por qué es mejor:**
|
|
86
|
+
- [Razón 1]
|
|
87
|
+
- [Razón 2]
|
|
88
|
+
|
|
89
|
+
### Recursos para Profundizar
|
|
90
|
+
|
|
91
|
+
📚 **Libros:**
|
|
92
|
+
- Clean Architecture (Robert C. Martin)
|
|
93
|
+
- Patterns of Enterprise Application Architecture (Martin Fowler)
|
|
94
|
+
|
|
95
|
+
🎓 **Cursos:**
|
|
96
|
+
- [Curso recomendado 1]
|
|
97
|
+
- [Curso recomendado 2]
|
|
98
|
+
|
|
99
|
+
📝 **Artículos:**
|
|
100
|
+
- [Artículo relevante 1]
|
|
101
|
+
- [Artículo relevante 2]
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## `/learn testing`
|
|
105
|
+
|
|
106
|
+
### Análisis
|
|
107
|
+
|
|
108
|
+
```markdown
|
|
109
|
+
## Análisis de Testing
|
|
110
|
+
|
|
111
|
+
### Estado Actual
|
|
112
|
+
- Cobertura estimada: X%
|
|
113
|
+
- Tipos de tests: [unit/integration/system]
|
|
114
|
+
- Framework: RSpec
|
|
115
|
+
|
|
116
|
+
### Oportunidades de Mejora
|
|
117
|
+
|
|
118
|
+
#### 1. Áreas sin tests
|
|
119
|
+
- [Modelo/Controlador X] - Sin tests
|
|
120
|
+
- [Feature Y] - Tests incompletos
|
|
121
|
+
|
|
122
|
+
#### 2. Tests que podrían mejorar
|
|
123
|
+
**Antes:**
|
|
124
|
+
```ruby
|
|
125
|
+
it "works" do
|
|
126
|
+
expect(user.save).to be true
|
|
127
|
+
end
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
**Después:**
|
|
131
|
+
```ruby
|
|
132
|
+
describe "#save" do
|
|
133
|
+
context "with valid attributes" do
|
|
134
|
+
it "persists the user" do
|
|
135
|
+
user = build(:user)
|
|
136
|
+
expect { user.save }.to change(User, :count).by(1)
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
context "with invalid email" do
|
|
141
|
+
it "returns false and adds error" do
|
|
142
|
+
user = build(:user, email: "invalid")
|
|
143
|
+
expect(user.save).to be false
|
|
144
|
+
expect(user.errors[:email]).to include("is invalid")
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
end
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### Recursos para Profundizar
|
|
151
|
+
|
|
152
|
+
📚 **Libros:**
|
|
153
|
+
- Effective Testing with RSpec 3
|
|
154
|
+
- Growing Object-Oriented Software, Guided by Tests
|
|
155
|
+
- The RSpec Book
|
|
156
|
+
|
|
157
|
+
🎓 **Cursos:**
|
|
158
|
+
- Test-Driven Development en Ruby (Upcase)
|
|
159
|
+
- Testing Rails Applications (GoRails)
|
|
160
|
+
|
|
161
|
+
📝 **Artículos:**
|
|
162
|
+
- Better Specs (betterspecs.org)
|
|
163
|
+
- Testing best practices de Thoughtbot
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## `/learn security`
|
|
167
|
+
|
|
168
|
+
### Análisis
|
|
169
|
+
|
|
170
|
+
```markdown
|
|
171
|
+
## Análisis de Seguridad
|
|
172
|
+
|
|
173
|
+
### Estado Actual
|
|
174
|
+
- Autenticación: [implementación]
|
|
175
|
+
- Autorización: [implementación]
|
|
176
|
+
- Protección CSRF: [estado]
|
|
177
|
+
- Sanitización de entrada: [estado]
|
|
178
|
+
|
|
179
|
+
### Oportunidades de Mejora
|
|
180
|
+
|
|
181
|
+
#### 1. [Vulnerabilidad potencial]
|
|
182
|
+
**Riesgo**: Alto/Medio/Bajo
|
|
183
|
+
**Ubicación**: [archivo]
|
|
184
|
+
|
|
185
|
+
**Código actual:**
|
|
186
|
+
```ruby
|
|
187
|
+
# Código vulnerable
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
**Código seguro:**
|
|
191
|
+
```ruby
|
|
192
|
+
# Código corregido
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### OWASP Top 10 - Checklist
|
|
196
|
+
|
|
197
|
+
- [ ] Injection
|
|
198
|
+
- [ ] Broken Authentication
|
|
199
|
+
- [ ] Sensitive Data Exposure
|
|
200
|
+
- [ ] XML External Entities
|
|
201
|
+
- [ ] Broken Access Control
|
|
202
|
+
- [ ] Security Misconfiguration
|
|
203
|
+
- [ ] Cross-Site Scripting (XSS)
|
|
204
|
+
- [ ] Insecure Deserialization
|
|
205
|
+
- [ ] Using Components with Known Vulnerabilities
|
|
206
|
+
- [ ] Insufficient Logging & Monitoring
|
|
207
|
+
|
|
208
|
+
### Recursos para Profundizar
|
|
209
|
+
|
|
210
|
+
📚 **Libros:**
|
|
211
|
+
- Web Application Security (Andrew Hoffman)
|
|
212
|
+
- The Web Application Hacker's Handbook
|
|
213
|
+
|
|
214
|
+
🎓 **Cursos:**
|
|
215
|
+
- OWASP Web Security Testing Guide
|
|
216
|
+
- Secure Rails Development
|
|
217
|
+
|
|
218
|
+
📝 **Artículos:**
|
|
219
|
+
- Rails Security Guide (oficial)
|
|
220
|
+
- Brakeman documentation
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
## `/learn performance`
|
|
224
|
+
|
|
225
|
+
### Análisis
|
|
226
|
+
|
|
227
|
+
```markdown
|
|
228
|
+
## Análisis de Rendimiento
|
|
229
|
+
|
|
230
|
+
### Estado Actual
|
|
231
|
+
- Tiempo de respuesta promedio: [estimación]
|
|
232
|
+
- Queries por página: [estimación]
|
|
233
|
+
- Uso de caching: [estado]
|
|
234
|
+
|
|
235
|
+
### Oportunidades de Mejora
|
|
236
|
+
|
|
237
|
+
#### 1. N+1 Queries
|
|
238
|
+
**Ubicación**: [archivo:línea]
|
|
239
|
+
**Impacto**: Alto
|
|
240
|
+
|
|
241
|
+
**Antes:**
|
|
242
|
+
```ruby
|
|
243
|
+
@articles = Article.all
|
|
244
|
+
# En la vista:
|
|
245
|
+
<% @articles.each do |article| %>
|
|
246
|
+
<%= article.user.name %>
|
|
247
|
+
<% end %>
|
|
248
|
+
# Genera: 1 query para articles + N queries para users
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
**Después:**
|
|
252
|
+
```ruby
|
|
253
|
+
@articles = Article.includes(:user)
|
|
254
|
+
# Genera: 2 queries total
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
#### 2. Oportunidades de Caching
|
|
258
|
+
- Fragment caching para [componente]
|
|
259
|
+
- Russian doll caching para [lista]
|
|
260
|
+
|
|
261
|
+
#### 3. Índices Faltantes
|
|
262
|
+
```ruby
|
|
263
|
+
# Migration sugerida
|
|
264
|
+
add_index :articles, :user_id
|
|
265
|
+
add_index :articles, [:published, :created_at]
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
### Recursos para Profundizar
|
|
269
|
+
|
|
270
|
+
📚 **Libros:**
|
|
271
|
+
- High Performance Ruby (Charles Nutter)
|
|
272
|
+
- Ruby Performance Optimization (Alexander Dymo)
|
|
273
|
+
|
|
274
|
+
🎓 **Cursos:**
|
|
275
|
+
- Scaling Rails Applications
|
|
276
|
+
- Performance Optimization (GoRails)
|
|
277
|
+
|
|
278
|
+
📝 **Artículos:**
|
|
279
|
+
- Rails Performance Guide
|
|
280
|
+
- Bullet gem documentation
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
## `/learn patterns`
|
|
284
|
+
|
|
285
|
+
### Análisis
|
|
286
|
+
|
|
287
|
+
```markdown
|
|
288
|
+
## Análisis de Patrones de Diseño
|
|
289
|
+
|
|
290
|
+
### Patrones Aplicables al Proyecto
|
|
291
|
+
|
|
292
|
+
#### 1. Service Objects
|
|
293
|
+
**Cuándo usarlo**: Lógica de negocio compleja en controladores
|
|
294
|
+
|
|
295
|
+
**Antes:**
|
|
296
|
+
```ruby
|
|
297
|
+
class OrdersController < ApplicationController
|
|
298
|
+
def create
|
|
299
|
+
@order = Order.new(order_params)
|
|
300
|
+
@order.calculate_total
|
|
301
|
+
@order.apply_discount(current_user)
|
|
302
|
+
@order.reserve_inventory
|
|
303
|
+
if @order.save
|
|
304
|
+
OrderMailer.confirmation(@order).deliver_later
|
|
305
|
+
redirect_to @order
|
|
306
|
+
end
|
|
307
|
+
end
|
|
308
|
+
end
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
**Después:**
|
|
312
|
+
```ruby
|
|
313
|
+
# app/services/create_order_service.rb
|
|
314
|
+
class CreateOrderService
|
|
315
|
+
def initialize(user:, order_params:)
|
|
316
|
+
@user = user
|
|
317
|
+
@order_params = order_params
|
|
318
|
+
end
|
|
319
|
+
|
|
320
|
+
def call
|
|
321
|
+
order = Order.new(@order_params)
|
|
322
|
+
order.calculate_total
|
|
323
|
+
order.apply_discount(@user)
|
|
324
|
+
order.reserve_inventory
|
|
325
|
+
|
|
326
|
+
if order.save
|
|
327
|
+
OrderMailer.confirmation(order).deliver_later
|
|
328
|
+
Result.success(order)
|
|
329
|
+
else
|
|
330
|
+
Result.failure(order.errors)
|
|
331
|
+
end
|
|
332
|
+
end
|
|
333
|
+
end
|
|
334
|
+
|
|
335
|
+
# En el controlador
|
|
336
|
+
class OrdersController < ApplicationController
|
|
337
|
+
def create
|
|
338
|
+
result = CreateOrderService.new(
|
|
339
|
+
user: current_user,
|
|
340
|
+
order_params: order_params
|
|
341
|
+
).call
|
|
342
|
+
|
|
343
|
+
if result.success?
|
|
344
|
+
redirect_to result.value
|
|
345
|
+
else
|
|
346
|
+
render :new
|
|
347
|
+
end
|
|
348
|
+
end
|
|
349
|
+
end
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
#### 2. Form Objects
|
|
353
|
+
**Cuándo usarlo**: Formularios que afectan múltiples modelos
|
|
354
|
+
|
|
355
|
+
#### 3. Query Objects
|
|
356
|
+
**Cuándo usarlo**: Queries complejas reutilizables
|
|
357
|
+
|
|
358
|
+
#### 4. Presenter/Decorator
|
|
359
|
+
**Cuándo usarlo**: Lógica de presentación compleja
|
|
360
|
+
|
|
361
|
+
### Recursos para Profundizar
|
|
362
|
+
|
|
363
|
+
📚 **Libros:**
|
|
364
|
+
- Design Patterns in Ruby (Russ Olsen)
|
|
365
|
+
- Practical Object-Oriented Design in Ruby (Sandi Metz)
|
|
366
|
+
- Refactoring: Ruby Edition (Jay Fields)
|
|
367
|
+
|
|
368
|
+
🎓 **Cursos:**
|
|
369
|
+
- Design Patterns in Ruby (Upcase)
|
|
370
|
+
- Refactoring Rails (GoRails)
|
|
371
|
+
|
|
372
|
+
📝 **Artículos:**
|
|
373
|
+
- 7 Patterns to Refactor Fat ActiveRecord Models
|
|
374
|
+
- Service Objects in Rails
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
## Recursos Generales
|
|
378
|
+
|
|
379
|
+
### Libros Esenciales
|
|
380
|
+
|
|
381
|
+
| Libro | Área | Nivel |
|
|
382
|
+
|-------|------|-------|
|
|
383
|
+
| Clean Code | General | Intermedio |
|
|
384
|
+
| POODR | OOP/Ruby | Intermedio |
|
|
385
|
+
| The Rails Way | Rails | Intermedio |
|
|
386
|
+
| Refactoring | Patterns | Avanzado |
|
|
387
|
+
| Domain-Driven Design | Architecture | Avanzado |
|
|
388
|
+
|
|
389
|
+
### Comunidades
|
|
390
|
+
|
|
391
|
+
- Ruby on Rails Discord
|
|
392
|
+
- Reddit r/rails
|
|
393
|
+
- Ruby Weekly newsletter
|
|
394
|
+
- Thoughtbot Blog
|
|
395
|
+
|
|
396
|
+
### Práctica
|
|
397
|
+
|
|
398
|
+
- Exercism.io (Ruby track)
|
|
399
|
+
- Codewars
|
|
400
|
+
- Contribuir a open source
|
|
401
|
+
|
|
402
|
+
## Notas importantes
|
|
403
|
+
|
|
404
|
+
- Las mejoras deben ser incrementales
|
|
405
|
+
- No refactorizar todo a la vez
|
|
406
|
+
- Siempre tener tests antes de refactorizar
|
|
407
|
+
- Priorizar por impacto en el proyecto
|
|
408
|
+
- El objetivo es aprender, no complicar el código
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
# Comando: /movil
|
|
2
|
+
|
|
3
|
+
Prepara y genera la versión móvil de la aplicación usando Hotwire Native.
|
|
4
|
+
|
|
5
|
+
## Flujo de trabajo
|
|
6
|
+
|
|
7
|
+
### Paso 1: Verificar requisitos
|
|
8
|
+
|
|
9
|
+
1. Confirmar que la app web funciona correctamente
|
|
10
|
+
2. Verificar que las vistas son responsive
|
|
11
|
+
3. Comprobar que Hotwire está configurado
|
|
12
|
+
|
|
13
|
+
### Paso 2: Preguntar plataformas
|
|
14
|
+
|
|
15
|
+
"¿Para qué plataformas quieres generar la app?"
|
|
16
|
+
- [ ] iOS
|
|
17
|
+
- [ ] Android
|
|
18
|
+
- [ ] Ambas
|
|
19
|
+
|
|
20
|
+
### Paso 3: Crear configuración de path
|
|
21
|
+
|
|
22
|
+
Crear archivo de configuración para la navegación nativa:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
mkdir -p public/configurations
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
```json
|
|
29
|
+
// public/configurations/ios_v1.json
|
|
30
|
+
{
|
|
31
|
+
"settings": {
|
|
32
|
+
"screenshots_enabled": true
|
|
33
|
+
},
|
|
34
|
+
"rules": [
|
|
35
|
+
{
|
|
36
|
+
"patterns": ["/"],
|
|
37
|
+
"properties": {
|
|
38
|
+
"presentation": "default"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"patterns": ["/new$", "/edit$"],
|
|
43
|
+
"properties": {
|
|
44
|
+
"presentation": "modal"
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"patterns": ["/sign_in", "/sign_up"],
|
|
49
|
+
"properties": {
|
|
50
|
+
"presentation": "replace"
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
]
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Paso 4: Crear helper para detectar app nativa
|
|
58
|
+
|
|
59
|
+
```ruby
|
|
60
|
+
# app/helpers/hotwire_native_helper.rb
|
|
61
|
+
module HotwireNativeHelper
|
|
62
|
+
def hotwire_native_app?
|
|
63
|
+
request.user_agent&.include?("Hotwire Native")
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def hotwire_native_ios?
|
|
67
|
+
request.user_agent&.include?("Hotwire Native iOS")
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def hotwire_native_android?
|
|
71
|
+
request.user_agent&.include?("Hotwire Native Android")
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Paso 5: Adaptar layout para móvil
|
|
77
|
+
|
|
78
|
+
```erb
|
|
79
|
+
<%# app/views/layouts/application.html.erb %>
|
|
80
|
+
<!DOCTYPE html>
|
|
81
|
+
<html lang="<%= I18n.locale %>" class="<%= 'hotwire-native' if hotwire_native_app? %>">
|
|
82
|
+
<head>
|
|
83
|
+
<!-- ... -->
|
|
84
|
+
</head>
|
|
85
|
+
<body class="<%= 'native-app' if hotwire_native_app? %>">
|
|
86
|
+
<% unless hotwire_native_app? %>
|
|
87
|
+
<%= render "shared/navigation" %>
|
|
88
|
+
<% end %>
|
|
89
|
+
|
|
90
|
+
<main class="<%= hotwire_native_app? ? 'pt-safe-top pb-safe-bottom' : '' %>">
|
|
91
|
+
<%= yield %>
|
|
92
|
+
</main>
|
|
93
|
+
|
|
94
|
+
<% unless hotwire_native_app? %>
|
|
95
|
+
<%= render "shared/footer" %>
|
|
96
|
+
<% end %>
|
|
97
|
+
</body>
|
|
98
|
+
</html>
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Paso 6: Generar proyecto iOS (si seleccionado)
|
|
102
|
+
|
|
103
|
+
Crear instrucciones para el proyecto iOS:
|
|
104
|
+
|
|
105
|
+
```markdown
|
|
106
|
+
## Configuración iOS
|
|
107
|
+
|
|
108
|
+
### Requisitos
|
|
109
|
+
- macOS
|
|
110
|
+
- Xcode 15+
|
|
111
|
+
- CocoaPods o Swift Package Manager
|
|
112
|
+
|
|
113
|
+
### Pasos
|
|
114
|
+
|
|
115
|
+
1. Crear nuevo proyecto Xcode (iOS App)
|
|
116
|
+
|
|
117
|
+
2. Añadir Hotwire Native via SPM:
|
|
118
|
+
- URL: https://github.com/hotwired/hotwire-native-ios
|
|
119
|
+
|
|
120
|
+
3. Configurar SceneDelegate:
|
|
121
|
+
```swift
|
|
122
|
+
import HotwireNative
|
|
123
|
+
|
|
124
|
+
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
|
|
125
|
+
var window: UIWindow?
|
|
126
|
+
private let navigator = Navigator()
|
|
127
|
+
|
|
128
|
+
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options: UIScene.ConnectionOptions) {
|
|
129
|
+
guard let windowScene = scene as? UIWindowScene else { return }
|
|
130
|
+
|
|
131
|
+
Hotwire.config.pathConfiguration.sources = [
|
|
132
|
+
.server(URL(string: "https://tu-app.com/configurations/ios_v1.json")!)
|
|
133
|
+
]
|
|
134
|
+
|
|
135
|
+
window = UIWindow(windowScene: windowScene)
|
|
136
|
+
window?.rootViewController = navigator.rootViewController
|
|
137
|
+
window?.makeKeyAndVisible()
|
|
138
|
+
|
|
139
|
+
navigator.route(URL(string: "https://tu-app.com")!)
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
4. Configurar permisos en Info.plist según necesidades
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### Paso 7: Generar proyecto Android (si seleccionado)
|
|
148
|
+
|
|
149
|
+
```markdown
|
|
150
|
+
## Configuración Android
|
|
151
|
+
|
|
152
|
+
### Requisitos
|
|
153
|
+
- Android Studio Hedgehog o superior
|
|
154
|
+
- JDK 17+
|
|
155
|
+
|
|
156
|
+
### Pasos
|
|
157
|
+
|
|
158
|
+
1. Crear nuevo proyecto Android (Empty Activity)
|
|
159
|
+
|
|
160
|
+
2. Añadir dependencia en build.gradle:
|
|
161
|
+
```kotlin
|
|
162
|
+
dependencies {
|
|
163
|
+
implementation("dev.hotwire:navigation:1.0.0")
|
|
164
|
+
}
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
3. Configurar MainActivity:
|
|
168
|
+
```kotlin
|
|
169
|
+
class MainActivity : HotwireActivity() {
|
|
170
|
+
override fun onCreate(savedInstanceState: Bundle?) {
|
|
171
|
+
super.onCreate(savedInstanceState)
|
|
172
|
+
setContentView(R.layout.activity_main)
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
override fun navigatorConfigurations() = listOf(
|
|
176
|
+
NavigatorConfiguration(
|
|
177
|
+
name = "main",
|
|
178
|
+
startLocation = "https://tu-app.com",
|
|
179
|
+
navigatorHostId = R.id.main_nav_host
|
|
180
|
+
)
|
|
181
|
+
)
|
|
182
|
+
}
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
4. Configurar permisos en AndroidManifest.xml
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### Paso 8: Verificar funcionalidad
|
|
189
|
+
|
|
190
|
+
Checklist de verificación:
|
|
191
|
+
- [ ] Navegación funciona correctamente
|
|
192
|
+
- [ ] Formularios envían datos
|
|
193
|
+
- [ ] Turbo Frames actualizan sin problemas
|
|
194
|
+
- [ ] Modales se abren correctamente
|
|
195
|
+
- [ ] Back button funciona
|
|
196
|
+
- [ ] Pull to refresh funciona
|
|
197
|
+
- [ ] Links externos abren en navegador
|
|
198
|
+
|
|
199
|
+
### Paso 9: Generar resumen
|
|
200
|
+
|
|
201
|
+
```markdown
|
|
202
|
+
# App Móvil Generada
|
|
203
|
+
|
|
204
|
+
## Configuración completada
|
|
205
|
+
- ✅ Path configuration creado
|
|
206
|
+
- ✅ Helper de detección añadido
|
|
207
|
+
- ✅ Layout adaptado para nativo
|
|
208
|
+
- ✅ Instrucciones iOS generadas
|
|
209
|
+
- ✅ Instrucciones Android generadas
|
|
210
|
+
|
|
211
|
+
## Archivos creados/modificados
|
|
212
|
+
- `public/configurations/ios_v1.json`
|
|
213
|
+
- `public/configurations/android_v1.json`
|
|
214
|
+
- `app/helpers/hotwire_native_helper.rb`
|
|
215
|
+
- `app/views/layouts/application.html.erb`
|
|
216
|
+
|
|
217
|
+
## Próximos pasos
|
|
218
|
+
|
|
219
|
+
### Para iOS:
|
|
220
|
+
1. Sigue las instrucciones en `docs/ios_setup.md`
|
|
221
|
+
2. Configura tu URL de producción
|
|
222
|
+
3. Añade iconos y splash screen
|
|
223
|
+
4. Prueba en simulador y dispositivo real
|
|
224
|
+
5. Publica en App Store
|
|
225
|
+
|
|
226
|
+
### Para Android:
|
|
227
|
+
1. Sigue las instrucciones en `docs/android_setup.md`
|
|
228
|
+
2. Configura tu URL de producción
|
|
229
|
+
3. Añade iconos y splash screen
|
|
230
|
+
4. Prueba en emulador y dispositivo real
|
|
231
|
+
5. Publica en Play Store
|
|
232
|
+
|
|
233
|
+
## Recursos útiles
|
|
234
|
+
- [Hotwire Native iOS](https://github.com/hotwired/hotwire-native-ios)
|
|
235
|
+
- [Hotwire Native Android](https://github.com/hotwired/hotwire-native-android)
|
|
236
|
+
- [Documentación oficial](https://hotwired.dev)
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
## Notas importantes
|
|
240
|
+
|
|
241
|
+
- La app móvil usa las mismas vistas que la web
|
|
242
|
+
- Solo se necesita código nativo mínimo para el "shell"
|
|
243
|
+
- Los cambios en la web se reflejan automáticamente en móvil
|
|
244
|
+
- Para funcionalidades nativas específicas (cámara, GPS, etc.) se necesitan bridge components
|
|
245
|
+
- Probar siempre en dispositivos reales antes de publicar
|