@atlashub/smartstack-cli 3.7.0 → 3.9.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 +365 -2
- package/dist/index.js.map +1 -1
- package/package.json +4 -2
- package/templates/agents/action.md +1 -0
- package/templates/agents/ba-writer.md +33 -0
- package/templates/agents/explore-codebase.md +1 -0
- package/templates/agents/explore-docs.md +1 -0
- package/templates/agents/fix-grammar.md +1 -0
- package/templates/agents/snipper.md +1 -0
- package/templates/skills/admin/SKILL.md +6 -0
- package/templates/skills/ai-prompt/SKILL.md +32 -136
- package/templates/skills/ai-prompt/steps/step-01-implementation.md +122 -0
- package/templates/skills/apex/SKILL.md +120 -0
- package/templates/skills/apex/_shared.md +86 -0
- package/templates/skills/apex/references/agent-teams-protocol.md +164 -0
- package/templates/skills/apex/references/smartstack-layers.md +173 -0
- package/templates/skills/apex/steps/step-00-init.md +156 -0
- package/templates/skills/apex/steps/step-01-analyze.md +169 -0
- package/templates/skills/apex/steps/step-02-plan.md +160 -0
- package/templates/skills/apex/steps/step-03-execute.md +166 -0
- package/templates/skills/apex/steps/step-04-validate.md +138 -0
- package/templates/skills/apex/steps/step-05-examine.md +124 -0
- package/templates/skills/apex/steps/step-06-resolve.md +105 -0
- package/templates/skills/apex/steps/step-07-tests.md +130 -0
- package/templates/skills/apex/steps/step-08-run-tests.md +115 -0
- package/templates/skills/application/SKILL.md +10 -0
- package/templates/skills/application/references/backend-controller-hierarchy.md +58 -0
- package/templates/skills/application/references/backend-entity-seeding.md +72 -0
- package/templates/skills/application/references/backend-verification.md +88 -0
- package/templates/skills/application/references/frontend-verification.md +111 -0
- package/templates/skills/application/references/nav-fallback-procedure.md +200 -0
- package/templates/skills/application/references/provider-template.md +134 -0
- package/templates/skills/application/references/test-frontend.md +73 -0
- package/templates/skills/application/references/test-prerequisites.md +72 -0
- package/templates/skills/application/steps/step-01-navigation.md +7 -198
- package/templates/skills/application/steps/step-03b-provider.md +4 -128
- package/templates/skills/application/steps/step-04-backend.md +20 -350
- package/templates/skills/application/steps/step-05-frontend.md +12 -101
- package/templates/skills/application/steps/step-07-tests.md +12 -132
- package/templates/skills/business-analyse/SKILL.md +11 -2
- package/templates/skills/business-analyse/html/ba-interactive.html +3214 -2246
- package/templates/skills/business-analyse/html/build-html.js +77 -0
- package/templates/skills/business-analyse/html/src/scripts/01-data-init.js +130 -0
- package/templates/skills/business-analyse/html/src/scripts/02-navigation.js +22 -0
- package/templates/skills/business-analyse/html/src/scripts/03-render-cadrage.js +208 -0
- package/templates/skills/business-analyse/html/src/scripts/04-render-modules.js +211 -0
- package/templates/skills/business-analyse/html/src/scripts/05-render-specs.js +554 -0
- package/templates/skills/business-analyse/html/src/scripts/06-render-consolidation.js +110 -0
- package/templates/skills/business-analyse/html/src/scripts/07-render-handoff.js +90 -0
- package/templates/skills/business-analyse/html/src/scripts/08-editing.js +45 -0
- package/templates/skills/business-analyse/html/src/scripts/09-export.js +168 -0
- package/templates/skills/business-analyse/html/src/scripts/10-comments.js +171 -0
- package/templates/skills/business-analyse/html/src/scripts/11-review-panel.js +161 -0
- package/templates/skills/business-analyse/html/src/styles/01-variables.css +38 -0
- package/templates/skills/business-analyse/html/src/styles/02-layout.css +101 -0
- package/templates/skills/business-analyse/html/src/styles/03-navigation.css +62 -0
- package/templates/skills/business-analyse/html/src/styles/04-cards.css +196 -0
- package/templates/skills/business-analyse/html/src/styles/05-modules.css +325 -0
- package/templates/skills/business-analyse/html/src/styles/06-wireframes.css +230 -0
- package/templates/skills/business-analyse/html/src/styles/07-comments.css +184 -0
- package/templates/skills/business-analyse/html/src/styles/08-review-panel.css +241 -0
- package/templates/skills/business-analyse/html/src/template.html +623 -0
- package/templates/skills/business-analyse/references/cadrage-structure-cards.md +78 -0
- package/templates/skills/business-analyse/references/cadrage-vibe-coding.md +97 -0
- package/templates/skills/business-analyse/references/consolidation-structural-checks.md +92 -0
- package/templates/skills/business-analyse/references/deploy-data-build.md +121 -0
- package/templates/skills/business-analyse/references/deploy-modes.md +49 -0
- package/templates/skills/business-analyse/references/handoff-file-templates.md +119 -0
- package/templates/skills/business-analyse/references/handoff-mappings.md +81 -0
- package/templates/skills/business-analyse/references/html-data-mapping.md +10 -2
- package/templates/skills/business-analyse/references/init-schema-deployment.md +65 -0
- package/templates/skills/business-analyse/references/review-data-mapping.md +363 -0
- package/templates/skills/business-analyse/references/spec-auto-inference.md +57 -0
- package/templates/skills/business-analyse/references/ui-dashboard-spec.md +85 -0
- package/templates/skills/business-analyse/references/ui-resource-cards.md +110 -0
- package/templates/skills/business-analyse/references/validate-incremental-html.md +55 -0
- package/templates/skills/business-analyse/steps/step-00-init.md +35 -68
- package/templates/skills/business-analyse/steps/step-01-cadrage.md +5 -194
- package/templates/skills/business-analyse/steps/step-03a-data.md +6 -49
- package/templates/skills/business-analyse/steps/step-03b-ui.md +12 -178
- package/templates/skills/business-analyse/steps/step-03d-validate.md +3 -48
- package/templates/skills/business-analyse/steps/step-04-consolidation.md +9 -104
- package/templates/skills/business-analyse/steps/step-05a-handoff.md +25 -441
- package/templates/skills/business-analyse/steps/step-05b-deploy.md +19 -187
- package/templates/skills/business-analyse/steps/step-06-review.md +277 -0
- package/templates/skills/cc-agent/references/agent-behavior-patterns.md +95 -0
- package/templates/skills/cc-agent/steps/step-02-generate.md +5 -78
- package/templates/skills/check-version/SKILL.md +7 -0
- package/templates/skills/controller/references/controller-code-templates.md +159 -0
- package/templates/skills/controller/references/permission-sync-templates.md +152 -0
- package/templates/skills/controller/steps/step-03-generate.md +6 -158
- package/templates/skills/controller/steps/step-04-perms.md +5 -144
- package/templates/skills/debug/SKILL.md +7 -0
- package/templates/skills/explore/SKILL.md +6 -0
- package/templates/skills/feature-full/SKILL.md +39 -142
- package/templates/skills/feature-full/steps/step-01-implementation.md +120 -0
- package/templates/skills/gitflow/references/init-config-template.md +135 -0
- package/templates/skills/gitflow/references/init-name-normalization.md +103 -0
- package/templates/skills/gitflow/references/plan-template.md +69 -0
- package/templates/skills/gitflow/references/start-efcore-preflight.md +70 -0
- package/templates/skills/gitflow/references/start-local-config.md +110 -0
- package/templates/skills/gitflow/steps/step-init.md +18 -289
- package/templates/skills/gitflow/steps/step-plan.md +6 -63
- package/templates/skills/gitflow/steps/step-start.md +16 -126
- package/templates/skills/mcp/SKILL.md +9 -213
- package/templates/skills/mcp/steps/step-01-healthcheck.md +108 -0
- package/templates/skills/mcp/steps/step-02-tools.md +73 -0
- package/templates/skills/notification/SKILL.md +7 -0
- package/templates/skills/quick-search/SKILL.md +5 -0
- package/templates/skills/ralph-loop/SKILL.md +99 -381
- package/templates/skills/ralph-loop/references/category-rules.md +259 -0
- package/templates/skills/ralph-loop/references/compact-loop.md +182 -0
- package/templates/skills/ralph-loop/references/task-transform-legacy.md +259 -0
- package/templates/skills/ralph-loop/references/team-orchestration.md +189 -0
- package/templates/skills/ralph-loop/steps/step-00-init.md +111 -383
- package/templates/skills/ralph-loop/steps/step-01-task.md +79 -896
- package/templates/skills/ralph-loop/steps/step-02-execute.md +68 -680
- package/templates/skills/ralph-loop/steps/step-03-commit.md +47 -277
- package/templates/skills/ralph-loop/steps/step-04-check.md +124 -607
- package/templates/skills/ralph-loop/steps/step-05-report.md +68 -367
- package/templates/skills/refactor/SKILL.md +12 -176
- package/templates/skills/refactor/steps/step-01-discover.md +60 -0
- package/templates/skills/refactor/steps/step-02-execute.md +67 -0
- package/templates/skills/review-code/SKILL.md +19 -257
- package/templates/skills/review-code/steps/step-01-smartstack.md +96 -0
- package/templates/skills/review-code/steps/step-02-detailed-review.md +80 -0
- package/templates/skills/review-code/steps/step-03-react.md +44 -0
- package/templates/skills/ui-components/SKILL.md +7 -0
- package/templates/skills/utils/SKILL.md +6 -0
- package/templates/skills/validate/SKILL.md +6 -0
- package/templates/skills/validate-feature/SKILL.md +8 -0
- package/templates/skills/workflow/SKILL.md +40 -118
- package/templates/skills/workflow/steps/step-01-implementation.md +84 -0
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# SmartStack Project Detection & MCP Validation
|
|
2
|
+
|
|
3
|
+
**CRITICAL**: Before starting any code review, detect if this is a SmartStack project and run MCP validation.
|
|
4
|
+
|
|
5
|
+
## Detection
|
|
6
|
+
|
|
7
|
+
**Detect SmartStack project by checking for ANY of these:**
|
|
8
|
+
- `.claude/mcp-status.json` exists
|
|
9
|
+
- `SmartStack.Domain/` or `SmartStack.Application/` directories
|
|
10
|
+
- `*.sln` file containing "SmartStack"
|
|
11
|
+
- `package.json` with `@smartstack/` dependencies
|
|
12
|
+
|
|
13
|
+
## MCP Validation
|
|
14
|
+
|
|
15
|
+
**If SmartStack detected, run comprehensive code review via MCP:**
|
|
16
|
+
|
|
17
|
+
**Primary tool - `review_code`** (unified review):
|
|
18
|
+
```
|
|
19
|
+
mcp__smartstack__review_code
|
|
20
|
+
scope: "changed" # or "all" or "staged"
|
|
21
|
+
checks: ["all"] # 9 categories covered
|
|
22
|
+
severity: "all" # blocking, critical, warning, info
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
**This single tool covers ALL categories:**
|
|
26
|
+
- Security (OWASP, secrets, SQL injection, XSS)
|
|
27
|
+
- Architecture (layer violations, DI bypass)
|
|
28
|
+
- Hardcoded values (magic numbers, URLs, feature flags)
|
|
29
|
+
- Tests (missing tests, test quality)
|
|
30
|
+
- AI Hallucinations (non-existent imports, phantom methods)
|
|
31
|
+
- Performance (N+1 queries, over-fetching)
|
|
32
|
+
- Dead Code (unused imports, functions)
|
|
33
|
+
- i18n (non-translated UI text)
|
|
34
|
+
- Accessibility (missing alt, ARIA issues)
|
|
35
|
+
|
|
36
|
+
**Optional: Additional convention checks:**
|
|
37
|
+
```
|
|
38
|
+
mcp__smartstack__validate_conventions
|
|
39
|
+
checks: ["all"]
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## MCP Check Categories
|
|
43
|
+
|
|
44
|
+
**SmartStack code review categories via MCP `review_code`:**
|
|
45
|
+
|
|
46
|
+
| Category | Check ID | What it detects |
|
|
47
|
+
|----------|----------|-----------------|
|
|
48
|
+
| **Security** | SEC-xxx | Hardcoded secrets, SQL injection, XSS, missing [Authorize] |
|
|
49
|
+
| **Architecture** | ARCH-xxx | Layer violations (Domain->Infrastructure), DI bypass |
|
|
50
|
+
| **Hardcoded** | HARD-xxx | Magic numbers, hardcoded URLs, feature flags |
|
|
51
|
+
| **Tests** | TEST-xxx | Missing tests, useless assertions, no coverage |
|
|
52
|
+
| **AI Hallucinations** | AI-xxx | Non-existent imports, phantom methods, placeholders |
|
|
53
|
+
| **Performance** | PERF-xxx | N+1 queries, ToList before Where, over-fetching |
|
|
54
|
+
| **Dead Code** | DEAD-xxx | Unused imports, functions, commented code, TODOs |
|
|
55
|
+
| **i18n** | I18N-xxx | Hardcoded UI text, missing translations |
|
|
56
|
+
| **Accessibility** | A11Y-xxx | Missing alt, no aria-label, focus issues |
|
|
57
|
+
|
|
58
|
+
**Severity levels:**
|
|
59
|
+
- `blocking` -> Must fix before merge (security, hallucinations)
|
|
60
|
+
- `critical` -> Should fix ASAP (architecture, tests)
|
|
61
|
+
- `warning` -> Recommended fix (performance, dead code)
|
|
62
|
+
- `info` -> Nice to have (i18n, a11y)
|
|
63
|
+
|
|
64
|
+
## Output Integration
|
|
65
|
+
|
|
66
|
+
**Merge MCP `review_code` results into review output:**
|
|
67
|
+
|
|
68
|
+
```markdown
|
|
69
|
+
## Code Review Results (via MCP)
|
|
70
|
+
|
|
71
|
+
### Summary
|
|
72
|
+
| Metric | Value |
|
|
73
|
+
|--------|-------|
|
|
74
|
+
| Status | {PASSED/FAILED/WARNING} |
|
|
75
|
+
| Score | {score}/100 |
|
|
76
|
+
| Grade | {A/B/C/D/F} |
|
|
77
|
+
|
|
78
|
+
### Blocking Issues ({count})
|
|
79
|
+
| ID | Issue | File:Line | Fix |
|
|
80
|
+
|----|-------|-----------|-----|
|
|
81
|
+
| SEC-001 | {title} | `{file}:{line}` | {suggestion} |
|
|
82
|
+
|
|
83
|
+
### Critical Issues ({count})
|
|
84
|
+
| ID | Issue | File:Line | Fix |
|
|
85
|
+
|----|-------|-----------|-----|
|
|
86
|
+
| ARCH-001 | {title} | `{file}:{line}` | {suggestion} |
|
|
87
|
+
|
|
88
|
+
### Warnings ({count})
|
|
89
|
+
(List or summarize)
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
**Priority mapping from MCP:**
|
|
93
|
+
- `blocking` -> `[BLOCKING]` - Must fix before merge
|
|
94
|
+
- `critical` -> `[CRITICAL]` - Should fix ASAP
|
|
95
|
+
- `warning` -> `[SUGGESTION]` - Recommended
|
|
96
|
+
- `info` -> `[NIT]` - Nice to have
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# Detailed Review Categories & Metrics
|
|
2
|
+
|
|
3
|
+
## Review Categories
|
|
4
|
+
|
|
5
|
+
### Security (Critical Priority)
|
|
6
|
+
**Must check in every review:**
|
|
7
|
+
- No hardcoded credentials (search: `password.*=.*['"]`, `api[_-]?key.*=`)
|
|
8
|
+
- Input validation on all user data
|
|
9
|
+
- Parameterized queries (no string concatenation for SQL)
|
|
10
|
+
- Authorization checks on every endpoint
|
|
11
|
+
- No `eval()`, `exec()`, dangerous functions
|
|
12
|
+
|
|
13
|
+
See [references/security-checklist.md](../references/security-checklist.md) for OWASP Top 10 patterns.
|
|
14
|
+
See [references/owasp-api-top10.md](../references/owasp-api-top10.md) for OWASP API Security Top 10.
|
|
15
|
+
|
|
16
|
+
### Logic (Critical Priority)
|
|
17
|
+
**Verify correctness:**
|
|
18
|
+
- Business logic matches requirements
|
|
19
|
+
- Edge cases handled (null, empty, boundary values)
|
|
20
|
+
- Error handling present and appropriate
|
|
21
|
+
- Race conditions in async code
|
|
22
|
+
- Resource cleanup (connections, file handles)
|
|
23
|
+
|
|
24
|
+
### Clean Code (High Priority)
|
|
25
|
+
**Check for code smells:**
|
|
26
|
+
- Large functions (>50 lines) - violate Single Responsibility
|
|
27
|
+
- Deep nesting (>3 levels) - extract to functions
|
|
28
|
+
- Long parameter lists (>3 params) - use objects
|
|
29
|
+
- Duplicated code - extract to shared functions
|
|
30
|
+
- Magic numbers/strings - use named constants
|
|
31
|
+
|
|
32
|
+
See [references/clean-code-principles.md](../references/clean-code-principles.md) for SOLID principles.
|
|
33
|
+
|
|
34
|
+
### Maintainability (Medium Priority)
|
|
35
|
+
**Assess long-term health:**
|
|
36
|
+
- Cognitive complexity <15 per function
|
|
37
|
+
- Clear naming that reveals intent
|
|
38
|
+
- Appropriate abstractions (not over-engineered)
|
|
39
|
+
- Test coverage for critical paths
|
|
40
|
+
|
|
41
|
+
## Code Quality Metrics
|
|
42
|
+
|
|
43
|
+
### Cognitive Complexity
|
|
44
|
+
- Target: <15 per function, <50 per module
|
|
45
|
+
- Each nesting level adds complexity
|
|
46
|
+
- Prefer early returns over deep nesting
|
|
47
|
+
|
|
48
|
+
### Function Size
|
|
49
|
+
- Target: <50 lines, ideally <20
|
|
50
|
+
- Should fit on one screen
|
|
51
|
+
- One function = one responsibility
|
|
52
|
+
|
|
53
|
+
### Cyclomatic Complexity
|
|
54
|
+
- Target: <10 per function
|
|
55
|
+
- Count: 1 + (if + while + for + case + catch + && + ||)
|
|
56
|
+
- High complexity = hard to test
|
|
57
|
+
|
|
58
|
+
See [references/code-quality-metrics.md](../references/code-quality-metrics.md) for detailed calculations.
|
|
59
|
+
|
|
60
|
+
## Anti-Patterns to Flag
|
|
61
|
+
|
|
62
|
+
### Nitpicking
|
|
63
|
+
**Problem**: Excessive minor comments bury critical issues
|
|
64
|
+
**Impact**: Developers become defensive, stop reading feedback
|
|
65
|
+
**Solution**: Automate style with linters; focus humans on logic/security
|
|
66
|
+
|
|
67
|
+
### Vague Criticism
|
|
68
|
+
**Problem**: "This is wrong" without explanation
|
|
69
|
+
**Impact**: Developer doesn't know how to fix; creates friction
|
|
70
|
+
**Solution**: Always include What + Why + How
|
|
71
|
+
|
|
72
|
+
### Blocking on Preferences
|
|
73
|
+
**Problem**: Blocking merge for subjective style preferences
|
|
74
|
+
**Impact**: Delays delivery; damages team trust
|
|
75
|
+
**Solution**: Reserve blocking for security/correctness only
|
|
76
|
+
|
|
77
|
+
### Reviewing Unchanged Code
|
|
78
|
+
**Problem**: Commenting on code outside the PR diff
|
|
79
|
+
**Impact**: Scope creep; unfair to author
|
|
80
|
+
**Solution**: Focus only on changed lines; file separate issues for existing problems
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# React/Next.js Review
|
|
2
|
+
|
|
3
|
+
## Codebase Detection
|
|
4
|
+
|
|
5
|
+
**When reviewing a React or Next.js project**, launch an additional parallel agent for Vercel React best practices.
|
|
6
|
+
|
|
7
|
+
**Detect React/Next.js codebase by checking:**
|
|
8
|
+
- `package.json` contains `"next"` or `"react"` dependencies
|
|
9
|
+
- Files with `.tsx`, `.jsx` extensions in changes
|
|
10
|
+
- `next.config.js` or `next.config.ts` exists
|
|
11
|
+
- `app/` or `pages/` directory structure (Next.js)
|
|
12
|
+
|
|
13
|
+
## Parallel Agent
|
|
14
|
+
|
|
15
|
+
**If React/Next.js detected, launch parallel agent:**
|
|
16
|
+
|
|
17
|
+
```yaml
|
|
18
|
+
agent:
|
|
19
|
+
type: code-reviewer
|
|
20
|
+
focus: "vercel-react-best-practices"
|
|
21
|
+
task: |
|
|
22
|
+
Review the recent code changes using Vercel React best practices.
|
|
23
|
+
Focus on:
|
|
24
|
+
- Eliminating waterfalls (async patterns, Promise.all)
|
|
25
|
+
- Bundle size optimization (dynamic imports, barrel files)
|
|
26
|
+
- Server-side performance (caching, serialization)
|
|
27
|
+
- Re-render optimization (memoization, state management)
|
|
28
|
+
- Rendering performance patterns
|
|
29
|
+
|
|
30
|
+
Use the /vercel-react-best-practices skill as reference.
|
|
31
|
+
Report findings with [BLOCKING], [SUGGESTION], or [NIT] labels.
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
**Execution:**
|
|
35
|
+
1. Check for React/Next.js in `package.json`
|
|
36
|
+
2. If detected, use Task tool to launch parallel agent:
|
|
37
|
+
```
|
|
38
|
+
Task tool with subagent_type="code-reviewer":
|
|
39
|
+
"Review recent changes against Vercel React best practices from /vercel-react-best-practices skill.
|
|
40
|
+
Focus on: async patterns, bundle optimization, server performance, re-renders.
|
|
41
|
+
Check changed files for violations of rules like async-parallel, bundle-barrel-imports,
|
|
42
|
+
server-cache-react, rerender-memo. Report with priority labels."
|
|
43
|
+
```
|
|
44
|
+
3. Merge findings into main review output
|
|
@@ -128,3 +128,10 @@ import { EntityCard, ProviderCard, TemplateCard } from '@/components/ui/EntityCa
|
|
|
128
128
|
- Always provide retry button for recoverable errors
|
|
129
129
|
- Use Lucide `AlertCircle` icon (not inline SVG)
|
|
130
130
|
- Keep error messages user-friendly (not technical stack traces)
|
|
131
|
+
|
|
132
|
+
<success_criteria>
|
|
133
|
+
- Component created following SmartStack UI patterns (CSS variables, Lucide icons, i18n)
|
|
134
|
+
- Correct file placement in src/pages/ or src/components/
|
|
135
|
+
- Loading, error, and empty states handled
|
|
136
|
+
- Responsive layout with SmartStack grid system
|
|
137
|
+
</success_criteria>
|
|
@@ -36,3 +36,9 @@ Route to subcommand file:
|
|
|
36
36
|
| `test-web-config` | `subcommands/test-web-config.md` |
|
|
37
37
|
|
|
38
38
|
</entry_point>
|
|
39
|
+
|
|
40
|
+
<success_criteria>
|
|
41
|
+
- Subcommand routed and executed successfully
|
|
42
|
+
- Test results displayed with pass/fail status
|
|
43
|
+
- Configuration saved when using test-web-config
|
|
44
|
+
</success_criteria>
|
|
@@ -173,3 +173,9 @@ WARNINGS ({count})
|
|
|
173
173
|
4. **Structured Output:** Typed responses for automation
|
|
174
174
|
|
|
175
175
|
</why_mcp>
|
|
176
|
+
|
|
177
|
+
<success_criteria>
|
|
178
|
+
- MCP validate_conventions called with correct checks
|
|
179
|
+
- Validation report displayed with pass/fail per check
|
|
180
|
+
- All errors and warnings listed with file references and suggestions
|
|
181
|
+
</success_criteria>
|
|
@@ -81,3 +81,11 @@ A validation report showing pass/fail for each check:
|
|
|
81
81
|
|
|
82
82
|
Result: ALL CHECKS PASSED
|
|
83
83
|
```
|
|
84
|
+
|
|
85
|
+
<success_criteria>
|
|
86
|
+
- Solution compiles without errors
|
|
87
|
+
- All unit tests pass
|
|
88
|
+
- All integration tests pass
|
|
89
|
+
- API smoke tests return expected HTTP status codes (200, 201, 204)
|
|
90
|
+
- Validation report displayed with per-check results
|
|
91
|
+
</success_criteria>
|
|
@@ -12,11 +12,11 @@ description: |
|
|
|
12
12
|
|
|
13
13
|
# Skill Workflow SmartStack
|
|
14
14
|
|
|
15
|
-
> **Architecture:** Trigger
|
|
15
|
+
> **Architecture:** Trigger -> Steps -> Actions (Email/Wait/Condition/Webhook)
|
|
16
16
|
|
|
17
17
|
**Reference:** [_shared.md](../_shared.md) for common services
|
|
18
18
|
|
|
19
|
-
##
|
|
19
|
+
## When This Skill Activates
|
|
20
20
|
|
|
21
21
|
| Trigger | Example |
|
|
22
22
|
|---------|---------|
|
|
@@ -25,17 +25,17 @@ description: |
|
|
|
25
25
|
| Chaining | "After 24h without response, send a reminder" |
|
|
26
26
|
| Keywords | "workflow", "trigger", "automation", "email template" |
|
|
27
27
|
|
|
28
|
-
##
|
|
28
|
+
## Flow
|
|
29
29
|
|
|
30
30
|
```
|
|
31
|
-
EVENT
|
|
32
|
-
|
|
31
|
+
EVENT -> WorkflowTrigger("user.registered")
|
|
32
|
+
|
|
|
33
33
|
IWorkflowService.TriggerAsync(code, variables)
|
|
34
|
-
|
|
35
|
-
Workflow Steps: SendEmail
|
|
34
|
+
|
|
|
35
|
+
Workflow Steps: SendEmail -> Wait -> Condition -> Webhook
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
-
##
|
|
38
|
+
## Available Triggers
|
|
39
39
|
|
|
40
40
|
### User Events
|
|
41
41
|
| Trigger | Variables |
|
|
@@ -62,138 +62,53 @@ new { Id = Guid.Parse("..."), Code = "entity.event", Name = "Entity Event",
|
|
|
62
62
|
await _workflowService.TriggerAsync("entity.event", new Dictionary<string, object>{...}, language: "en");
|
|
63
63
|
```
|
|
64
64
|
|
|
65
|
-
##
|
|
65
|
+
## Implementation
|
|
66
66
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
### 2. Wait
|
|
74
|
-
```csharp
|
|
75
|
-
WorkflowStep.CreateWaitStep("Wait 24h", delayMinutes: 1440, order: 2);
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
### 3. Condition
|
|
79
|
-
```csharp
|
|
80
|
-
WorkflowStep.CreateConditionStep("Check premium", JsonSerializer.Serialize(new {
|
|
81
|
-
condition = "{{userType}} == 'Premium'",
|
|
82
|
-
trueStepOrder = 3, falseStepOrder = 4
|
|
83
|
-
}), order: 2);
|
|
84
|
-
// Operators: ==, !=, >, <, contains, &&, ||
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
### 4. Webhook
|
|
88
|
-
```csharp
|
|
89
|
-
WorkflowStep.CreateWebhookStep("Notify CRM", JsonSerializer.Serialize(new {
|
|
90
|
-
url = "https://...", method = "POST",
|
|
91
|
-
headers = new { Authorization = "Bearer {{apiKey}}" },
|
|
92
|
-
body = new { eventType = "...", userId = "{{userId}}" },
|
|
93
|
-
retryCount = 3
|
|
94
|
-
}), order: 3);
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
## WORKFLOW CREATION
|
|
98
|
-
|
|
99
|
-
```csharp
|
|
100
|
-
// 1. Create workflow
|
|
101
|
-
var workflow = Workflow.Create("welcome-sequence", "Welcome Sequence", description, triggerId, null, false, 10);
|
|
102
|
-
|
|
103
|
-
// 2. Add steps
|
|
104
|
-
workflow.AddStep(WorkflowStep.CreateEmailStep("Welcome", templateId, 1));
|
|
105
|
-
workflow.AddStep(WorkflowStep.CreateWaitStep("Wait 24h", 1440, 2));
|
|
106
|
-
workflow.AddStep(WorkflowStep.CreateEmailStep("Follow-up", followUpTemplateId, 3));
|
|
107
|
-
|
|
108
|
-
// 3. Seed data (WorkflowConfiguration.cs)
|
|
109
|
-
builder.HasData(new { Id = ..., Code = "welcome-sequence", TriggerId = ..., IsActive = true, ... });
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
## TRIGGERING
|
|
113
|
-
|
|
114
|
-
```csharp
|
|
115
|
-
// In Service or Controller
|
|
116
|
-
await _workflowService.TriggerAsync("user.registered", new Dictionary<string, object>
|
|
117
|
-
{
|
|
118
|
-
["userId"] = user.Id,
|
|
119
|
-
["email"] = user.Email,
|
|
120
|
-
["confirmUrl"] = GenerateConfirmUrl(user.Id)
|
|
121
|
-
}, language: "en", ct);
|
|
122
|
-
```
|
|
67
|
+
See [steps/step-01-implementation.md](steps/step-01-implementation.md) for:
|
|
68
|
+
- Step types (SendEmail, Wait, Condition, Webhook) with code templates
|
|
69
|
+
- Workflow creation and seed data
|
|
70
|
+
- Triggering from services
|
|
71
|
+
- Email templates (Handlebars syntax)
|
|
72
|
+
- Frontend API
|
|
123
73
|
|
|
124
|
-
##
|
|
125
|
-
|
|
126
|
-
### Structure
|
|
127
|
-
```csharp
|
|
128
|
-
EmailTemplate: Code, Name, Category, IsActive, Translations[]
|
|
129
|
-
EmailTemplateTranslation: LanguageCode, Subject, HtmlBody, TextBody
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
### Syntax (Handlebars)
|
|
133
|
-
```html
|
|
134
|
-
<h1>Welcome {{userName}}!</h1>
|
|
135
|
-
{{#if isPremium}}<p>Thank you Premium member!</p>{{else}}<p>Premium offers...</p>{{/if}}
|
|
136
|
-
{{#each items}}<li>{{this.name}}</li>{{/each}}
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
## FRONTEND API
|
|
140
|
-
|
|
141
|
-
```typescript
|
|
142
|
-
workflowsApi.getAll() / getById(id) / create(data) / update(id, data)
|
|
143
|
-
workflowsApi.getTriggers()
|
|
144
|
-
workflowsApi.addStep(workflowId, step) / updateStep / deleteStep / reorderSteps
|
|
145
|
-
workflowsApi.execute(workflowId, variables)
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
## CHECKLIST
|
|
149
|
-
|
|
150
|
-
```
|
|
151
|
-
□ Trigger identified (existing or new in WorkflowTriggerConfiguration.cs)
|
|
152
|
-
□ Workflow created: Unique code, Linked trigger, Priority (10=standard, 20+=priority)
|
|
153
|
-
□ Steps: SendEmail+templateId, Wait+delayMinutes, Condition+expression, Webhook+url
|
|
154
|
-
□ Email templates created (if SendEmail)
|
|
155
|
-
□ Trigger added to source code
|
|
156
|
-
□ Tests: trigger, emails, variables
|
|
157
|
-
```
|
|
158
|
-
|
|
159
|
-
## RELATION WITH DOMAIN EVENTS
|
|
74
|
+
## Relation with Domain Events
|
|
160
75
|
|
|
161
76
|
Workflow triggers (`TriggerAsync`) are the **primary mechanism** for cross-process automation (emails, webhooks, multi-step flows).
|
|
162
77
|
|
|
163
|
-
**Domain Events** (MediatR `INotificationHandler<T>`) are
|
|
164
|
-
|
|
165
|
-
**Recommended pattern:** Domain Event handler bridges to Workflow triggers:
|
|
166
|
-
```csharp
|
|
167
|
-
// OrderCreatedEventHandler calls TriggerAsync for cross-process actions
|
|
168
|
-
public async Task Handle(OrderCreatedEvent notification, CancellationToken ct)
|
|
169
|
-
{
|
|
170
|
-
await _workflowService.TriggerAsync("order.created",
|
|
171
|
-
new Dictionary<string, object>{ ["orderId"] = notification.OrderId }, ct: ct);
|
|
172
|
-
}
|
|
173
|
-
```
|
|
78
|
+
**Domain Events** (MediatR `INotificationHandler<T>`) are complementary for **in-process** side effects (audit logging, cache invalidation, read-model updates).
|
|
174
79
|
|
|
175
|
-
**When to use which:**
|
|
176
80
|
| Scenario | Mechanism |
|
|
177
81
|
|----------|-----------|
|
|
178
82
|
| Send email after entity creation | Workflow Trigger |
|
|
179
83
|
| Invalidate cache after entity update | Domain Event |
|
|
180
84
|
| Log audit trail | Domain Event |
|
|
181
85
|
| Multi-step business process with delays | Workflow Trigger |
|
|
182
|
-
| Notify multiple services of same change | Domain Event
|
|
86
|
+
| Notify multiple services of same change | Domain Event -> Workflow Trigger |
|
|
183
87
|
|
|
184
|
-
See `review-code/references/smartstack-conventions.md` (Domain Events section) for
|
|
88
|
+
See `review-code/references/smartstack-conventions.md` (Domain Events section) for full pattern.
|
|
185
89
|
|
|
186
|
-
##
|
|
90
|
+
## Checklist
|
|
91
|
+
|
|
92
|
+
```
|
|
93
|
+
- Trigger identified (existing or new in WorkflowTriggerConfiguration.cs)
|
|
94
|
+
- Workflow created: Unique code, Linked trigger, Priority (10=standard, 20+=priority)
|
|
95
|
+
- Steps: SendEmail+templateId, Wait+delayMinutes, Condition+expression, Webhook+url
|
|
96
|
+
- Email templates created (if SendEmail)
|
|
97
|
+
- Trigger added to source code
|
|
98
|
+
- Tests: trigger, emails, variables
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Absolute Rules
|
|
187
102
|
|
|
188
103
|
| DO | DON'T |
|
|
189
104
|
|----|-------|
|
|
190
105
|
| IWorkflowService.TriggerAsync | Direct execution |
|
|
191
106
|
| All trigger variables | Hardcoded URLs in templates |
|
|
192
107
|
| Specify language for emails | Secrets in variables |
|
|
193
|
-
| Unique kebab-case codes | Infinite loops (A
|
|
108
|
+
| Unique kebab-case codes | Infinite loops (A->B->A) |
|
|
194
109
|
| Log executions | Forget email templates |
|
|
195
110
|
|
|
196
|
-
##
|
|
111
|
+
## Key Files
|
|
197
112
|
|
|
198
113
|
| File | Role |
|
|
199
114
|
|------|------|
|
|
@@ -203,3 +118,10 @@ See `review-code/references/smartstack-conventions.md` (Domain Events section) f
|
|
|
203
118
|
| `Application/Common/Interfaces/IWorkflowService.cs` | Interface |
|
|
204
119
|
| `Infrastructure/Services/Workflow/WorkflowExecutionService.cs` | Implementation |
|
|
205
120
|
| `Infrastructure/.../WorkflowConfiguration.cs` | EF Config + Seed |
|
|
121
|
+
|
|
122
|
+
<success_criteria>
|
|
123
|
+
- Workflow entity, steps, and triggers created following SmartStack patterns
|
|
124
|
+
- EF Core configuration and seed data generated
|
|
125
|
+
- IWorkflowService integration wired correctly
|
|
126
|
+
- Email templates created with i18n support (4 languages)
|
|
127
|
+
</success_criteria>
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# Workflow - Implementation Details
|
|
2
|
+
|
|
3
|
+
## Step Types
|
|
4
|
+
|
|
5
|
+
### 1. SendEmail
|
|
6
|
+
```csharp
|
|
7
|
+
WorkflowStep.CreateEmailStep("Welcome Email", emailTemplateId, order: 1);
|
|
8
|
+
// Config: templateId, recipientVariable, ccEmails
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
### 2. Wait
|
|
12
|
+
```csharp
|
|
13
|
+
WorkflowStep.CreateWaitStep("Wait 24h", delayMinutes: 1440, order: 2);
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
### 3. Condition
|
|
17
|
+
```csharp
|
|
18
|
+
WorkflowStep.CreateConditionStep("Check premium", JsonSerializer.Serialize(new {
|
|
19
|
+
condition = "{{userType}} == 'Premium'",
|
|
20
|
+
trueStepOrder = 3, falseStepOrder = 4
|
|
21
|
+
}), order: 2);
|
|
22
|
+
// Operators: ==, !=, >, <, contains, &&, ||
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### 4. Webhook
|
|
26
|
+
```csharp
|
|
27
|
+
WorkflowStep.CreateWebhookStep("Notify CRM", JsonSerializer.Serialize(new {
|
|
28
|
+
url = "https://...", method = "POST",
|
|
29
|
+
headers = new { Authorization = "Bearer {{apiKey}}" },
|
|
30
|
+
body = new { eventType = "...", userId = "{{userId}}" },
|
|
31
|
+
retryCount = 3
|
|
32
|
+
}), order: 3);
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Workflow Creation
|
|
36
|
+
|
|
37
|
+
```csharp
|
|
38
|
+
// 1. Create workflow
|
|
39
|
+
var workflow = Workflow.Create("welcome-sequence", "Welcome Sequence", description, triggerId, null, false, 10);
|
|
40
|
+
|
|
41
|
+
// 2. Add steps
|
|
42
|
+
workflow.AddStep(WorkflowStep.CreateEmailStep("Welcome", templateId, 1));
|
|
43
|
+
workflow.AddStep(WorkflowStep.CreateWaitStep("Wait 24h", 1440, 2));
|
|
44
|
+
workflow.AddStep(WorkflowStep.CreateEmailStep("Follow-up", followUpTemplateId, 3));
|
|
45
|
+
|
|
46
|
+
// 3. Seed data (WorkflowConfiguration.cs)
|
|
47
|
+
builder.HasData(new { Id = ..., Code = "welcome-sequence", TriggerId = ..., IsActive = true, ... });
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Triggering
|
|
51
|
+
|
|
52
|
+
```csharp
|
|
53
|
+
// In Service or Controller
|
|
54
|
+
await _workflowService.TriggerAsync("user.registered", new Dictionary<string, object>
|
|
55
|
+
{
|
|
56
|
+
["userId"] = user.Id,
|
|
57
|
+
["email"] = user.Email,
|
|
58
|
+
["confirmUrl"] = GenerateConfirmUrl(user.Id)
|
|
59
|
+
}, language: "en", ct);
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Email Templates
|
|
63
|
+
|
|
64
|
+
### Structure
|
|
65
|
+
```csharp
|
|
66
|
+
EmailTemplate: Code, Name, Category, IsActive, Translations[]
|
|
67
|
+
EmailTemplateTranslation: LanguageCode, Subject, HtmlBody, TextBody
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Syntax (Handlebars)
|
|
71
|
+
```html
|
|
72
|
+
<h1>Welcome {{userName}}!</h1>
|
|
73
|
+
{{#if isPremium}}<p>Thank you Premium member!</p>{{else}}<p>Premium offers...</p>{{/if}}
|
|
74
|
+
{{#each items}}<li>{{this.name}}</li>{{/each}}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Frontend API
|
|
78
|
+
|
|
79
|
+
```typescript
|
|
80
|
+
workflowsApi.getAll() / getById(id) / create(data) / update(id, data)
|
|
81
|
+
workflowsApi.getTriggers()
|
|
82
|
+
workflowsApi.addStep(workflowId, step) / updateStep / deleteStep / reorderSteps
|
|
83
|
+
workflowsApi.execute(workflowId, variables)
|
|
84
|
+
```
|