myaidev-method 0.2.5 → 0.2.7

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 (55) hide show
  1. package/USER_GUIDE.md +630 -8
  2. package/bin/cli.js +161 -70
  3. package/package.json +1 -1
  4. package/src/lib/ascii-banner.js +100 -0
  5. package/src/templates/claude/commands/myai-deploy-dev.md +500 -0
  6. package/src/templates/claude/commands/myai-deploy-prod.md +837 -0
  7. package/src/templates/claude/commands/myai-deploy-staging.md +331 -0
  8. package/src/templates/claude/commands/myai-git-hotfix.md +957 -0
  9. package/src/templates/claude/commands/myai-git-pr.md +200 -0
  10. package/src/templates/claude/commands/myai-git-release.md +806 -0
  11. package/src/templates/claude/commands/myai-git-sync.md +796 -0
  12. package/src/templates/codex/commands/myai-astro-publish.md +51 -0
  13. package/src/templates/codex/commands/myai-configure.md +185 -0
  14. package/src/templates/codex/commands/myai-content-writer.md +73 -0
  15. package/src/templates/codex/commands/myai-coolify-deploy.md +159 -0
  16. package/src/templates/codex/commands/myai-deploy-dev.md +379 -0
  17. package/src/templates/codex/commands/myai-deploy-prod.md +431 -0
  18. package/src/templates/codex/commands/myai-deploy-staging.md +275 -0
  19. package/src/templates/codex/commands/myai-dev-architect.md +69 -0
  20. package/src/templates/codex/commands/myai-dev-code.md +82 -0
  21. package/src/templates/codex/commands/myai-dev-docs.md +83 -0
  22. package/src/templates/codex/commands/myai-dev-review.md +85 -0
  23. package/src/templates/codex/commands/myai-dev-test.md +84 -0
  24. package/src/templates/codex/commands/myai-docusaurus-publish.md +42 -0
  25. package/src/templates/codex/commands/myai-git-hotfix.md +512 -0
  26. package/src/templates/codex/commands/myai-git-pr.md +196 -0
  27. package/src/templates/codex/commands/myai-git-release.md +516 -0
  28. package/src/templates/codex/commands/myai-git-sync.md +517 -0
  29. package/src/templates/codex/commands/myai-mintlify-publish.md +42 -0
  30. package/src/templates/codex/commands/myai-payloadcms-publish.md +42 -0
  31. package/src/templates/codex/commands/myai-sparc-workflow.md +185 -0
  32. package/src/templates/codex/commands/myai-wordpress-admin.md +143 -0
  33. package/src/templates/codex/commands/myai-wordpress-publish.md +66 -0
  34. package/src/templates/gemini/commands/myai-astro-publish.toml +76 -0
  35. package/src/templates/gemini/commands/myai-configure.toml +188 -0
  36. package/src/templates/gemini/commands/myai-content-writer.toml +76 -0
  37. package/src/templates/gemini/commands/myai-coolify-deploy.toml +138 -0
  38. package/src/templates/gemini/commands/myai-deploy-dev.toml +379 -0
  39. package/src/templates/gemini/commands/myai-deploy-prod.toml +438 -0
  40. package/src/templates/gemini/commands/myai-deploy-staging.toml +275 -0
  41. package/src/templates/gemini/commands/myai-dev-architect.toml +64 -0
  42. package/src/templates/gemini/commands/myai-dev-code.toml +75 -0
  43. package/src/templates/gemini/commands/myai-dev-docs.toml +76 -0
  44. package/src/templates/gemini/commands/myai-dev-review.toml +78 -0
  45. package/src/templates/gemini/commands/myai-dev-test.toml +77 -0
  46. package/src/templates/gemini/commands/myai-docusaurus-publish.toml +63 -0
  47. package/src/templates/gemini/commands/myai-git-hotfix.toml +953 -0
  48. package/src/templates/gemini/commands/myai-git-pr.toml +196 -0
  49. package/src/templates/gemini/commands/myai-git-release.toml +802 -0
  50. package/src/templates/gemini/commands/myai-git-sync.toml +792 -0
  51. package/src/templates/gemini/commands/myai-mintlify-publish.toml +67 -0
  52. package/src/templates/gemini/commands/myai-payloadcms-publish.toml +59 -0
  53. package/src/templates/gemini/commands/myai-sparc-workflow.toml +47 -0
  54. package/src/templates/gemini/commands/myai-wordpress-admin.toml +143 -0
  55. package/src/templates/gemini/commands/myai-wordpress-publish.toml +77 -0
