@atlashub/smartstack-cli 3.37.0 → 3.39.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/dist/index.js +16 -24
- package/dist/index.js.map +1 -1
- package/dist/mcp-entry.mjs +235 -265
- package/dist/mcp-entry.mjs.map +1 -1
- package/package.json +1 -1
- package/scripts/extract-api-endpoints.ts +5 -5
- package/scripts/generate-doc-with-mock-ui.ts +10 -17
- package/templates/agents/ba-reader.md +9 -9
- package/templates/agents/ba-writer.md +12 -15
- package/templates/agents/code-reviewer.md +1 -1
- package/templates/agents/docs-context-reader.md +1 -1
- package/templates/agents/efcore/scan.md +3 -1
- package/templates/agents/gitflow/commit.md +74 -0
- package/templates/agents/gitflow/finish.md +5 -2
- package/templates/agents/gitflow/init-clone.md +3 -3
- package/templates/agents/gitflow/init-validate.md +3 -2
- package/templates/agents/gitflow/merge.md +5 -4
- package/templates/agents/gitflow/pr.md +5 -4
- package/templates/agents/gitflow/start.md +37 -5
- package/templates/hooks/hooks.json +11 -0
- package/templates/hooks/wsl-dotnet-cleanup.sh +24 -0
- package/templates/mcp-scaffolding/frontend/nav-routes.ts.hbs +20 -20
- package/templates/mcp-scaffolding/frontend/routes.tsx.hbs +16 -24
- package/templates/mcp-scaffolding/migrations/seed-roles.cs.hbs +2 -2
- package/templates/skills/_resources/mcp-validate-documentation-spec.md +3 -3
- package/templates/skills/_shared.md +15 -17
- package/templates/skills/ai-prompt/SKILL.md +1 -1
- package/templates/skills/ai-prompt/steps/step-00-init.md +47 -0
- package/templates/skills/apex/SKILL.md +3 -4
- package/templates/skills/apex/_shared.md +10 -20
- package/templates/skills/apex/references/analysis-methods.md +141 -0
- package/templates/skills/apex/references/challenge-questions.md +1 -21
- package/templates/skills/apex/references/core-seed-data.md +35 -58
- package/templates/skills/apex/references/examine-build-validation.md +82 -0
- package/templates/skills/apex/references/execution-frontend-gates.md +177 -0
- package/templates/skills/apex/references/execution-frontend-patterns.md +105 -0
- package/templates/skills/apex/references/execution-layer1-rules.md +96 -0
- package/templates/skills/apex/references/initialization-challenge-flow.md +110 -0
- package/templates/skills/apex/references/planning-layer-mapping.md +151 -0
- package/templates/skills/apex/references/post-checks.md +145 -40
- package/templates/skills/apex/references/smartstack-api.md +35 -51
- package/templates/skills/apex/references/smartstack-frontend.md +18 -18
- package/templates/skills/apex/references/smartstack-layers.md +38 -62
- package/templates/skills/apex/steps/step-00-init.md +14 -26
- package/templates/skills/apex/steps/step-01-analyze.md +10 -143
- package/templates/skills/apex/steps/step-02-plan.md +10 -92
- package/templates/skills/apex/steps/step-03-execute.md +45 -252
- package/templates/skills/apex/steps/step-04-examine.md +14 -78
- package/templates/skills/apex/steps/step-05-deep-review.md +2 -2
- package/templates/skills/apex/steps/step-08-run-tests.md +1 -0
- package/templates/skills/application/SKILL.md +241 -242
- package/templates/skills/application/references/backend-controller-hierarchy.md +16 -16
- package/templates/skills/application/references/backend-seeding-and-dto-output.md +83 -0
- package/templates/skills/application/references/backend-table-prefix-mapping.md +79 -0
- package/templates/skills/application/references/backend-verification.md +1 -1
- package/templates/skills/application/references/frontend-i18n-and-output.md +67 -0
- package/templates/skills/application/references/frontend-route-naming.md +117 -0
- package/templates/skills/application/references/frontend-route-wiring-app-tsx.md +107 -0
- package/templates/skills/application/references/frontend-verification.md +12 -12
- package/templates/skills/application/references/init-parameter-detection.md +121 -0
- package/templates/skills/application/references/migration-checklist-troubleshooting.md +100 -0
- package/templates/skills/application/references/nav-fallback-procedure.md +199 -200
- package/templates/skills/application/references/provider-template.md +2 -6
- package/templates/skills/application/references/roles-client-project-handling.md +55 -0
- package/templates/skills/application/references/roles-fallback-procedure.md +149 -0
- package/templates/skills/application/references/test-coverage-requirements.md +213 -0
- package/templates/skills/application/references/test-frontend.md +3 -3
- package/templates/skills/application/steps/step-00-init.md +130 -260
- package/templates/skills/application/steps/step-01-navigation.md +170 -170
- package/templates/skills/application/steps/step-02-permissions.md +196 -196
- package/templates/skills/application/steps/step-03-roles.md +182 -339
- package/templates/skills/application/steps/step-03b-provider.md +133 -134
- package/templates/skills/application/steps/step-04-backend.md +174 -265
- package/templates/skills/application/steps/step-05-frontend.md +18 -144
- package/templates/skills/application/steps/step-06-migration.md +12 -60
- package/templates/skills/application/steps/step-07-tests.md +9 -76
- package/templates/skills/application/templates-backend.md +29 -27
- package/templates/skills/application/templates-frontend.md +49 -49
- package/templates/skills/application/templates-seed.md +57 -131
- package/templates/skills/business-analyse/SKILL.md +27 -30
- package/templates/skills/business-analyse/_architecture.md +6 -6
- package/templates/skills/business-analyse/_shared.md +60 -88
- package/templates/skills/business-analyse/questionnaire/04-data.md +3 -3
- package/templates/skills/business-analyse/questionnaire/06-security.md +1 -1
- package/templates/skills/business-analyse/questionnaire/13-cross-module.md +1 -1
- package/templates/skills/business-analyse/react/application-viewer.md +12 -12
- package/templates/skills/business-analyse/react/components.md +8 -12
- package/templates/skills/business-analyse/react/schema.md +836 -836
- package/templates/skills/business-analyse/references/agent-module-prompt.md +2 -3
- package/templates/skills/business-analyse/references/analysis-semantic-checks.md +190 -0
- package/templates/skills/business-analyse/references/cache-warming-strategy.md +2 -2
- package/templates/skills/business-analyse/references/cadrage-challenge-patterns.md +41 -0
- package/templates/skills/business-analyse/references/cadrage-coverage-matrix.md +74 -0
- package/templates/skills/business-analyse/references/cadrage-shared-modules.md +69 -0
- package/templates/skills/business-analyse/references/cadrage-structure-cards.md +1 -1
- package/templates/skills/business-analyse/references/compilation-structure-cards.md +297 -0
- package/templates/skills/business-analyse/references/consolidation-structural-checks.md +2 -2
- package/templates/skills/business-analyse/references/deploy-modes.md +5 -5
- package/templates/skills/business-analyse/references/detection-strategies.md +7 -7
- package/templates/skills/business-analyse/references/handoff-file-templates.md +14 -22
- package/templates/skills/business-analyse/references/handoff-mappings.md +4 -4
- package/templates/skills/business-analyse/references/handoff-seeddata-generation.md +312 -0
- package/templates/skills/business-analyse/references/init-schema-deployment.md +3 -3
- package/templates/skills/business-analyse/references/naming-conventions.md +22 -24
- package/templates/skills/business-analyse/references/prd-generation.md +2 -2
- package/templates/skills/business-analyse/references/review-data-mapping.md +2 -2
- package/templates/skills/business-analyse/references/robustness-checks.md +1 -1
- package/templates/skills/business-analyse/references/spec-auto-inference.md +3 -3
- package/templates/skills/business-analyse/references/team-orchestration.md +49 -6
- package/templates/skills/business-analyse/references/ui-dashboard-spec.md +1 -1
- package/templates/skills/business-analyse/references/ui-resource-cards.md +18 -18
- package/templates/skills/business-analyse/references/validate-incremental-html.md +2 -2
- package/templates/skills/business-analyse/references/validation-checklist.md +2 -2
- package/templates/skills/business-analyse/schemas/application-schema.json +4 -5
- package/templates/skills/business-analyse/schemas/project-schema.json +1 -6
- package/templates/skills/business-analyse/schemas/sections/metadata-schema.json +2 -3
- package/templates/skills/business-analyse/schemas/sections/specification-schema.json +4 -4
- package/templates/skills/business-analyse/steps/step-00-init.md +8 -17
- package/templates/skills/business-analyse/steps/step-01-cadrage.md +35 -198
- package/templates/skills/business-analyse/steps/step-01b-applications.md +16 -20
- package/templates/skills/business-analyse/steps/step-02-decomposition.md +1 -1
- package/templates/skills/business-analyse/steps/step-03a1-setup.md +4 -4
- package/templates/skills/business-analyse/steps/step-03a2-analysis.md +1 -1
- package/templates/skills/business-analyse/steps/step-03b-ui.md +4 -4
- package/templates/skills/business-analyse/steps/step-03c-compile.md +66 -140
- package/templates/skills/business-analyse/steps/step-03d-validate.md +2 -2
- package/templates/skills/business-analyse/steps/step-04a-collect.md +2 -2
- package/templates/skills/business-analyse/steps/step-04b-analyze.md +42 -160
- package/templates/skills/business-analyse/steps/step-04c-decide.md +1 -1
- package/templates/skills/business-analyse/steps/step-05a-handoff.md +74 -104
- package/templates/skills/business-analyse/steps/step-05b-deploy.md +13 -11
- package/templates/skills/business-analyse/steps/step-06-review.md +3 -3
- package/templates/skills/business-analyse/templates/tpl-frd.md +13 -13
- package/templates/skills/business-analyse/templates/tpl-handoff.md +12 -12
- package/templates/skills/business-analyse/templates/tpl-progress.md +1 -1
- package/templates/skills/business-analyse/templates-frd.md +25 -25
- package/templates/skills/business-analyse/templates-react.md +15 -21
- package/templates/skills/controller/SKILL.md +1 -1
- package/templates/skills/controller/postman-templates.md +1 -1
- package/templates/skills/controller/references/controller-code-templates.md +2 -2
- package/templates/skills/controller/references/mcp-scaffold-workflow.md +209 -0
- package/templates/skills/controller/references/permission-sync-templates.md +13 -16
- package/templates/skills/controller/steps/step-00-init.md +11 -11
- package/templates/skills/controller/steps/step-03-generate.md +64 -103
- package/templates/skills/controller/templates.md +67 -71
- package/templates/skills/debug/SKILL.md +13 -218
- package/templates/skills/debug/steps/step-00-init.md +57 -0
- package/templates/skills/debug/steps/step-01-analyze.md +219 -0
- package/templates/skills/debug/steps/step-02-resolve.md +85 -0
- package/templates/skills/documentation/SKILL.md +49 -345
- package/templates/skills/documentation/data-schema.md +11 -8
- package/templates/skills/documentation/steps/step-00-init.md +70 -0
- package/templates/skills/documentation/steps/step-01-scan.md +113 -0
- package/templates/skills/documentation/steps/step-02-generate.md +231 -0
- package/templates/skills/documentation/steps/step-03-validate.md +238 -0
- package/templates/skills/documentation/templates.md +480 -322
- package/templates/skills/efcore/SKILL.md +1 -1
- package/templates/skills/efcore/references/both-contexts.md +32 -0
- package/templates/skills/efcore/references/database-operations.md +67 -0
- package/templates/skills/efcore/references/destructive-operations.md +38 -0
- package/templates/skills/efcore/references/reset-operations.md +81 -0
- package/templates/skills/efcore/references/seed-methods.md +86 -0
- package/templates/skills/efcore/references/shared-init-functions.md +250 -0
- package/templates/skills/efcore/references/sql-objects-injection.md +61 -0
- package/templates/skills/efcore/references/troubleshooting.md +81 -0
- package/templates/skills/efcore/steps/db/step-deploy.md +1 -32
- package/templates/skills/efcore/steps/db/step-reset.md +7 -103
- package/templates/skills/efcore/steps/db/step-seed.md +10 -132
- package/templates/skills/efcore/steps/db/step-status.md +5 -44
- package/templates/skills/efcore/steps/migration/step-02-create.md +1 -14
- package/templates/skills/efcore/steps/migration/step-03-validate.md +8 -62
- package/templates/skills/efcore/steps/rebase-snapshot/step-03-create.md +1 -57
- package/templates/skills/efcore/steps/shared/step-00-init.md +11 -254
- package/templates/skills/efcore/steps/squash/step-03-create.md +1 -58
- package/templates/skills/feature-full/SKILL.md +1 -1
- package/templates/skills/feature-full/steps/step-00-init.md +57 -0
- package/templates/skills/feature-full/steps/step-01-implementation.md +1 -1
- package/templates/skills/gitflow/SKILL.md +28 -5
- package/templates/skills/gitflow/_shared.md +109 -12
- package/templates/skills/gitflow/phases/abort.md +4 -0
- package/templates/skills/gitflow/phases/cleanup.md +4 -0
- package/templates/skills/gitflow/references/commit-message-generation.md +58 -0
- package/templates/skills/gitflow/references/commit-migration-validation.md +49 -0
- package/templates/skills/gitflow/references/finish-cleanup.md +55 -0
- package/templates/skills/gitflow/references/finish-version-bumping.md +45 -0
- package/templates/skills/gitflow/references/init-environment-detection.md +41 -0
- package/templates/skills/gitflow/references/init-questions.md +185 -0
- package/templates/skills/gitflow/references/init-structure-creation.md +75 -0
- package/templates/skills/gitflow/references/init-version-detection.md +21 -0
- package/templates/skills/gitflow/references/init-workspace-detection.md +43 -0
- package/templates/skills/gitflow/references/merge-ci-status.md +36 -0
- package/templates/skills/gitflow/references/merge-execution.md +62 -0
- package/templates/skills/gitflow/references/merge-pr-context.md +76 -0
- package/templates/skills/gitflow/references/pr-build-checks.md +60 -0
- package/templates/skills/gitflow/references/pr-generation.md +58 -0
- package/templates/skills/gitflow/references/start-branch-normalization.md +28 -0
- package/templates/skills/gitflow/references/start-worktree-creation.md +50 -0
- package/templates/skills/gitflow/references/sync-push-verify.md +44 -0
- package/templates/skills/gitflow/references/sync-rebase-conflicts.md +38 -0
- package/templates/skills/gitflow/steps/step-commit.md +12 -91
- package/templates/skills/gitflow/steps/step-finish.md +15 -159
- package/templates/skills/gitflow/steps/step-init.md +24 -326
- package/templates/skills/gitflow/steps/step-merge.md +17 -176
- package/templates/skills/gitflow/steps/step-pr.md +10 -116
- package/templates/skills/gitflow/steps/step-start.md +16 -109
- package/templates/skills/gitflow/steps/step-sync.md +6 -69
- package/templates/skills/ralph-loop/SKILL.md +6 -0
- package/templates/skills/ralph-loop/references/category-completeness.md +185 -0
- package/templates/skills/ralph-loop/references/compact-loop.md +1 -1
- package/templates/skills/ralph-loop/references/init-resume-recovery.md +127 -0
- package/templates/skills/ralph-loop/references/module-transition.md +151 -0
- package/templates/skills/ralph-loop/references/multi-module-queue.md +171 -0
- package/templates/skills/ralph-loop/references/parallel-execution.md +246 -0
- package/templates/skills/ralph-loop/references/task-transform-legacy.md +6 -9
- package/templates/skills/ralph-loop/references/team-orchestration.md +45 -3
- package/templates/skills/ralph-loop/steps/step-00-init.md +36 -109
- package/templates/skills/ralph-loop/steps/step-01-task.md +15 -163
- package/templates/skills/ralph-loop/steps/step-02-execute.md +8 -154
- package/templates/skills/ralph-loop/steps/step-04-check.md +20 -73
- package/templates/skills/review-code/references/owasp-api-top10.md +5 -5
- package/templates/skills/review-code/references/smartstack-conventions.md +568 -568
- package/templates/skills/validate-feature/references/api-smoke-tests.md +140 -0
- package/templates/skills/validate-feature/references/db-validation-checks.md +180 -0
- package/templates/skills/validate-feature/steps/step-01-compile.md +1 -3
- package/templates/skills/validate-feature/steps/step-04-api-smoke.md +34 -145
- package/templates/skills/validate-feature/steps/step-05-db-validation.md +74 -260
- package/templates/skills/workflow/SKILL.md +1 -1
- package/templates/skills/workflow/steps/step-00-init.md +57 -0
|
@@ -16,145 +16,18 @@ Detect EF Core project structure, identify DbContext (Core vs Extensions), and l
|
|
|
16
16
|
|
|
17
17
|
## EXECUTION SEQUENCE:
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
Load all helper functions from: `references/shared-init-functions.md`
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
This includes:
|
|
22
|
+
- `ensure_dotnet_ef()` - Platform-aware dotnet-ef PATH fix
|
|
23
|
+
- `detect_efcore_project()` - Find EF Core project
|
|
24
|
+
- `detect_dbcontext()` - Detect Core vs Extensions
|
|
25
|
+
- `detect_environment()` - Load environment configuration
|
|
26
|
+
- `determine_base_branch()` - Determine GitFlow branch
|
|
27
|
+
- `block_production()` - Prevent production deployments
|
|
28
|
+
- `run_for_contexts()` - Helper for dual context execution
|
|
23
29
|
|
|
24
|
-
|
|
25
|
-
ensure_dotnet_ef() {
|
|
26
|
-
# Quick check: already available?
|
|
27
|
-
if dotnet ef --version &>/dev/null; then
|
|
28
|
-
DOTNET_EF_VERSION=$(dotnet ef --version 2>/dev/null)
|
|
29
|
-
echo "dotnet-ef: $DOTNET_EF_VERSION"
|
|
30
|
-
return 0
|
|
31
|
-
fi
|
|
32
|
-
|
|
33
|
-
echo "dotnet-ef not on PATH, attempting platform-aware fix..."
|
|
34
|
-
|
|
35
|
-
# Try all known .NET global tools locations
|
|
36
|
-
# - $USERPROFILE/.dotnet/tools → Windows via Git Bash (USERPROFILE=C:\Users\xxx)
|
|
37
|
-
# - $HOME/.dotnet/tools → Linux/macOS or Git Bash fallback
|
|
38
|
-
# - $LOCALAPPDATA/Microsoft/dotnet/tools → Windows alternate location
|
|
39
|
-
for TOOLS_DIR in \
|
|
40
|
-
"$USERPROFILE/.dotnet/tools" \
|
|
41
|
-
"$HOME/.dotnet/tools" \
|
|
42
|
-
"$LOCALAPPDATA/Microsoft/dotnet/tools"; do
|
|
43
|
-
if [ -n "$TOOLS_DIR" ] && [ -d "$TOOLS_DIR" ]; then
|
|
44
|
-
export PATH="$TOOLS_DIR:$PATH"
|
|
45
|
-
echo " PATH += $TOOLS_DIR"
|
|
46
|
-
fi
|
|
47
|
-
done
|
|
48
|
-
|
|
49
|
-
# Verify after PATH fix
|
|
50
|
-
if dotnet ef --version &>/dev/null; then
|
|
51
|
-
DOTNET_EF_VERSION=$(dotnet ef --version 2>/dev/null)
|
|
52
|
-
echo "dotnet-ef: $DOTNET_EF_VERSION (found after PATH fix)"
|
|
53
|
-
return 0
|
|
54
|
-
fi
|
|
55
|
-
|
|
56
|
-
echo "ERROR: dotnet-ef not available"
|
|
57
|
-
echo "Install with: dotnet tool install --global dotnet-ef"
|
|
58
|
-
echo ""
|
|
59
|
-
echo "If installed but not found, check:"
|
|
60
|
-
echo " Windows: %USERPROFILE%\\.dotnet\\tools must be in PATH"
|
|
61
|
-
echo " Linux: ~/.dotnet/tools must be in PATH"
|
|
62
|
-
exit 1
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
ensure_dotnet_ef
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
**IMPORTANT — WSL pitfall:**
|
|
69
|
-
If the shell resolves `$HOME` to `/home/{user}` (WSL path) instead of `/c/Users/{user}` (Git Bash),
|
|
70
|
-
the .NET SDK may not be found even if `dotnet-ef` is. Use `$USERPROFILE` first on Windows.
|
|
71
|
-
|
|
72
|
-
---
|
|
73
|
-
|
|
74
|
-
### 1. Detect EF Core Project
|
|
75
|
-
|
|
76
|
-
```bash
|
|
77
|
-
detect_efcore_project() {
|
|
78
|
-
# Find project with EF Core reference
|
|
79
|
-
CSPROJ=$(find . -name "*.csproj" -exec grep -l "Microsoft.EntityFrameworkCore" {} \; | head -1)
|
|
80
|
-
|
|
81
|
-
if [ -z "$CSPROJ" ]; then
|
|
82
|
-
echo "ERROR: No EF Core project found"
|
|
83
|
-
exit 1
|
|
84
|
-
fi
|
|
85
|
-
|
|
86
|
-
PROJECT_DIR=$(dirname "$CSPROJ")
|
|
87
|
-
PROJECT_NAME=$(basename "$CSPROJ" .csproj)
|
|
88
|
-
MIGRATIONS_DIR="$PROJECT_DIR/Persistence/Migrations"
|
|
89
|
-
|
|
90
|
-
# Find startup and infrastructure projects
|
|
91
|
-
STARTUP_PROJECT=$(find . -name "*.Api.csproj" -o -name "*Web.csproj" | head -1)
|
|
92
|
-
INFRA_PROJECT=$(find . -name "*Infrastructure.csproj" | head -1)
|
|
93
|
-
[ -z "$INFRA_PROJECT" ] && INFRA_PROJECT="$CSPROJ"
|
|
94
|
-
|
|
95
|
-
echo "Project: $PROJECT_NAME"
|
|
96
|
-
echo "Migrations: $MIGRATIONS_DIR"
|
|
97
|
-
}
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
### 2. Detect DbContext (Core vs Extensions)
|
|
101
|
-
|
|
102
|
-
```bash
|
|
103
|
-
detect_dbcontext() {
|
|
104
|
-
# Priority 1: SmartStack.Domain exists → SmartStack source project (Core only)
|
|
105
|
-
if find . -type d -name "SmartStack.Domain" | grep -q .; then
|
|
106
|
-
DBCONTEXT="CoreDbContext"
|
|
107
|
-
DBCONTEXT_TYPE="core"
|
|
108
|
-
SCHEMA="core"
|
|
109
|
-
RUN_BOTH=false
|
|
110
|
-
echo "DbContext: CoreDbContext (SmartStack.Domain found)"
|
|
111
|
-
return
|
|
112
|
-
fi
|
|
113
|
-
|
|
114
|
-
# Priority 2: Client project with SmartStack NuGet → BOTH contexts
|
|
115
|
-
# Detect: csproj files that have a PackageReference to SmartStack (not ProjectReference)
|
|
116
|
-
# This identifies client projects created via `ss init` that consume SmartStack as NuGet
|
|
117
|
-
if find . -name "*.csproj" -exec grep -ql "PackageReference.*SmartStack" {} \; 2>/dev/null; then
|
|
118
|
-
DBCONTEXT="CoreDbContext"
|
|
119
|
-
DBCONTEXT_TYPE="both"
|
|
120
|
-
SCHEMA="core"
|
|
121
|
-
RUN_BOTH=true
|
|
122
|
-
echo "DbContext: Both (Core from SmartStack NuGet + Extensions local)"
|
|
123
|
-
echo " Deploy order: CoreDbContext → ExtensionsDbContext"
|
|
124
|
-
return
|
|
125
|
-
fi
|
|
126
|
-
|
|
127
|
-
# Priority 3: Scan for DbContext in code
|
|
128
|
-
CORE_CTX=$(find . -name "*.cs" -exec grep -l "CoreDbContext" {} \; 2>/dev/null | head -1)
|
|
129
|
-
EXT_CTX=$(find . -name "*.cs" -exec grep -l "ExtensionsDbContext" {} \; 2>/dev/null | head -1)
|
|
130
|
-
|
|
131
|
-
if [ -n "$CORE_CTX" ] && [ -n "$EXT_CTX" ]; then
|
|
132
|
-
DBCONTEXT="CoreDbContext"
|
|
133
|
-
DBCONTEXT_TYPE="both"
|
|
134
|
-
SCHEMA="core"
|
|
135
|
-
RUN_BOTH=true
|
|
136
|
-
echo "DbContext: Both (CoreDbContext + ExtensionsDbContext found)"
|
|
137
|
-
elif [ -n "$CORE_CTX" ] && [ -z "$EXT_CTX" ]; then
|
|
138
|
-
DBCONTEXT="CoreDbContext"
|
|
139
|
-
DBCONTEXT_TYPE="core"
|
|
140
|
-
SCHEMA="core"
|
|
141
|
-
RUN_BOTH=false
|
|
142
|
-
elif [ -z "$CORE_CTX" ] && [ -n "$EXT_CTX" ]; then
|
|
143
|
-
DBCONTEXT="ExtensionsDbContext"
|
|
144
|
-
DBCONTEXT_TYPE="extensions"
|
|
145
|
-
SCHEMA="extensions"
|
|
146
|
-
RUN_BOTH=false
|
|
147
|
-
else
|
|
148
|
-
# Priority 4: Ask user
|
|
149
|
-
DBCONTEXT=""
|
|
150
|
-
DBCONTEXT_TYPE=""
|
|
151
|
-
SCHEMA=""
|
|
152
|
-
RUN_BOTH=false
|
|
153
|
-
fi
|
|
154
|
-
}
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
### 3. Ask User if DbContext Unknown
|
|
30
|
+
### User Prompt (if DbContext Unknown)
|
|
158
31
|
|
|
159
32
|
**If `{dbcontext}` is empty after detection:**
|
|
160
33
|
|
|
@@ -188,123 +61,7 @@ if (answer === "CoreDbContext") {
|
|
|
188
61
|
}
|
|
189
62
|
```
|
|
190
63
|
|
|
191
|
-
###
|
|
192
|
-
|
|
193
|
-
```bash
|
|
194
|
-
detect_environment() {
|
|
195
|
-
API_DIR=$(find . -type d -name "*.Api" | head -1)
|
|
196
|
-
[ -z "$API_DIR" ] && API_DIR="src/SmartStack.Api"
|
|
197
|
-
|
|
198
|
-
# Priority: --env flag > appsettings.Local.json > error
|
|
199
|
-
if [ -n "$ENV_FLAG" ]; then
|
|
200
|
-
CONFIG_FILE="$API_DIR/appsettings.${ENV_FLAG}.json"
|
|
201
|
-
elif [ -f "$API_DIR/appsettings.Local.json" ]; then
|
|
202
|
-
CONFIG_FILE="$API_DIR/appsettings.Local.json"
|
|
203
|
-
SELECTED_ENV="Local"
|
|
204
|
-
else
|
|
205
|
-
echo "ERROR: No appsettings.Local.json found"
|
|
206
|
-
echo "Create one or use --env flag"
|
|
207
|
-
exit 1
|
|
208
|
-
fi
|
|
209
|
-
|
|
210
|
-
echo "Environment: $SELECTED_ENV"
|
|
211
|
-
echo "Config: $CONFIG_FILE"
|
|
212
|
-
}
|
|
213
|
-
```
|
|
214
|
-
|
|
215
|
-
### 5. Determine Base Branch (for squash/rebase)
|
|
216
|
-
|
|
217
|
-
```bash
|
|
218
|
-
determine_base_branch() {
|
|
219
|
-
CURRENT_BRANCH=$(git branch --show-current)
|
|
220
|
-
|
|
221
|
-
case "$CURRENT_BRANCH" in
|
|
222
|
-
feature/*)
|
|
223
|
-
BASE_BRANCH="develop"
|
|
224
|
-
BRANCH_TYPE="feature"
|
|
225
|
-
;;
|
|
226
|
-
release/*)
|
|
227
|
-
BASE_BRANCH="main"
|
|
228
|
-
BRANCH_TYPE="release"
|
|
229
|
-
;;
|
|
230
|
-
hotfix/*)
|
|
231
|
-
BASE_BRANCH="main"
|
|
232
|
-
BRANCH_TYPE="hotfix"
|
|
233
|
-
;;
|
|
234
|
-
develop)
|
|
235
|
-
BASE_BRANCH="main"
|
|
236
|
-
BRANCH_TYPE="develop"
|
|
237
|
-
;;
|
|
238
|
-
main|master)
|
|
239
|
-
echo "ERROR: Cannot run on main/master branch"
|
|
240
|
-
exit 1
|
|
241
|
-
;;
|
|
242
|
-
*)
|
|
243
|
-
BASE_BRANCH="develop"
|
|
244
|
-
BRANCH_TYPE="unknown"
|
|
245
|
-
;;
|
|
246
|
-
esac
|
|
247
|
-
|
|
248
|
-
echo "Branch: $CURRENT_BRANCH ($BRANCH_TYPE)"
|
|
249
|
-
echo "Base: $BASE_BRANCH"
|
|
250
|
-
}
|
|
251
|
-
```
|
|
252
|
-
|
|
253
|
-
### 6. Block Production
|
|
254
|
-
|
|
255
|
-
```bash
|
|
256
|
-
block_production() {
|
|
257
|
-
# Check for production indicators (case-insensitive)
|
|
258
|
-
if grep -qi '"Production"' "$CONFIG_FILE" 2>/dev/null; then
|
|
259
|
-
echo "BLOCKED: Production environment detected in $CONFIG_FILE"
|
|
260
|
-
exit 1
|
|
261
|
-
fi
|
|
262
|
-
|
|
263
|
-
# Case-insensitive database name check
|
|
264
|
-
DB_LOWER=$(echo "$DATABASE_NAME" | tr '[:upper:]' '[:lower:]')
|
|
265
|
-
if [[ "$DB_LOWER" == *"prod"* ]] || [[ "$DB_LOWER" == *"production"* ]]; then
|
|
266
|
-
echo "BLOCKED: Production database detected ($DATABASE_NAME)"
|
|
267
|
-
exit 1
|
|
268
|
-
fi
|
|
269
|
-
|
|
270
|
-
# Environment name check (case-insensitive)
|
|
271
|
-
ENV_LOWER=$(echo "$SELECTED_ENV" | tr '[:upper:]' '[:lower:]')
|
|
272
|
-
if [[ "$ENV_LOWER" == "production" ]] || [[ "$ENV_LOWER" == "prod" ]]; then
|
|
273
|
-
echo "BLOCKED: Production environment selected ($SELECTED_ENV)"
|
|
274
|
-
exit 1
|
|
275
|
-
fi
|
|
276
|
-
}
|
|
277
|
-
```
|
|
278
|
-
|
|
279
|
-
### 7. Dual Context Helper
|
|
280
|
-
|
|
281
|
-
```bash
|
|
282
|
-
# Helper for steps that need to run for both contexts when RUN_BOTH=true
|
|
283
|
-
# Usage: run_for_contexts "command_or_function"
|
|
284
|
-
# Executes with CoreDbContext first, then ExtensionsDbContext
|
|
285
|
-
# Maintains deploy order constraint: Core MUST run first
|
|
286
|
-
|
|
287
|
-
run_for_contexts() {
|
|
288
|
-
if [ "$RUN_BOTH" = "true" ]; then
|
|
289
|
-
echo "=== Running for CoreDbContext (core schema) ==="
|
|
290
|
-
DBCONTEXT="CoreDbContext"
|
|
291
|
-
DBCONTEXT_TYPE="core"
|
|
292
|
-
SCHEMA="core"
|
|
293
|
-
eval "$1"
|
|
294
|
-
|
|
295
|
-
echo ""
|
|
296
|
-
echo "=== Running for ExtensionsDbContext (extensions schema) ==="
|
|
297
|
-
DBCONTEXT="ExtensionsDbContext"
|
|
298
|
-
DBCONTEXT_TYPE="extensions"
|
|
299
|
-
SCHEMA="extensions"
|
|
300
|
-
eval "$1"
|
|
301
|
-
else
|
|
302
|
-
eval "$1"
|
|
303
|
-
fi
|
|
304
|
-
}
|
|
305
|
-
```
|
|
306
|
-
|
|
307
|
-
### 8. Display Summary
|
|
64
|
+
### Display Summary
|
|
308
65
|
|
|
309
66
|
```
|
|
310
67
|
EF CORE CONTEXT
|
|
@@ -135,64 +135,7 @@ echo " Down methods: $DOWN_METHODS"
|
|
|
135
135
|
|
|
136
136
|
### 6. Inject SQL Objects (Functions, Views, SP)
|
|
137
137
|
|
|
138
|
-
|
|
139
|
-
SQL source scripts are in `Persistence/SqlObjects/` (Embedded Resources).
|
|
140
|
-
After a squash, they must be re-injected into the consolidated migration.
|
|
141
|
-
|
|
142
|
-
```bash
|
|
143
|
-
# Check if SqlObjects folder exists with .sql files
|
|
144
|
-
SQL_OBJECTS_DIR="$INFRA_PROJECT_DIR/Persistence/SqlObjects"
|
|
145
|
-
SQL_FILES=$(find "$SQL_OBJECTS_DIR" -name "*.sql" 2>/dev/null | wc -l)
|
|
146
|
-
|
|
147
|
-
if [ "$SQL_FILES" -gt 0 ]; then
|
|
148
|
-
echo ""
|
|
149
|
-
echo "Found $SQL_FILES SQL object(s) in SqlObjects/"
|
|
150
|
-
echo "Injecting SqlObjectHelper.ApplyAll(migrationBuilder) into migration..."
|
|
151
|
-
|
|
152
|
-
# Validate migration file path before sed operations (prevent path injection)
|
|
153
|
-
if [ ! -f "$MIGRATION_FILE" ]; then
|
|
154
|
-
echo "ERROR: Migration file not found: $MIGRATION_FILE"
|
|
155
|
-
exit 1
|
|
156
|
-
fi
|
|
157
|
-
if ! echo "$MIGRATION_FILE" | grep -qE '\.cs$'; then
|
|
158
|
-
echo "ERROR: Invalid migration file path (not .cs): $MIGRATION_FILE"
|
|
159
|
-
exit 1
|
|
160
|
-
fi
|
|
161
|
-
|
|
162
|
-
# Add using directive if not present
|
|
163
|
-
if ! grep -q "using SmartStack.Infrastructure.Persistence.SqlObjects;" "$MIGRATION_FILE"; then
|
|
164
|
-
sed -i '1s/^/using SmartStack.Infrastructure.Persistence.SqlObjects;\n/' "$MIGRATION_FILE"
|
|
165
|
-
fi
|
|
166
|
-
|
|
167
|
-
# Add SqlObjectHelper.ApplyAll at the end of Up() method
|
|
168
|
-
# Find the closing brace of Up() and insert before it
|
|
169
|
-
sed -i '/protected override void Up/,/^ }/ {
|
|
170
|
-
/^ }/ i\
|
|
171
|
-
\ // Apply SQL objects (TVF, Views, SP) from embedded resources\
|
|
172
|
-
\ SqlObjectHelper.ApplyAll(migrationBuilder);
|
|
173
|
-
}' "$MIGRATION_FILE"
|
|
174
|
-
|
|
175
|
-
# Verify injection succeeded (fallback to manual step if sed pattern didn't match)
|
|
176
|
-
if ! grep -q "SqlObjectHelper.ApplyAll" "$MIGRATION_FILE"; then
|
|
177
|
-
echo "WARNING: Automatic injection failed (indentation pattern may differ)"
|
|
178
|
-
echo ""
|
|
179
|
-
echo "MANUAL STEP REQUIRED: Add these lines inside the Up() method before the closing brace:"
|
|
180
|
-
echo ' using SmartStack.Infrastructure.Persistence.SqlObjects;'
|
|
181
|
-
echo ' ...'
|
|
182
|
-
echo ' SqlObjectHelper.ApplyAll(migrationBuilder);'
|
|
183
|
-
echo ""
|
|
184
|
-
echo "File: $MIGRATION_FILE"
|
|
185
|
-
else
|
|
186
|
-
echo " SqlObjectHelper.ApplyAll(migrationBuilder) injected"
|
|
187
|
-
fi
|
|
188
|
-
find "$SQL_OBJECTS_DIR" -name "*.sql" -exec basename {} \; | while read f; do
|
|
189
|
-
echo " - $f"
|
|
190
|
-
done
|
|
191
|
-
else
|
|
192
|
-
echo ""
|
|
193
|
-
echo "No SQL objects found in SqlObjects/ - skipping injection"
|
|
194
|
-
fi
|
|
195
|
-
```
|
|
138
|
+
Load: `references/sql-objects-injection.md`
|
|
196
139
|
|
|
197
140
|
---
|
|
198
141
|
|
|
@@ -43,7 +43,7 @@ DOMAIN -> APPLICATION -> INFRASTRUCTURE -> API -> WEB
|
|
|
43
43
|
|
|
44
44
|
## Phases 2-7: Implementation
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
Start with [steps/step-00-init.md](steps/step-00-init.md) to analyze requirements and existing patterns, then proceed to [steps/step-01-implementation.md](steps/step-01-implementation.md) for detailed code templates covering:
|
|
47
47
|
- Phase 2: Domain (Entity + Factory + Behaviors + Enum)
|
|
48
48
|
- Phase 3: Application (Interface + DTOs + Permissions)
|
|
49
49
|
- Phase 4: Infrastructure (EF Config + Service + DI)
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# Step 0: Initialization
|
|
2
|
+
|
|
3
|
+
## YOUR TASK
|
|
4
|
+
Gather requirements and analyze existing code patterns before implementing a complete full-stack feature.
|
|
5
|
+
|
|
6
|
+
## EXECUTION SEQUENCE
|
|
7
|
+
|
|
8
|
+
### 1. Identify Feature Scope
|
|
9
|
+
- What is the main entity/aggregate? (e.g., Product, Invoice, Support Ticket)
|
|
10
|
+
- What are the CRUD operations required? (Create, Read, Update, Delete, Archive)
|
|
11
|
+
- What business rules apply? (validations, state transitions, constraints)
|
|
12
|
+
- What user permissions are needed? (who can create/edit/delete/view)
|
|
13
|
+
- What notifications/workflows are required? (emails, webhooks, automation)
|
|
14
|
+
- Does AI play a role? (content generation, analysis, validation)
|
|
15
|
+
|
|
16
|
+
### 2. Analyze Existing Code Patterns
|
|
17
|
+
- Review `Domain/` for similar entity structures, factories, and behaviors
|
|
18
|
+
- Check `Application/` for existing service interfaces and DTOs
|
|
19
|
+
- Examine `Infrastructure/` for EF Core configurations and patterns
|
|
20
|
+
- Look at `API/Controllers/` for authorization and RequirePermission attributes
|
|
21
|
+
- Study `web/` for similar pages, forms, and i18n implementations
|
|
22
|
+
- Identify reusable components and patterns to follow
|
|
23
|
+
|
|
24
|
+
### 3. Define Data Model
|
|
25
|
+
- Entity properties and types
|
|
26
|
+
- Enums for status, types, and classifications
|
|
27
|
+
- Relationships (OneToMany, ManyToMany, etc.)
|
|
28
|
+
- Audit requirements (CreatedAt, CreatedBy, ModifiedAt, ModifiedBy)
|
|
29
|
+
- Soft delete or permanent delete?
|
|
30
|
+
|
|
31
|
+
### 4. Plan Implementation Phases
|
|
32
|
+
- **Phase 2:** Domain entity, factory method, behaviors, enums, IAuditableEntity
|
|
33
|
+
- **Phase 3:** Application service interface, DTOs, permissions (create + assign permissions files)
|
|
34
|
+
- **Phase 4:** Infrastructure (EF Config, concrete service, DI registration, DbSet, migration)
|
|
35
|
+
- **Phase 5:** API controller with Authorize, RequirePermission, ProducesResponseType
|
|
36
|
+
- **Phase 6:** Frontend (API client, custom hook with SignalR, page, form, routing, i18n for 4 languages)
|
|
37
|
+
- **Phase 7:** Integrations (notifications, workflows, AI if applicable)
|
|
38
|
+
|
|
39
|
+
### 5. Validate Against Architecture Rules
|
|
40
|
+
- Confirm layered architecture is followed (no frontend-to-DB shortcuts)
|
|
41
|
+
- Verify entity factory methods are used (no direct constructors in services)
|
|
42
|
+
- Check permissions split across 2 files (Create/List/Read/Update/Delete vs Assign)
|
|
43
|
+
- Plan SignalR hooks for real-time updates
|
|
44
|
+
- Define ProducesResponseType for all endpoints
|
|
45
|
+
- Plan i18n for English, French, Italian, German
|
|
46
|
+
|
|
47
|
+
## SUCCESS METRICS
|
|
48
|
+
- Feature scope clearly defined and bounded
|
|
49
|
+
- All required CRUD operations identified
|
|
50
|
+
- Business rules documented
|
|
51
|
+
- Permissions mapped to roles
|
|
52
|
+
- Implementation plan with all 7 phases outlined
|
|
53
|
+
- Existing code patterns understood and will be followed
|
|
54
|
+
- Data model defined with relationships and audit requirements
|
|
55
|
+
|
|
56
|
+
## NEXT STEP
|
|
57
|
+
Proceed to `./step-01-implementation.md` to execute all phases (Domain, Application, Infrastructure, API, Frontend, Integrations) with code templates and orchestration of child skills.
|
|
@@ -30,7 +30,7 @@ public record {Entity}Dto(Guid Id, string Name, string Status, DateTime CreatedA
|
|
|
30
30
|
public record Create{Entity}Request(string Name, string? Description);
|
|
31
31
|
|
|
32
32
|
// Permissions.cs + PermissionConfiguration.cs (2 files!)
|
|
33
|
-
public const string View = "{
|
|
33
|
+
public const string View = "{area}.{module}.read";
|
|
34
34
|
```
|
|
35
35
|
|
|
36
36
|
## Phase 4: Infrastructure
|
|
@@ -6,11 +6,12 @@ disable-model-invocation: true
|
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
## Current state (auto-injected)
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
9
|
+
- Preflight: !`if [ -f .git ] && grep -q '^gitdir: [A-Za-z]:' .git 2>/dev/null && grep -qi microsoft /proc/version 2>/dev/null; then p=$(sed 's/^gitdir: //' .git | tr -d '\r\n'); d=$(echo "${p:0:1}" | tr A-Z a-z); r="${p:2}"; r="${r//\\//}"; printf 'gitdir: %s\n' "$(realpath -m --relative-to="$(pwd)" "/mnt/$d$r")" > .git && echo "repaired"; else echo "ok"; fi`
|
|
10
|
+
- Branch: !`git branch --show-current 2>/dev/null || echo "UNAVAILABLE"`
|
|
11
|
+
- Status: !`git status --short 2>/dev/null || echo "UNAVAILABLE"`
|
|
12
|
+
- Recent commits: !`git log --oneline -5 2>/dev/null || echo "UNAVAILABLE"`
|
|
13
|
+
- Worktrees: !`git worktree list 2>/dev/null || echo "UNAVAILABLE (run preflight_git_check from _shared.md)"`
|
|
14
|
+
- Config: !`cat .claude/gitflow/config.json 2>/dev/null || echo "no config found"`
|
|
14
15
|
|
|
15
16
|
<objective>
|
|
16
17
|
Execute GitFlow workflows with automatic versioning, worktree management, and EF Core migration validation. Uses progressive step loading to minimize context and maintain fresh state at each phase.
|
|
@@ -316,6 +317,28 @@ Auto mode: {auto_mode}
|
|
|
316
317
|
|
|
317
318
|
</task_agents>
|
|
318
319
|
|
|
320
|
+
<worktree_repair>
|
|
321
|
+
|
|
322
|
+
**MANDATORY PRE-FLIGHT:** Before routing to any step or agent, run `preflight_git_check` (from `_shared.md` PREFLIGHT_GIT_CHECK section). This ensures git is accessible and repairs cross-platform worktree paths (Windows ↔ WSL).
|
|
323
|
+
|
|
324
|
+
**When to trigger:** If any auto-injected state shows "UNAVAILABLE", or if the Preflight line shows "repaired".
|
|
325
|
+
|
|
326
|
+
**Execution:**
|
|
327
|
+
```bash
|
|
328
|
+
# 1. Detect platform
|
|
329
|
+
detect_platform
|
|
330
|
+
|
|
331
|
+
# 2. Run preflight (repairs .git file + .bare/worktrees/*/gitdir)
|
|
332
|
+
preflight_git_check
|
|
333
|
+
|
|
334
|
+
# 3. Verify
|
|
335
|
+
git status --short
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
**This converts all paths to relative format (cross-platform safe).**
|
|
339
|
+
|
|
340
|
+
</worktree_repair>
|
|
341
|
+
|
|
319
342
|
<execution_rules>
|
|
320
343
|
|
|
321
344
|
- **Single step mode**: Read the step file and execute inline
|
|
@@ -143,6 +143,9 @@ Searches in: pwd, develop worktree, then git root.
|
|
|
143
143
|
|
|
144
144
|
```bash
|
|
145
145
|
resolve_gitflow_config_path() {
|
|
146
|
+
# Ensure git is accessible (cross-platform worktree repair)
|
|
147
|
+
preflight_git_check 2>/dev/null
|
|
148
|
+
|
|
146
149
|
# 1. Try current directory
|
|
147
150
|
[ -f ".claude/gitflow/config.json" ] && { echo ".claude/gitflow/config.json"; return 0; }
|
|
148
151
|
|
|
@@ -316,9 +319,36 @@ cleanup_worktree_for_branch() {
|
|
|
316
319
|
|
|
317
320
|
---
|
|
318
321
|
|
|
322
|
+
## VALIDATE_WORKTREE_PATH
|
|
323
|
+
|
|
324
|
+
Validates that a worktree path follows config conventions. Only `01-Main` and `02-Develop` may use numbered prefixes. All other worktrees (features, releases, hotfixes) MUST use config paths (`features/{name}`, `releases/v{version}`, `hotfixes/{name}`).
|
|
325
|
+
|
|
326
|
+
```bash
|
|
327
|
+
validate_worktree_path() {
|
|
328
|
+
local WORKTREE_PATH="$1"
|
|
329
|
+
local BASENAME=$(basename "$WORKTREE_PATH")
|
|
330
|
+
|
|
331
|
+
# Only 01-Main and 02-Develop may use numbered prefixes
|
|
332
|
+
if [[ "$BASENAME" =~ ^[0-9]{2}- ]] && [[ "$BASENAME" != "01-Main" ]] && [[ "$BASENAME" != "02-Develop" ]]; then
|
|
333
|
+
echo "ERROR: Invalid numbered worktree directory: $BASENAME"
|
|
334
|
+
echo " Path: $WORKTREE_PATH"
|
|
335
|
+
echo " FORBIDDEN: Numbered directories like 03-Release, 04-Feature, 05-Hotfix"
|
|
336
|
+
echo " REQUIRED: Use config paths → features/{name}, releases/v{version}, hotfixes/{name}"
|
|
337
|
+
return 1
|
|
338
|
+
fi
|
|
339
|
+
return 0
|
|
340
|
+
}
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
---
|
|
344
|
+
|
|
319
345
|
## REPAIR_WORKTREE_PATHS
|
|
320
346
|
|
|
321
|
-
|
|
347
|
+
Converts worktree metadata paths to **relative paths** for cross-platform compatibility (Windows + WSL).
|
|
348
|
+
Absolute paths (Windows `D:/...` or POSIX `/mnt/d/...`) break when switching environments.
|
|
349
|
+
Relative paths work everywhere without repair.
|
|
350
|
+
|
|
351
|
+
Scans `.bare/worktrees/*/gitdir` and the corresponding `{worktree}/.git` files.
|
|
322
352
|
|
|
323
353
|
```bash
|
|
324
354
|
repair_worktree_paths() {
|
|
@@ -333,24 +363,48 @@ repair_worktree_paths() {
|
|
|
333
363
|
local gitdir_file="$wt_dir/gitdir"
|
|
334
364
|
[ ! -f "$gitdir_file" ] && continue
|
|
335
365
|
|
|
336
|
-
#
|
|
366
|
+
# Read stored path (may be Windows absolute, POSIX absolute, or already relative)
|
|
337
367
|
local stored_path=$(cat "$gitdir_file" | tr -d '\n\r')
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
368
|
+
|
|
369
|
+
# Resolve to current platform absolute path for realpath computation
|
|
370
|
+
local resolved_path="$stored_path"
|
|
371
|
+
local is_abs=false
|
|
372
|
+
if [[ "$stored_path" =~ ^[A-Za-z]:[\\/] ]]; then
|
|
373
|
+
is_abs=true
|
|
374
|
+
resolved_path=$(normalize_path_for_platform "$stored_path")
|
|
375
|
+
elif [[ "$stored_path" =~ ^/ ]]; then
|
|
376
|
+
is_abs=true
|
|
377
|
+
resolved_path=$(normalize_path_for_platform "$stored_path")
|
|
378
|
+
fi
|
|
379
|
+
if [ "$is_abs" = "false" ]; then
|
|
380
|
+
# Already relative - resolve from gitdir_file location to get absolute
|
|
381
|
+
resolved_path=$(realpath -m "$wt_dir/$stored_path")
|
|
382
|
+
fi
|
|
383
|
+
|
|
384
|
+
# Get worktree real directory (parent of .git file)
|
|
385
|
+
local wt_real_dir=$(dirname "$resolved_path")
|
|
386
|
+
[ ! -d "$wt_real_dir" ] && continue
|
|
387
|
+
|
|
388
|
+
# Compute relative path: .bare/worktrees/{name}/ → worktree/.git
|
|
389
|
+
local bare_wt_abs=$(realpath -m "$wt_dir")
|
|
390
|
+
local wt_abs=$(realpath -m "$wt_real_dir")
|
|
391
|
+
local rel_gitdir=$(realpath -m --relative-to="$bare_wt_abs" "$wt_abs/.git")
|
|
392
|
+
|
|
393
|
+
if [ "$stored_path" != "$rel_gitdir" ]; then
|
|
394
|
+
printf '%s\n' "$rel_gitdir" > "$gitdir_file"
|
|
395
|
+
echo "REPAIRED: $wt_name/gitdir → $rel_gitdir"
|
|
342
396
|
REPAIRED=$((REPAIRED + 1))
|
|
343
397
|
fi
|
|
344
398
|
|
|
345
|
-
# Fix the worktree's .git file
|
|
346
|
-
local wt_real_dir=$(dirname "$fixed_path")
|
|
399
|
+
# Fix the worktree's .git pseudo-file → relative path to .bare/worktrees/{name}
|
|
347
400
|
if [ -f "$wt_real_dir/.git" ]; then
|
|
348
401
|
local git_content=$(cat "$wt_real_dir/.git" | tr -d '\n\r')
|
|
349
402
|
local git_path="${git_content#gitdir: }"
|
|
350
|
-
local
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
403
|
+
local rel_bare=$(realpath -m --relative-to="$wt_abs" "$bare_wt_abs")
|
|
404
|
+
|
|
405
|
+
if [ "$git_path" != "$rel_bare" ]; then
|
|
406
|
+
printf 'gitdir: %s\n' "$rel_bare" > "$wt_real_dir/.git"
|
|
407
|
+
echo "REPAIRED: $wt_name/.git → $rel_bare"
|
|
354
408
|
REPAIRED=$((REPAIRED + 1))
|
|
355
409
|
fi
|
|
356
410
|
fi
|
|
@@ -362,6 +416,49 @@ repair_worktree_paths() {
|
|
|
362
416
|
|
|
363
417
|
---
|
|
364
418
|
|
|
419
|
+
## PREFLIGHT_GIT_CHECK
|
|
420
|
+
|
|
421
|
+
Lightweight check to ensure git is accessible in the current worktree. If git fails (cross-platform path issue), locates `.bare` and calls `repair_worktree_paths`. Must be called before any git operation in agents that may run in worktrees created from a different environment (Windows vs WSL).
|
|
422
|
+
|
|
423
|
+
```bash
|
|
424
|
+
preflight_git_check() {
|
|
425
|
+
# Quick test: if git works, nothing to do
|
|
426
|
+
git rev-parse --git-dir >/dev/null 2>&1 && return 0
|
|
427
|
+
|
|
428
|
+
echo "Git inaccessible — attempting worktree path repair..."
|
|
429
|
+
|
|
430
|
+
# Find .bare directory by walking up
|
|
431
|
+
local BARE_DIR=""
|
|
432
|
+
local DIR="$(pwd)"
|
|
433
|
+
while [ "$DIR" != "/" ]; do
|
|
434
|
+
[ -d "$DIR/.bare" ] && { BARE_DIR="$DIR/.bare"; break; }
|
|
435
|
+
DIR=$(dirname "$DIR")
|
|
436
|
+
done
|
|
437
|
+
|
|
438
|
+
if [ -z "$BARE_DIR" ]; then
|
|
439
|
+
echo "ERROR: No .bare directory found. Not a GitFlow worktree."
|
|
440
|
+
return 1
|
|
441
|
+
fi
|
|
442
|
+
|
|
443
|
+
# Ensure platform is detected
|
|
444
|
+
[ -z "$GF_PLATFORM" ] && detect_platform
|
|
445
|
+
|
|
446
|
+
# Repair all worktree paths to relative format
|
|
447
|
+
repair_worktree_paths "$BARE_DIR"
|
|
448
|
+
|
|
449
|
+
# Verify repair
|
|
450
|
+
if git rev-parse --git-dir >/dev/null 2>&1; then
|
|
451
|
+
echo "Worktree paths repaired successfully."
|
|
452
|
+
return 0
|
|
453
|
+
else
|
|
454
|
+
echo "ERROR: Worktree repair failed. Run /gitflow init to reconfigure."
|
|
455
|
+
return 1
|
|
456
|
+
fi
|
|
457
|
+
}
|
|
458
|
+
```
|
|
459
|
+
|
|
460
|
+
---
|
|
461
|
+
|
|
365
462
|
## RESOLVE_WORKSPACE
|
|
366
463
|
|
|
367
464
|
Resolves the workspace JSON file by walking up the directory tree.
|
|
@@ -67,6 +67,10 @@ BRANCH_TYPE=$(echo $CURRENT | cut -d'/' -f1)
|
|
|
67
67
|
echo "⚠️ This will delete branch $CURRENT and its worktree"
|
|
68
68
|
echo "All uncommitted changes will be LOST"
|
|
69
69
|
|
|
70
|
+
# Repair cross-platform worktree paths (WSL ↔ Windows)
|
|
71
|
+
detect_platform
|
|
72
|
+
repair_worktree_paths "$(git rev-parse --git-common-dir 2>/dev/null || echo '.bare')"
|
|
73
|
+
|
|
70
74
|
# Find worktree
|
|
71
75
|
WORKTREE=$(git worktree list | grep "$CURRENT" | awk '{print $1}')
|
|
72
76
|
|
|
@@ -38,6 +38,10 @@ CURRENT=$(git rev-parse --abbrev-ref HEAD)
|
|
|
38
38
|
```bash
|
|
39
39
|
echo "Scanning worktrees..."
|
|
40
40
|
|
|
41
|
+
# Repair cross-platform worktree paths (WSL ↔ Windows)
|
|
42
|
+
detect_platform
|
|
43
|
+
repair_worktree_paths "$(git rev-parse --git-common-dir 2>/dev/null || echo '.bare')"
|
|
44
|
+
|
|
41
45
|
mkdir -p .claude/gitflow/cache
|
|
42
46
|
git worktree list > .claude/gitflow/cache/worktrees.txt
|
|
43
47
|
|