@atlashub/smartstack-cli 1.17.0 → 1.19.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.
Files changed (35) hide show
  1. package/package.json +1 -1
  2. package/templates/agents/efcore/db-deploy.md +5 -0
  3. package/templates/agents/efcore/db-reset.md +5 -0
  4. package/templates/agents/efcore/db-seed.md +5 -0
  5. package/templates/agents/efcore/db-status.md +5 -0
  6. package/templates/agents/efcore/migration.md +8 -0
  7. package/templates/agents/efcore/rebase-snapshot.md +9 -0
  8. package/templates/agents/efcore/squash.md +50 -20
  9. package/templates/commands/efcore/squash.md +24 -12
  10. package/templates/skills/efcore/SKILL.md +162 -0
  11. package/templates/skills/efcore/steps/db/step-deploy.md +208 -0
  12. package/templates/skills/efcore/steps/db/step-reset.md +259 -0
  13. package/templates/skills/efcore/steps/db/step-seed.md +244 -0
  14. package/templates/skills/efcore/steps/db/step-status.md +198 -0
  15. package/templates/skills/efcore/steps/migration/step-00-init.md +102 -0
  16. package/templates/skills/efcore/steps/migration/step-01-check.md +138 -0
  17. package/templates/skills/efcore/steps/migration/step-02-create.md +144 -0
  18. package/templates/skills/efcore/steps/migration/step-03-validate.md +203 -0
  19. package/templates/skills/efcore/steps/rebase-snapshot/step-00-init.md +173 -0
  20. package/templates/skills/efcore/steps/rebase-snapshot/step-01-backup.md +100 -0
  21. package/templates/skills/efcore/steps/rebase-snapshot/step-02-fetch.md +115 -0
  22. package/templates/skills/efcore/steps/rebase-snapshot/step-03-create.md +108 -0
  23. package/templates/skills/efcore/steps/rebase-snapshot/step-04-validate.md +157 -0
  24. package/templates/skills/efcore/steps/shared/step-00-init.md +266 -0
  25. package/templates/skills/efcore/steps/squash/step-00-init.md +141 -0
  26. package/templates/skills/efcore/steps/squash/step-01-backup.md +120 -0
  27. package/templates/skills/efcore/steps/squash/step-02-fetch.md +168 -0
  28. package/templates/skills/efcore/steps/squash/step-03-create.md +178 -0
  29. package/templates/skills/efcore/steps/squash/step-04-validate.md +174 -0
  30. package/templates/skills/gitflow/steps/step-commit.md +14 -2
  31. package/templates/skills/gitflow/steps/step-finish.md +26 -0
  32. package/templates/skills/gitflow/steps/step-merge.md +8 -3
  33. package/templates/skills/gitflow/steps/step-pr.md +10 -0
  34. package/templates/skills/gitflow/steps/step-start.md +12 -1
  35. package/templates/skills/gitflow/steps/step-sync.md +24 -0