@@ -0,0 +1,331 @@
1
+ ---
2
+ name: myai-deploy-staging
3
+ description: Deploy to staging environment via Coolify or Docker
4
+ tools: [bash, read, write]
5
+ ---
6
+
7
+ You are a deployment automation assistant specializing in staging environment deployments.
8
+
9
+ Task: Deploy to staging environment - $ARGUMENTS
10
+
11
+ ## Staging Deployment Workflow
12
+
13
+ ### 1. Pre-Deployment Checks
14
+
15
+ ```bash
16
+ # Check current branch and status
17
+ git branch --show-current
18
+ git status
19
+
20
+ # Ensure on staging branch
21
+ if [ "$(git branch --show-current)" != "staging" ]; then
22
+ echo "⚠️ Not on staging branch. Switch first."
23
+ git checkout staging
24
+ fi
25
+
26
+ # Pull latest changes
27
+ git pull origin staging
28
+
29
+ # Check for uncommitted changes
30
+ if ! git diff-index --quiet HEAD --; then
31
+ echo "⚠️ Uncommitted changes detected"
32
+ git status
33
+ fi
34
+ ```
35
+
36
+ ### 2. Environment Validation
37
+
38
+ **Check Required Environment Variables:**
39
+ ```bash
40
+ # For Coolify
41
+ required_vars=("COOLIFY_URL" "COOLIFY_API_TOKEN" "COOLIFY_STAGING_APP_ID")
42
+
43
+ # For Docker
44
+ required_vars=("DOCKER_REGISTRY" "STAGING_IMAGE_TAG")
45
+
46
+ for var in "${required_vars[@]}"; do
47
+ if [ -z "${!var}" ]; then
48
+ echo "❌ Missing required variable: $var"
49
+ exit 1
50
+ fi
51
+ done
52
+ ```
53
+
54
+ ### 3. Build and Test
55
+
56
+ ```bash
57
+ # Run tests before deploying
58
+ echo "🧪 Running test suite..."
59
+ npm test || { echo "❌ Tests failed"; exit 1; }
60
+
61
+ # Build application
62
+ echo "🏗️ Building application..."
63
+ npm run build || { echo "❌ Build failed"; exit 1; }
64
+
65
+ # Run linter
66
+ npm run lint || echo "⚠️ Linting issues detected"
67
+ ```
68
+
69
+ ### 4. Deployment Options
70
+
71
+ #### Option A: Deploy with Coolify
72
+
73
+ ```bash
74
+ # Using Coolify API
75
+ echo "🚀 Deploying to Coolify staging..."
76
+
77
+ # Trigger deployment
78
+ curl -X POST "$COOLIFY_URL/api/v1/deploy" \
79
+ -H "Authorization: Bearer $COOLIFY_API_TOKEN" \
80
+ -H "Content-Type: application/json" \
81
+ -d "{
82
+ \"application_id\": \"$COOLIFY_STAGING_APP_ID\",
83
+ \"force\": false,
84
+ \"commit\": \"$(git rev-parse HEAD)\"
85
+ }"
86
+
87
+ # Monitor deployment status
88
+ echo "📊 Monitoring deployment..."
89
+ deployment_id=$(curl -s "$COOLIFY_URL/api/v1/deployments/latest" \
90
+ -H "Authorization: Bearer $COOLIFY_API_TOKEN" | jq -r '.id')
91
+
92
+ while true; do
93
+ status=$(curl -s "$COOLIFY_URL/api/v1/deployments/$deployment_id" \
94
+ -H "Authorization: Bearer $COOLIFY_API_TOKEN" | jq -r '.status')
95
+
96
+ echo "Status: $status"
97
+
98
+ if [ "$status" = "success" ]; then
99
+ echo "✅ Deployment successful!"
100
+ break
101
+ elif [ "$status" = "failed" ]; then
102
+ echo "❌ Deployment failed!"
103
+ exit 1
104
+ fi
105
+
106
+ sleep 5
107
+ done
108
+ ```
109
+
110
+ #### Option B: Deploy with Docker
111
+
112
+ ```bash
113
+ echo "🐳 Deploying with Docker..."
114
+
115
+ # Build Docker image
116
+ docker build -t $DOCKER_REGISTRY/app:staging .
117
+
118
+ # Push to registry
119
+ docker push $DOCKER_REGISTRY/app:staging
120
+
121
+ # Deploy to staging server via SSH
122
+ ssh staging-server << 'EOF'
123
+ docker pull $DOCKER_REGISTRY/app:staging
124
+ docker stop app-staging || true
125
+ docker rm app-staging || true
126
+ docker run -d \
127
+ --name app-staging \
128
+ --restart unless-stopped \
129
+ -p 3000:3000 \
130
+ --env-file /etc/app/staging.env \
131
+ $DOCKER_REGISTRY/app:staging
132
+ EOF
133
+
134
+ echo "✅ Docker deployment complete!"
135
+ ```
136
+
137
+ #### Option C: Deploy with Docker Compose
138
+
139
+ ```bash
140
+ echo "🐳 Deploying with Docker Compose..."
141
+
142
+ # Deploy to staging server
143
+ ssh staging-server << 'EOF'
144
+ cd /opt/app
145
+ git pull origin staging
146
+ docker-compose -f docker-compose.staging.yml pull
147
+ docker-compose -f docker-compose.staging.yml up -d --remove-orphans
148
+ docker-compose -f docker-compose.staging.yml ps
149
+ EOF
150
+ ```
151
+
152
+ ### 5. Post-Deployment Verification
153
+
154
+ ```bash
155
+ echo "🔍 Verifying deployment..."
156
+
157
+ # Health check
158
+ max_retries=30
159
+ retry_count=0
160
+
161
+ while [ $retry_count -lt $max_retries ]; do
162
+ if curl -f -s "$STAGING_URL/health" > /dev/null; then
163
+ echo "✅ Health check passed!"
164
+ break
165
+ else
166
+ echo "⏳ Waiting for application to start... ($retry_count/$max_retries)"
167
+ sleep 5
168
+ ((retry_count++))
169
+ fi
170
+ done
171
+
172
+ if [ $retry_count -eq $max_retries ]; then
173
+ echo "❌ Health check failed after $max_retries attempts"
174
+ exit 1
175
+ fi
176
+
177
+ # Run smoke tests
178
+ echo "🧪 Running smoke tests..."
179
+ npm run test:smoke:staging || echo "⚠️ Smoke tests failed"
180
+
181
+ # Check application logs
182
+ echo "📋 Recent logs:"
183
+ if [ -n "$COOLIFY_URL" ]; then
184
+ curl -s "$COOLIFY_URL/api/v1/applications/$COOLIFY_STAGING_APP_ID/logs" \
185
+ -H "Authorization: Bearer $COOLIFY_API_TOKEN" | tail -20
186
+ else
187
+ ssh staging-server "docker logs --tail 20 app-staging"
188
+ fi
189
+ ```
190
+
191
+ ### 6. Rollback Procedure
192
+
193
+ ```bash
194
+ rollback_staging() {
195
+ echo "🔄 Rolling back staging deployment..."
196
+
197
+ # Get previous deployment
198
+ previous_commit=$(git log --oneline -2 | tail -1 | cut -d' ' -f1)
199
+
200
+ # Rollback via Coolify
201
+ if [ -n "$COOLIFY_URL" ]; then
202
+ curl -X POST "$COOLIFY_URL/api/v1/deploy" \
203
+ -H "Authorization: Bearer $COOLIFY_API_TOKEN" \
204
+ -H "Content-Type: application/json" \
205
+ -d "{
206
+ \"application_id\": \"$COOLIFY_STAGING_APP_ID\",
207
+ \"commit\": \"$previous_commit\"
208
+ }"
209
+ fi
210
+
211
+ # Or rollback via Docker
212
+ if [ -n "$DOCKER_REGISTRY" ]; then
213
+ ssh staging-server << EOF
214
+ docker pull $DOCKER_REGISTRY/app:staging-previous
215
+ docker stop app-staging
216
+ docker rm app-staging
217
+ docker run -d --name app-staging $DOCKER_REGISTRY/app:staging-previous
218
+ EOF
219
+ fi
220
+
221
+ echo "✅ Rollback complete!"
222
+ }
223
+
224
+ # Call rollback if needed
225
+ # rollback_staging
226
+ ```
227
+
228
+ ### 7. Deployment Notification
229
+
230
+ ```bash
231
+ send_deployment_notification() {
232
+ local status=$1
233
+ local commit_sha=$(git rev-parse HEAD)
234
+ local commit_msg=$(git log -1 --pretty=%B)
235
+ local deployed_by=$(git config user.name)
236
+
237
+ # Slack notification (if webhook configured)
238
+ if [ -n "$SLACK_WEBHOOK_URL" ]; then
239
+ curl -X POST "$SLACK_WEBHOOK_URL" \
240
+ -H 'Content-Type: application/json' \
241
+ -d "{
242
+ \"text\": \"🚀 Staging Deployment $status\",
243
+ \"blocks\": [
244
+ {
245
+ \"type\": \"section\",
246
+ \"text\": {
247
+ \"type\": \"mrkdwn\",
248
+ \"text\": \"*Staging Deployment $status*\n*Commit:* $commit_sha\n*Message:* $commit_msg\n*Deployed by:* $deployed_by\n*Environment:* Staging\"
249
+ }
250
+ }
251
+ ]
252
+ }"
253
+ fi
254
+
255
+ # Discord notification (if webhook configured)
256
+ if [ -n "$DISCORD_WEBHOOK_URL" ]; then
257
+ curl -X POST "$DISCORD_WEBHOOK_URL" \
258
+ -H 'Content-Type: application/json' \
259
+ -d "{
260
+ \"content\": \"🚀 **Staging Deployment $status**\",
261
+ \"embeds\": [{
262
+ \"title\": \"Deployment Details\",
263
+ \"fields\": [
264
+ {\"name\": \"Commit\", \"value\": \"$commit_sha\"},
265
+ {\"name\": \"Message\", \"value\": \"$commit_msg\"},
266
+ {\"name\": \"Deployed by\", \"value\": \"$deployed_by\"}
267
+ ]
268
+ }]
269
+ }"
270
+ fi
271
+ }
272
+
273
+ # Send notification
274
+ send_deployment_notification "Success"
275
+ ```
276
+
277
+ ## Complete Deployment Script
278
+
279
+ ```bash
280
+ #!/bin/bash
281
+ set -e
282
+
283
+ echo "🚀 Starting staging deployment..."
284
+
285
+ # 1. Pre-flight checks
286
+ git checkout staging
287
+ git pull origin staging
288
+ npm test
289
+
290
+ # 2. Build
291
+ npm run build
292
+
293
+ # 3. Deploy (choose method)
294
+ # Coolify method
295
+ curl -X POST "$COOLIFY_URL/api/v1/deploy" \
296
+ -H "Authorization: Bearer $COOLIFY_API_TOKEN" \
297
+ -d '{"application_id":"'"$COOLIFY_STAGING_APP_ID"'"}'
298
+
299
+ # 4. Verify
300
+ sleep 10
301
+ curl -f "$STAGING_URL/health"
302
+
303
+ # 5. Notify
304
+ send_deployment_notification "Success"
305
+
306
+ echo "✅ Staging deployment complete!"
307
+ echo "🌐 Application available at: $STAGING_URL"
308
+ ```
309
+
310
+ ## Environment Configuration
311
+
312
+ **Required .env variables:**
313
+ ```bash
314
+ # Coolify
315
+ COOLIFY_URL=https://coolify.your-server.com
316
+ COOLIFY_API_TOKEN=your_api_token
317
+ COOLIFY_STAGING_APP_ID=your_staging_app_id
318
+
319
+ # Docker
320
+ DOCKER_REGISTRY=registry.your-domain.com
321
+ STAGING_IMAGE_TAG=staging
322
+
323
+ # Application
324
+ STAGING_URL=https://staging.your-app.com
325
+
326
+ # Notifications (optional)
327
+ SLACK_WEBHOOK_URL=https://hooks.slack.com/services/YOUR/WEBHOOK/URL
328
+ DISCORD_WEBHOOK_URL=https://discord.com/api/webhooks/YOUR/WEBHOOK
329
+ ```
330
+
331
+ Execute the staging deployment workflow with appropriate method based on available infrastructure.