@polymorphism-tech/morph-spec 2.4.0 → 3.0.1
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/CLAUDE.md +75 -239
- package/bin/morph-spec.js +8 -0
- package/content/.claude/commands/morph-deploy.md +529 -0
- package/content/.claude/skills/level-0-meta/README.md +7 -0
- package/content/.claude/skills/{checklists → level-0-meta}/morph-checklist.md +117 -117
- package/content/.claude/skills/level-1-workflows/README.md +7 -0
- package/content/.claude/skills/{workflows → level-1-workflows}/morph-replicate.md +213 -213
- package/content/.claude/skills/{workflows → level-1-workflows}/phase-clarify.md +131 -131
- package/content/.claude/skills/{workflows → level-1-workflows}/phase-design.md +213 -205
- package/content/.claude/skills/{workflows → level-1-workflows}/phase-setup.md +106 -92
- package/content/.claude/skills/{workflows → level-1-workflows}/phase-tasks.md +164 -164
- package/content/.claude/skills/{workflows → level-1-workflows}/phase-uiux.md +169 -138
- package/content/.claude/skills/level-2-domains/README.md +14 -0
- package/content/.claude/skills/level-2-domains/architecture/prompt-engineer.md +189 -0
- package/content/.claude/skills/level-2-domains/architecture/seo-growth-hacker.md +320 -0
- package/content/.claude/skills/level-2-domains/infrastructure/azure-deploy-specialist.md +699 -0
- package/content/.claude/skills/{specialists → level-2-domains/quality}/testing-specialist.md +126 -126
- package/content/.claude/skills/level-3-technologies/README.md +7 -0
- package/content/.claude/skills/level-4-patterns/README.md +7 -0
- package/content/.morph/config/agents.json +744 -358
- package/content/.morph/config/config.template.json +33 -0
- package/content/.morph/docs/workflows/enforcement-pipeline.md +668 -0
- package/content/.morph/examples/scheduled-reports/decisions.md +158 -158
- package/content/.morph/examples/scheduled-reports/proposal.md +95 -95
- package/content/.morph/examples/scheduled-reports/spec.md +267 -267
- package/content/.morph/hooks/README.md +158 -0
- package/content/.morph/hooks/task-completed.js +73 -0
- package/content/.morph/hooks/teammate-idle.js +68 -0
- package/content/.morph/schemas/tasks.schema.json +220 -220
- package/content/.morph/standards/agent-teams-workflow.md +474 -0
- package/content/.morph/templates/CONTEXT-FEATURE.md +276 -0
- package/content/.morph/templates/CONTEXT.md +170 -0
- package/content/.morph/templates/clarify-questions.md +159 -159
- package/content/.morph/templates/contracts/Commands.cs +74 -74
- package/content/.morph/templates/contracts/Entities.cs +25 -25
- package/content/.morph/templates/contracts/Queries.cs +74 -74
- package/content/.morph/templates/contracts/README.md +74 -74
- package/content/.morph/templates/infra/azure-pipelines-deploy.yml +480 -0
- package/package.json +1 -2
- package/scripts/reorganize-skills.cjs +175 -0
- package/scripts/validate-agents-structure.cjs +52 -0
- package/scripts/validate-skills.cjs +180 -0
- package/src/commands/advance-phase.js +83 -0
- package/src/commands/deploy.js +780 -0
- package/src/commands/detect-agents.js +43 -6
- package/src/commands/detect.js +1 -1
- package/src/commands/generate-context.js +40 -0
- package/src/commands/state.js +2 -1
- package/src/commands/sync.js +1 -1
- package/src/commands/update.js +13 -1
- package/src/lib/context-generator.js +513 -0
- package/src/lib/design-system-detector.js +187 -0
- package/src/lib/design-system-scaffolder.js +299 -0
- package/src/lib/hook-executor.js +256 -0
- package/src/lib/spec-validator.js +258 -0
- package/src/lib/standards-context-injector.js +287 -0
- package/src/lib/state-manager.js +21 -4
- package/src/lib/team-orchestrator.js +322 -0
- package/src/lib/validation-runner.js +65 -13
- package/src/lib/validators/design-system-validator.js +231 -0
- package/src/utils/file-copier.js +9 -1
- /package/content/.claude/skills/{checklists → level-0-meta}/code-review.md +0 -0
- /package/content/.claude/skills/{checklists → level-0-meta}/simulation-checklist.md +0 -0
- /package/content/.claude/skills/{specialists → level-2-domains/ai-agents}/ai-system-architect.md +0 -0
- /package/content/.claude/skills/{specialists → level-2-domains/architecture}/po-pm-advisor.md +0 -0
- /package/content/.claude/skills/{specialists → level-2-domains/architecture}/standards-architect.md +0 -0
- /package/content/.claude/skills/{specialists → level-2-domains/backend}/dotnet-senior.md +0 -0
- /package/content/.claude/skills/{specialists → level-2-domains/backend}/ef-modeler.md +0 -0
- /package/content/.claude/skills/{specialists → level-2-domains/backend}/hangfire-orchestrator.md +0 -0
- /package/content/.claude/skills/{specialists → level-2-domains/backend}/ms-agent-expert.md +0 -0
- /package/content/.claude/skills/{stacks/dotnet-blazor.md → level-2-domains/frontend/blazor-builder.md} +0 -0
- /package/content/.claude/skills/{stacks/dotnet-nextjs.md → level-2-domains/frontend/nextjs-expert.md} +0 -0
- /package/content/.claude/skills/{specialists → level-2-domains/frontend}/ui-ux-designer.md +0 -0
- /package/content/.claude/skills/{specialists → level-2-domains/infrastructure}/azure-architect.md +0 -0
- /package/content/.claude/skills/{infra → level-2-domains/infrastructure}/bicep-architect.md +0 -0
- /package/content/.claude/skills/{infra → level-2-domains/infrastructure}/container-specialist.md +0 -0
- /package/content/.claude/skills/{infra → level-2-domains/infrastructure}/devops-engineer.md +0 -0
- /package/content/.claude/skills/{integrations → level-2-domains/integrations}/asaas-financial.md +0 -0
- /package/content/.claude/skills/{integrations → level-2-domains/integrations}/azure-identity.md +0 -0
- /package/content/.claude/skills/{integrations → level-2-domains/integrations}/clerk-auth.md +0 -0
- /package/content/.claude/skills/{integrations → level-2-domains/integrations}/resend-email.md +0 -0
- /package/content/.claude/skills/{specialists → level-2-domains/quality}/code-analyzer.md +0 -0
- /package/{detectors → src/lib/detectors}/config-detector.js +0 -0
- /package/{detectors → src/lib/detectors}/conversation-analyzer.js +0 -0
- /package/{detectors → src/lib/detectors}/index.js +0 -0
- /package/{detectors → src/lib/detectors}/standards-generator.js +0 -0
- /package/{detectors → src/lib/detectors}/structure-detector.js +0 -0
package/content/.claude/skills/{specialists → level-2-domains/quality}/testing-specialist.md
RENAMED
|
@@ -1,126 +1,126 @@
|
|
|
1
|
-
# Testing Specialist
|
|
2
|
-
|
|
3
|
-
> **Layer:** 2 | **Load:** on-keyword | **Keywords:** test, testing, mock, fake, simulation, unit test, integration test
|
|
4
|
-
|
|
5
|
-
Especialista em testes, mocking e simulação para projetos .NET.
|
|
6
|
-
|
|
7
|
-
## Strategy
|
|
8
|
-
|
|
9
|
-
| Level | What | Tools |
|
|
10
|
-
|-------|------|-------|
|
|
11
|
-
| **Unit** | Business logic, domain, handlers | xUnit + Moq + FluentAssertions |
|
|
12
|
-
| **Integration** | API flows, DB operations | WebApplicationFactory + TestContainers |
|
|
13
|
-
| **Component** | Blazor rendering, events | bUnit |
|
|
14
|
-
| **E2E** | Critical user journeys | Playwright (if needed) |
|
|
15
|
-
|
|
16
|
-
**Focus:** Critical/complex code. Don't aim for 100%, aim for value. Cover edge cases and error paths.
|
|
17
|
-
|
|
18
|
-
---
|
|
19
|
-
|
|
20
|
-
## Core Patterns
|
|
21
|
-
|
|
22
|
-
### AAA (Arrange-Act-Assert)
|
|
23
|
-
|
|
24
|
-
```csharp
|
|
25
|
-
[Fact]
|
|
26
|
-
public async Task CreateOrder_Should_ReturnSuccess_When_ValidInput()
|
|
27
|
-
{
|
|
28
|
-
// Arrange
|
|
29
|
-
var command = new CreateOrderCommand { CustomerId = 1, Items = [...] };
|
|
30
|
-
var handler = new CreateOrderHandler(_mockRepo.Object);
|
|
31
|
-
// Act
|
|
32
|
-
var result = await handler.Handle(command, CancellationToken.None);
|
|
33
|
-
// Assert
|
|
34
|
-
result.IsSuccess.Should().BeTrue();
|
|
35
|
-
}
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
### Naming Convention
|
|
39
|
-
```
|
|
40
|
-
[Method]_Should_[ExpectedResult]_When_[Condition]
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
### Test Data Builders
|
|
44
|
-
Use builder pattern for complex test entities: `new OrderBuilder().WithCustomer(123).WithStatus(Completed).Build()`
|
|
45
|
-
|
|
46
|
-
### Mocking (Moq)
|
|
47
|
-
```csharp
|
|
48
|
-
var mockRepo = new Mock<IOrderRepository>();
|
|
49
|
-
mockRepo.Setup(r => r.GetByIdAsync(It.IsAny<int>())).ReturnsAsync(new Order { Id = 1 });
|
|
50
|
-
mockRepo.Verify(r => r.SaveAsync(It.IsAny<Order>()), Times.Once);
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
### Integration Tests (WebApplicationFactory)
|
|
54
|
-
Replace real DB with in-memory in `ConfigureServices`, use `CreateClient()` for HTTP calls.
|
|
55
|
-
|
|
56
|
-
### bUnit (Blazor)
|
|
57
|
-
`RenderComponent<Counter>()` → `Find("button").Click()` → assert `TextContent`.
|
|
58
|
-
|
|
59
|
-
---
|
|
60
|
-
|
|
61
|
-
## Libraries
|
|
62
|
-
|
|
63
|
-
| Library | Purpose | NuGet |
|
|
64
|
-
|---------|---------|-------|
|
|
65
|
-
| xUnit | Test framework | `xunit` |
|
|
66
|
-
| Moq | Mocking | `Moq` |
|
|
67
|
-
| FluentAssertions | Readable assertions | `FluentAssertions` |
|
|
68
|
-
| Bogus | Fake data | `Bogus` |
|
|
69
|
-
| TestContainers | DB containers | `Testcontainers` |
|
|
70
|
-
| Respawn | DB reset | `Respawn` |
|
|
71
|
-
| WireMock | HTTP mocking | `WireMock.Net` |
|
|
72
|
-
| bUnit | Blazor testing | `bunit` |
|
|
73
|
-
|
|
74
|
-
## Folder Structure
|
|
75
|
-
|
|
76
|
-
```
|
|
77
|
-
tests/
|
|
78
|
-
├── Unit/{Domain,Application,Builders}/
|
|
79
|
-
├── Integration/{Api,Fixtures}/
|
|
80
|
-
└── E2E/
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
## Anti-Patterns
|
|
84
|
-
1. **Fragile tests** — test behavior, not implementation
|
|
85
|
-
2. **Slow tests** — use mocks, not real DB for unit tests
|
|
86
|
-
3. **Coupled tests** — each test independent
|
|
87
|
-
4. **Vague assertions** — use specific FluentAssertions
|
|
88
|
-
5. **Giant setup** — extract to builders/fixtures
|
|
89
|
-
|
|
90
|
-
---
|
|
91
|
-
|
|
92
|
-
## Simulation of External Services
|
|
93
|
-
|
|
94
|
-
> **Ref:** `.claude/skills/checklists/simulation-checklist.md` for complete checklist
|
|
95
|
-
|
|
96
|
-
### Key Rules
|
|
97
|
-
|
|
98
|
-
| Mock Type | Characteristic | DI Lifetime |
|
|
99
|
-
|-----------|---------------|-------------|
|
|
100
|
-
| **Stateful** (Dictionary, List) | Keeps data between calls | `Singleton` |
|
|
101
|
-
| **Stateless** | No state | `Scoped` |
|
|
102
|
-
|
|
103
|
-
```csharp
|
|
104
|
-
// ❌ Stateful with Scoped = loses state between requests
|
|
105
|
-
services.AddScoped<IReplicateClient, FakeReplicateClient>();
|
|
106
|
-
// ✅ Stateful with Singleton
|
|
107
|
-
services.AddSingleton<IReplicateClient, FakeReplicateClient>();
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
**Before implementing mocks:** Map ALL dependencies (interfaces, transitive deps, lifetimes).
|
|
111
|
-
|
|
112
|
-
---
|
|
113
|
-
|
|
114
|
-
## Checklists
|
|
115
|
-
|
|
116
|
-
### Per Test Type
|
|
117
|
-
| Target | Test |
|
|
118
|
-
|--------|------|
|
|
119
|
-
| Entity/Domain | Creation validation, state transitions (valid + invalid), invariants |
|
|
120
|
-
| Handler/Service | Happy path, invalid input, not found (404), auth error, timeout |
|
|
121
|
-
| API | Status codes, response body, request validation, auth |
|
|
122
|
-
| Blazor Component | Initial render, user events, states (loading/error/empty), form validation |
|
|
123
|
-
|
|
124
|
-
---
|
|
125
|
-
|
|
126
|
-
*MORPH-SPEC by Polymorphism Tech*
|
|
1
|
+
# Testing Specialist
|
|
2
|
+
|
|
3
|
+
> **Layer:** 2 | **Load:** on-keyword | **Keywords:** test, testing, mock, fake, simulation, unit test, integration test
|
|
4
|
+
|
|
5
|
+
Especialista em testes, mocking e simulação para projetos .NET.
|
|
6
|
+
|
|
7
|
+
## Strategy
|
|
8
|
+
|
|
9
|
+
| Level | What | Tools |
|
|
10
|
+
|-------|------|-------|
|
|
11
|
+
| **Unit** | Business logic, domain, handlers | xUnit + Moq + FluentAssertions |
|
|
12
|
+
| **Integration** | API flows, DB operations | WebApplicationFactory + TestContainers |
|
|
13
|
+
| **Component** | Blazor rendering, events | bUnit |
|
|
14
|
+
| **E2E** | Critical user journeys | Playwright (if needed) |
|
|
15
|
+
|
|
16
|
+
**Focus:** Critical/complex code. Don't aim for 100%, aim for value. Cover edge cases and error paths.
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## Core Patterns
|
|
21
|
+
|
|
22
|
+
### AAA (Arrange-Act-Assert)
|
|
23
|
+
|
|
24
|
+
```csharp
|
|
25
|
+
[Fact]
|
|
26
|
+
public async Task CreateOrder_Should_ReturnSuccess_When_ValidInput()
|
|
27
|
+
{
|
|
28
|
+
// Arrange
|
|
29
|
+
var command = new CreateOrderCommand { CustomerId = 1, Items = [...] };
|
|
30
|
+
var handler = new CreateOrderHandler(_mockRepo.Object);
|
|
31
|
+
// Act
|
|
32
|
+
var result = await handler.Handle(command, CancellationToken.None);
|
|
33
|
+
// Assert
|
|
34
|
+
result.IsSuccess.Should().BeTrue();
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Naming Convention
|
|
39
|
+
```
|
|
40
|
+
[Method]_Should_[ExpectedResult]_When_[Condition]
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Test Data Builders
|
|
44
|
+
Use builder pattern for complex test entities: `new OrderBuilder().WithCustomer(123).WithStatus(Completed).Build()`
|
|
45
|
+
|
|
46
|
+
### Mocking (Moq)
|
|
47
|
+
```csharp
|
|
48
|
+
var mockRepo = new Mock<IOrderRepository>();
|
|
49
|
+
mockRepo.Setup(r => r.GetByIdAsync(It.IsAny<int>())).ReturnsAsync(new Order { Id = 1 });
|
|
50
|
+
mockRepo.Verify(r => r.SaveAsync(It.IsAny<Order>()), Times.Once);
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Integration Tests (WebApplicationFactory)
|
|
54
|
+
Replace real DB with in-memory in `ConfigureServices`, use `CreateClient()` for HTTP calls.
|
|
55
|
+
|
|
56
|
+
### bUnit (Blazor)
|
|
57
|
+
`RenderComponent<Counter>()` → `Find("button").Click()` → assert `TextContent`.
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## Libraries
|
|
62
|
+
|
|
63
|
+
| Library | Purpose | NuGet |
|
|
64
|
+
|---------|---------|-------|
|
|
65
|
+
| xUnit | Test framework | `xunit` |
|
|
66
|
+
| Moq | Mocking | `Moq` |
|
|
67
|
+
| FluentAssertions | Readable assertions | `FluentAssertions` |
|
|
68
|
+
| Bogus | Fake data | `Bogus` |
|
|
69
|
+
| TestContainers | DB containers | `Testcontainers` |
|
|
70
|
+
| Respawn | DB reset | `Respawn` |
|
|
71
|
+
| WireMock | HTTP mocking | `WireMock.Net` |
|
|
72
|
+
| bUnit | Blazor testing | `bunit` |
|
|
73
|
+
|
|
74
|
+
## Folder Structure
|
|
75
|
+
|
|
76
|
+
```
|
|
77
|
+
tests/
|
|
78
|
+
├── Unit/{Domain,Application,Builders}/
|
|
79
|
+
├── Integration/{Api,Fixtures}/
|
|
80
|
+
└── E2E/
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Anti-Patterns
|
|
84
|
+
1. **Fragile tests** — test behavior, not implementation
|
|
85
|
+
2. **Slow tests** — use mocks, not real DB for unit tests
|
|
86
|
+
3. **Coupled tests** — each test independent
|
|
87
|
+
4. **Vague assertions** — use specific FluentAssertions
|
|
88
|
+
5. **Giant setup** — extract to builders/fixtures
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## Simulation of External Services
|
|
93
|
+
|
|
94
|
+
> **Ref:** `.claude/skills/checklists/simulation-checklist.md` for complete checklist
|
|
95
|
+
|
|
96
|
+
### Key Rules
|
|
97
|
+
|
|
98
|
+
| Mock Type | Characteristic | DI Lifetime |
|
|
99
|
+
|-----------|---------------|-------------|
|
|
100
|
+
| **Stateful** (Dictionary, List) | Keeps data between calls | `Singleton` |
|
|
101
|
+
| **Stateless** | No state | `Scoped` |
|
|
102
|
+
|
|
103
|
+
```csharp
|
|
104
|
+
// ❌ Stateful with Scoped = loses state between requests
|
|
105
|
+
services.AddScoped<IReplicateClient, FakeReplicateClient>();
|
|
106
|
+
// ✅ Stateful with Singleton
|
|
107
|
+
services.AddSingleton<IReplicateClient, FakeReplicateClient>();
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
**Before implementing mocks:** Map ALL dependencies (interfaces, transitive deps, lifetimes).
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
## Checklists
|
|
115
|
+
|
|
116
|
+
### Per Test Type
|
|
117
|
+
| Target | Test |
|
|
118
|
+
|--------|------|
|
|
119
|
+
| Entity/Domain | Creation validation, state transitions (valid + invalid), invariants |
|
|
120
|
+
| Handler/Service | Happy path, invalid input, not found (404), auth error, timeout |
|
|
121
|
+
| API | Status codes, response body, request validation, auth |
|
|
122
|
+
| Blazor Component | Initial render, user events, states (loading/error/empty), form validation |
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
*MORPH-SPEC by Polymorphism Tech*
|