@@ -0,0 +1,198 @@
1
+ ---
2
+ name: step-status
3
+ description: Display migrations and database status
4
+ next_step: null
5
+ ---
6
+
7
+ # Database Status
8
+
9
+ ## YOUR TASK:
10
+
11
+ Display comprehensive status of EF Core migrations and database connection.
12
+
13
+ **Requires:** `steps/shared/step-00-init.md` completed
14
+
15
+ **Type:** Read-only, no modifications
16
+
17
+ ---
18
+
19
+ ## EXECUTION SEQUENCE:
20
+
21
+ ### 1. Display Configuration
22
+
23
+ ```bash
24
+ echo ""
25
+ echo "EF CORE STATUS"
26
+ echo "=============="
27
+ echo ""
28
+ echo "Project: $PROJECT_NAME"
29
+ echo "DbContext: $DBCONTEXT ($DBCONTEXT_TYPE)"
30
+ echo "Schema: $SCHEMA"
31
+ echo "Environment: $SELECTED_ENV"
32
+ echo "Config: $CONFIG_FILE"
33
+ ```
34
+
35
+ ### 2. Test Database Connection
36
+
37
+ ```bash
38
+ echo ""
39
+ echo "Testing connection..."
40
+
41
+ CONNECTION_TEST=$(dotnet ef database list \
42
+ --context "$DBCONTEXT" \
43
+ --project "$INFRA_PROJECT" \
44
+ --startup-project "$STARTUP_PROJECT" 2>&1)
45
+
46
+ if [ $? -eq 0 ]; then
47
+ echo "Connection: OK"
48
+ else
49
+ echo "Connection: FAILED"
50
+ echo ""
51
+ echo "$CONNECTION_TEST"
52
+ fi
53
+ ```
54
+
55
+ ### 3. List Migrations
56
+
57
+ ```bash
58
+ echo ""
59
+ echo "Migrations:"
60
+
61
+ dotnet ef migrations list \
62
+ --context "$DBCONTEXT" \
63
+ --project "$INFRA_PROJECT" \
64
+ --startup-project "$STARTUP_PROJECT"
65
+ ```
66
+
67
+ ### 4. Count Applied vs Pending
68
+
69
+ ```bash
70
+ MIGRATION_OUTPUT=$(dotnet ef migrations list \
71
+ --context "$DBCONTEXT" \
72
+ --project "$INFRA_PROJECT" \
73
+ --startup-project "$STARTUP_PROJECT" 2>/dev/null)
74
+
75
+ APPLIED=$(echo "$MIGRATION_OUTPUT" | grep -v "(Pending)" | grep -c "^[0-9]" || echo "0")
76
+ PENDING=$(echo "$MIGRATION_OUTPUT" | grep -c "(Pending)" || echo "0")
77
+ TOTAL=$((APPLIED + PENDING))
78
+
79
+ echo ""
80
+ echo "Summary:"
81
+ echo " Total: $TOTAL migrations"
82
+ echo " Applied: $APPLIED"
83
+ echo " Pending: $PENDING"
84
+ ```
85
+
86
+ ### 5. Check MCP for Conflicts (Optional)
87
+
88
+ ```javascript
89
+ // Call MCP for additional analysis
90
+ const result = await mcp__smartstack__check_migrations({
91
+ branch: CURRENT_BRANCH
92
+ });
93
+
94
+ if (result.conflicts && result.conflicts.length > 0) {
95
+ console.log("");
96
+ console.log("Conflicts detected:");
97
+ result.conflicts.forEach(c => console.log(" - " + c));
98
+ }
99
+ ```
100
+
101
+ ### 6. Check Naming Compliance
102
+
103
+ ```bash
104
+ echo ""
105
+ echo "Naming compliance:"
106
+
107
+ # Check migration naming pattern
108
+ PATTERN="^(core|extensions)_v[0-9]+\.[0-9]+\.[0-9]+_[0-9]+_"
109
+ NON_COMPLIANT=$(find "$MIGRATIONS_DIR" -name "*.cs" 2>/dev/null | \
110
+ grep -v "Designer\|Snapshot" | \
111
+ xargs -I{} basename {} .cs | \
112
+ grep -v -E "$PATTERN" | \
113
+ wc -l)
114
+
115
+ if [ "$NON_COMPLIANT" -eq 0 ]; then
116
+ echo " All migrations follow naming convention"
117
+ else
118
+ echo " WARNING: $NON_COMPLIANT migrations have non-standard names"
119
+ fi
120
+ ```
121
+
122
+ ### 7. Check 1-Migration-Per-Feature Rule
123
+
124
+ ```bash
125
+ # Count migrations for current branch
126
+ BRANCH_MIGS=$(find "$MIGRATIONS_DIR" -name "*.cs" 2>/dev/null | \
127
+ grep -v "Designer\|Snapshot" | \
128
+ xargs -I{} basename {} | \
129
+ grep -i "$(echo "$CURRENT_BRANCH" | sed 's|.*/||' | tr '-' '_')" | \
130
+ wc -l)
131
+
132
+ echo ""
133
+ if [ "$BRANCH_MIGS" -le 1 ]; then
134
+ echo "1-migration-per-feature: OK"
135
+ else
136
+ echo "1-migration-per-feature: WARNING ($BRANCH_MIGS migrations for this branch)"
137
+ echo " Consider: /efcore squash"
138
+ fi
139
+ ```
140
+
141
+ ---
142
+
143
+ ## OUTPUT FORMAT:
144
+
145
+ ```
146
+ EF CORE STATUS
147
+ ==============
148
+ Project: {project_name}
149
+ DbContext: {dbcontext} ({dbcontext_type})
150
+ Schema: {schema}
151
+ Environment: {env}
152
+ Config: {config_file}
153
+
154
+ Connection: {OK | FAILED}
155
+
156
+ Migrations:
157
+ {list of migrations}
158
+
159
+ Summary:
160
+ Total: {N} migrations
161
+ Applied: {N}
162
+ Pending: {N}
163
+
164
+ Naming compliance: {OK | WARNING}
165
+ 1-migration-per-feature: {OK | WARNING}
166
+
167
+ {if pending}
168
+ Next: /efcore db-deploy
169
+ {endif}
170
+ ```
171
+
172
+ ---
173
+
174
+ ## TROUBLESHOOTING (if connection fails):
175
+
176
+ ```
177
+ TROUBLESHOOTING
178
+ ├── SQL Server running?
179
+ ├── appsettings.Local.json configured?
180
+ ├── Database exists?
181
+ └── Commands: /efcore db-reset, /efcore db-deploy
182
+ ```
183
+
184
+ ---
185
+
186
+ ## OPTIONS:
187
+
188
+ | Option | Description |
189
+ |--------|-------------|
190
+ | `--verbose` | Show all migrations with details |
191
+ | `--json` | Output as JSON |
192
+ | `--context` | Specify DbContext |
193
+
194
+ ---
195
+
196
+ ## COMPLETION:
197
+
198
+ Status displayed. No modifications made.
@@ -0,0 +1,102 @@
1
+ ---
2
+ name: step-00-init
3
+ description: Initialize migration - cross-branch check and context detection
4
+ next_step: step-01-check.md
5
+ ---
6
+
7
+ # Step 0: Initialize Migration
8
+
9
+ ## YOUR TASK:
10
+
11
+ Detect context, check for cross-branch conflicts, and prepare for migration creation.
12
+
13
+ **Requires:** `steps/shared/step-00-init.md` completed (provides {dbcontext}, {base_branch}, etc.)
14
+
15
+ ---
16
+
17
+ ## RULE:
18
+
19
+ ```
20
+ 1 MIGRATION PER FEATURE
21
+
22
+ - If migration exists for this branch → recreate it
23
+ - Never accumulate multiple migrations per feature
24
+ - Squash before merge if needed
25
+ ```
26
+
27
+ ---
28
+
29
+ ## EXECUTION SEQUENCE:
30
+
31
+ ### 1. Display Context
32
+
33
+ ```bash
34
+ echo "Migration Context"
35
+ echo "================"
36
+ echo ""
37
+ echo "Branch: $CURRENT_BRANCH"
38
+ echo "Type: $BRANCH_TYPE"
39
+ echo "DbContext: $DBCONTEXT ($DBCONTEXT_TYPE)"
40
+ echo "Schema: $SCHEMA"
41
+ echo "Migrations: $MIGRATIONS_DIR"
42
+ ```
43
+
44
+ ### 2. Cross-Branch Validation (Optional)
45
+
46
+ ```bash
47
+ if [ "$CROSS_BRANCH_ENABLED" = "true" ]; then
48
+ echo ""
49
+ echo "Checking cross-branch conflicts..."
50
+
51
+ # Get snapshot from develop
52
+ DEVELOP_SNAPSHOT=$(git show "origin/$BASE_BRANCH:$MIGRATIONS_DIR/${DBCONTEXT}ModelSnapshot.cs" 2>/dev/null || echo "")
53
+ LOCAL_SNAPSHOT=$(cat "$MIGRATIONS_DIR/${DBCONTEXT}ModelSnapshot.cs" 2>/dev/null || echo "")
54
+
55
+ if [ -n "$DEVELOP_SNAPSHOT" ] && [ -n "$LOCAL_SNAPSHOT" ]; then
56
+ DIFF_LINES=$(diff <(echo "$DEVELOP_SNAPSHOT") <(echo "$LOCAL_SNAPSHOT") 2>/dev/null | wc -l)
57
+
58
+ if [ "$DIFF_LINES" -gt 100 ]; then
59
+ echo ""
60
+ echo "WARNING: Cross-branch conflict detected ($DIFF_LINES lines differ)"
61
+ echo "Recommendation: /efcore rebase-snapshot"
62
+ echo ""
63
+
64
+ if [ "$BLOCK_ON_CONFLICT" = "true" ]; then
65
+ echo "BLOCKED: Use --force to override or rebase first"
66
+ exit 1
67
+ fi
68
+ else
69
+ echo " No significant conflicts detected"
70
+ fi
71
+ fi
72
+ fi
73
+ ```
74
+
75
+ ### 3. Skip If --force Flag
76
+
77
+ ```bash
78
+ if [ "$FORCE_FLAG" = "true" ]; then
79
+ echo ""
80
+ echo "Force mode: skipping cross-branch check"
81
+ fi
82
+ ```
83
+
84
+ ---
85
+
86
+ ## STATE OUTPUT:
87
+
88
+ | Variable | Description |
89
+ |----------|-------------|
90
+ | `{cross_branch_ok}` | true if no conflicts or force mode |
91
+ | `{diff_lines}` | Number of lines different from parent |
92
+
93
+ ---
94
+
95
+ ## SUCCESS CRITERIA:
96
+
97
+ - DbContext detected
98
+ - Cross-branch check passed (or forced)
99
+
100
+ ## NEXT STEP:
101
+
102
+ → `step-01-check.md`
@@ -0,0 +1,138 @@
1
+ ---
2
+ name: step-01-check
3
+ description: Check for existing migration and decide action
4
+ next_step: step-02-create.md
5
+ ---
6
+
7
+ # Step 1: Check Existing Migration
8
+
9
+ ## YOUR TASK:
10
+
11
+ Search for existing migrations for this branch and decide whether to recreate or skip.
12
+
13
+ **Previous step:** `step-00-init.md`
14
+
15
+ ---
16
+
17
+ ## EXECUTION SEQUENCE:
18
+
19
+ ### 1. Build Search Pattern
20
+
21
+ ```bash
22
+ # Extract branch name for pattern
23
+ case "$BRANCH_TYPE" in
24
+ feature)
25
+ BRANCH_SHORT=$(echo "$CURRENT_BRANCH" | sed 's|feature/||' | tr '-' '_')
26
+ ;;
27
+ release)
28
+ BRANCH_SHORT=$(echo "$CURRENT_BRANCH" | sed 's|release/||' | tr '.' '_')
29
+ ;;
30
+ hotfix)
31
+ BRANCH_SHORT=$(echo "$CURRENT_BRANCH" | sed 's|hotfix/||' | tr '.' '_')
32
+ ;;
33
+ *)
34
+ BRANCH_SHORT=""
35
+ ;;
36
+ esac
37
+
38
+ echo "Searching for existing migrations..."
39
+ echo " Pattern: *${BRANCH_SHORT}*"
40
+ ```
41
+
42
+ ### 2. Find Existing Migrations
43
+
44
+ ```bash
45
+ # Search for migrations that match this branch
46
+ EXISTING_MIGRATIONS=$(find "$MIGRATIONS_DIR" -name "*.cs" 2>/dev/null | \
47
+ grep -v "Designer\|Snapshot" | \
48
+ xargs -I{} basename {} | \
49
+ grep -i "$BRANCH_SHORT" || echo "")
50
+
51
+ EXISTING_COUNT=$(echo "$EXISTING_MIGRATIONS" | grep -c "." 2>/dev/null || echo "0")
52
+
53
+ echo ""
54
+ if [ "$EXISTING_COUNT" -gt 0 ]; then
55
+ echo "Found $EXISTING_COUNT existing migration(s):"
56
+ echo "$EXISTING_MIGRATIONS" | while read mig; do
57
+ echo " - $mig"
58
+ done
59
+ else
60
+ echo "No existing migration for this branch."
61
+ fi
62
+ ```
63
+
64
+ ### 3. Decide Action
65
+
66
+ **If migrations exist and NOT force mode:**
67
+
68
+ ```yaml
69
+ AskUserQuestion:
70
+ header: "Migration"
71
+ question: "Found {EXISTING_COUNT} existing migration(s). What do you want to do?"
72
+ options:
73
+ - label: "Recreate (Recommended)"
74
+ description: "Delete existing and create new"
75
+ - label: "Keep and add new"
76
+ description: "Add another migration (not recommended)"
77
+ - label: "Cancel"
78
+ description: "Do nothing"
79
+ multiSelect: false
80
+ ```
81
+
82
+ **Handle response:**
83
+
84
+ ```javascript
85
+ if (answer === "Recreate (Recommended)" || force_mode) {
86
+ // Delete existing migrations
87
+ ACTION = "recreate";
88
+ } else if (answer === "Keep and add new") {
89
+ ACTION = "add";
90
+ // Warning: violates 1-migration-per-feature rule
91
+ } else {
92
+ // Cancel
93
+ exit(0);
94
+ }
95
+ ```
96
+
97
+ ### 4. Delete Existing (If Recreate)
98
+
99
+ ```bash
100
+ if [ "$ACTION" = "recreate" ]; then
101
+ echo ""
102
+ echo "Removing existing migrations..."
103
+
104
+ for mig in $EXISTING_MIGRATIONS; do
105
+ mig_name="${mig%.cs}"
106
+
107
+ rm -f "$MIGRATIONS_DIR/${mig_name}.cs"
108
+ rm -f "$MIGRATIONS_DIR/${mig_name}.Designer.cs"
109
+
110
+ echo " Removed: $mig_name"
111
+ done
112
+
113
+ echo ""
114
+ echo "Existing migrations removed."
115
+ fi
116
+ ```
117
+
118
+ ---
119
+
120
+ ## STATE OUTPUT:
121
+
122
+ | Variable | Description |
123
+ |----------|-------------|
124
+ | `{existing_migrations}` | List of existing migrations |
125
+ | `{existing_count}` | Number found |
126
+ | `{action}` | "recreate", "add", or "cancel" |
127
+
128
+ ---
129
+
130
+ ## SUCCESS CRITERIA:
131
+
132
+ - Existing migrations identified
133
+ - User decision captured
134
+ - Old migrations removed (if recreate)
135
+
136
+ ## NEXT STEP:
137
+
138
+ → `step-02-create.md`
@@ -0,0 +1,144 @@
1
+ ---
2
+ name: step-02-create
3
+ description: Create migration with MCP naming
4
+ next_step: step-03-validate.md
5
+ ---
6
+
7
+ # Step 2: Create Migration
8
+
9
+ ## YOUR TASK:
10
+
11
+ Get migration description from user, call MCP for compliant name, and create migration.
12
+
13
+ **MANDATORY:** Use MCP `suggest_migration` for naming. NEVER hardcode.
14
+
15
+ **Previous step:** `step-01-check.md`
16
+
17
+ ---
18
+
19
+ ## EXECUTION SEQUENCE:
20
+
21
+ ### 1. Get Description from User
22
+
23
+ **If NOT force mode with predefined description:**
24
+
25
+ ```yaml
26
+ AskUserQuestion:
27
+ header: "Description"
28
+ question: "Short description for the migration (e.g., 'Add User Roles'):"
29
+ options:
30
+ - label: "Add..."
31
+ description: "Adding tables/columns"
32
+ - label: "Update..."
33
+ description: "Modifying structure"
34
+ - label: "Fix..."
35
+ description: "Schema correction"
36
+ - label: "Remove..."
37
+ description: "Deleting elements"
38
+ multiSelect: false
39
+ ```
40
+
41
+ **User can also provide free text (Other option).**
42
+
43
+ ```bash
44
+ # DESCRIPTION = user response or predefined value
45
+ # Examples: "Add User Roles", "Update Tenant Schema", "Fix Foreign Keys"
46
+
47
+ echo ""
48
+ echo "Description: $DESCRIPTION"
49
+ ```
50
+
51
+ ### 2. Call MCP for Migration Name (MANDATORY)
52
+
53
+ ```javascript
54
+ // DESCRIPTION = from user input (e.g., "Add User Roles")
55
+ // DBCONTEXT_TYPE = "core" or "extensions" (from detect_dbcontext)
56
+
57
+ const result = await mcp__smartstack__suggest_migration({
58
+ description: DESCRIPTION,
59
+ context: DBCONTEXT_TYPE // NEVER hardcode!
60
+ });
61
+
62
+ // Result example: core_v1.8.0_001_AddUserRoles
63
+ MIGRATION_NAME = result.migrationName;
64
+ ```
65
+
66
+ **FORBIDDEN:**
67
+ - Calculating name manually
68
+ - Hardcoding context as "core"
69
+ - Using wrong version format
70
+
71
+ ### 3. Display Migration Name
72
+
73
+ ```bash
74
+ echo ""
75
+ echo "Migration name: $MIGRATION_NAME"
76
+ echo "Context: $DBCONTEXT"
77
+ echo ""
78
+ ```
79
+
80
+ ### 4. Create Migration
81
+
82
+ ```bash
83
+ echo "Creating migration..."
84
+ echo ""
85
+
86
+ dotnet ef migrations add "$MIGRATION_NAME" \
87
+ --context "$DBCONTEXT" \
88
+ --project "$INFRA_PROJECT" \
89
+ --startup-project "$STARTUP_PROJECT" \
90
+ -o Persistence/Migrations \
91
+ --verbose
92
+ ```
93
+
94
+ ### 5. Verify Creation
95
+
96
+ ```bash
97
+ # Check files were created
98
+ MIGRATION_FILE="$MIGRATIONS_DIR/${MIGRATION_NAME}.cs"
99
+ DESIGNER_FILE="$MIGRATIONS_DIR/${MIGRATION_NAME}.Designer.cs"
100
+
101
+ if [ ! -f "$MIGRATION_FILE" ]; then
102
+ echo ""
103
+ echo "ERROR: Migration file not created"
104
+ echo "Expected: $MIGRATION_FILE"
105
+ exit 1
106
+ fi
107
+
108
+ echo ""
109
+ echo "Migration created:"
110
+ echo " $MIGRATION_FILE"
111
+ echo " $DESIGNER_FILE"
112
+ ```
113
+
114
+ ---
115
+
116
+ ## STATE OUTPUT:
117
+
118
+ | Variable | Description |
119
+ |----------|-------------|
120
+ | `{description}` | User-provided description |
121
+ | `{migration_name}` | Name from MCP |
122
+ | `{migration_file}` | Path to .cs file |
123
+
124
+ ---
125
+
126
+ ## ERROR HANDLING:
127
+
128
+ | Error | Resolution |
129
+ |-------|------------|
130
+ | MCP unavailable | Check connection, retry |
131
+ | Creation fails | Check dotnet ef output |
132
+ | File not created | Verify paths and permissions |
133
+
134
+ ---
135
+
136
+ ## SUCCESS CRITERIA:
137
+
138
+ - Description captured
139
+ - MCP called successfully
140
+ - Migration files created
141
+
142
+ ## NEXT STEP:
143
+
144
+ → `step-03-validate.md`