musubix 1.1.9 → 1.1.13
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/.github/skills/musubix-adr-generation/SKILL.md +209 -0
- package/.github/skills/musubix-best-practices/SKILL.md +315 -0
- package/.github/skills/musubix-c4-design/SKILL.md +162 -0
- package/.github/skills/musubix-domain-inference/SKILL.md +196 -0
- package/.github/skills/musubix-test-generation/SKILL.md +212 -0
- package/.github/skills/musubix-traceability/SKILL.md +141 -0
- package/AGENTS.md +54 -29
- package/README.ja.md +1 -1
- package/README.md +4 -4
- package/docs/Test-prompt.md +105 -0
- package/docs/evolution-from-musubi-to-musubix.md +213 -19
- package/package.json +4 -5
- package/steering/project.yml +3 -3
- package/steering/tech.ja.md +62 -8
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: musubix-domain-inference
|
|
3
|
+
description: Guide for automatic domain detection and component inference. Use this when asked to identify the domain of a project and get recommended components for that domain.
|
|
4
|
+
license: MIT
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# MUSUBIX Domain Inference Skill
|
|
8
|
+
|
|
9
|
+
This skill guides you through automatic domain detection and component recommendations.
|
|
10
|
+
|
|
11
|
+
## Overview
|
|
12
|
+
|
|
13
|
+
MUSUBIX supports **62 domains** with **224 predefined components**. The domain inference system automatically:
|
|
14
|
+
|
|
15
|
+
1. Detects project domain from requirements/descriptions
|
|
16
|
+
2. Recommends optimal components for that domain
|
|
17
|
+
3. Suggests architecture patterns
|
|
18
|
+
|
|
19
|
+
## Supported Domains (62)
|
|
20
|
+
|
|
21
|
+
### Business (8)
|
|
22
|
+
| Domain | Description | Key Components |
|
|
23
|
+
|--------|-------------|----------------|
|
|
24
|
+
| ecommerce | EC・通販 | CartService, ProductCatalog, OrderProcessor |
|
|
25
|
+
| finance | 金融 | AccountService, TransactionManager, LedgerService |
|
|
26
|
+
| crm | 顧客管理 | CustomerService, LeadManager, OpportunityTracker |
|
|
27
|
+
| hr | 人事 | EmployeeService, PayrollCalculator, AttendanceTracker |
|
|
28
|
+
| marketing | マーケティング | CampaignManager, AudienceSegmenter, AnalyticsService |
|
|
29
|
+
| inventory | 在庫管理 | StockManager, ReorderService, WarehouseController |
|
|
30
|
+
| payment | 決済 | PaymentGateway, RefundProcessor, InvoiceGenerator |
|
|
31
|
+
| subscription | サブスク | PlanManager, BillingService, RenewalProcessor |
|
|
32
|
+
|
|
33
|
+
### Healthcare (3)
|
|
34
|
+
| Domain | Description | Key Components |
|
|
35
|
+
|--------|-------------|----------------|
|
|
36
|
+
| healthcare | ヘルスケア | PatientService, DiagnosticService, AppointmentManager |
|
|
37
|
+
| pharmacy | 薬局 | PrescriptionManager, MedicineInventory, DosageCalculator |
|
|
38
|
+
| veterinary | 動物病院 | PetService, VetScheduleService, VaccinationTracker |
|
|
39
|
+
|
|
40
|
+
### Service (20+)
|
|
41
|
+
| Domain | Description | Key Components |
|
|
42
|
+
|--------|-------------|----------------|
|
|
43
|
+
| booking | 予約 | ReservationService, SlotManager, AvailabilityChecker |
|
|
44
|
+
| hotel | ホテル | RoomService, CheckInManager, HousekeepingScheduler |
|
|
45
|
+
| restaurant | 飲食店 | MenuManager, TableService, KitchenOrderSystem |
|
|
46
|
+
| gym | フィットネス | MembershipService, ClassScheduler, TrainerAssignment |
|
|
47
|
+
| delivery | 配送 | DeliveryService, RouteOptimizer, TrackingManager |
|
|
48
|
+
| parking | 駐車場 | SpaceManager, EntryExitController, FeeCalculator |
|
|
49
|
+
|
|
50
|
+
### Technology (8)
|
|
51
|
+
| Domain | Description | Key Components |
|
|
52
|
+
|--------|-------------|----------------|
|
|
53
|
+
| iot | IoT | DeviceManager, TelemetryProcessor, AlertService |
|
|
54
|
+
| security | セキュリティ | AuthService, PermissionManager, AuditLogger |
|
|
55
|
+
| ai | AI | ModelService, InferenceEngine, TrainingPipeline |
|
|
56
|
+
| analytics | 分析 | ReportGenerator, MetricsCollector, DashboardService |
|
|
57
|
+
|
|
58
|
+
## Domain Detection
|
|
59
|
+
|
|
60
|
+
### Automatic Detection
|
|
61
|
+
|
|
62
|
+
MUSUBIX analyzes text for domain keywords:
|
|
63
|
+
|
|
64
|
+
```typescript
|
|
65
|
+
import { domainDetector } from '@nahisaho/musubix-core';
|
|
66
|
+
|
|
67
|
+
const result = domainDetector.detect(`
|
|
68
|
+
ペットの予約管理システムを作りたい。
|
|
69
|
+
獣医師のスケジュール管理と、ワクチン接種記録も必要。
|
|
70
|
+
`);
|
|
71
|
+
|
|
72
|
+
// Result:
|
|
73
|
+
// {
|
|
74
|
+
// primaryDomain: { id: 'veterinary', name: 'Veterinary', nameJa: '動物病院' },
|
|
75
|
+
// confidence: 0.92,
|
|
76
|
+
// matchedKeywords: ['ペット', '獣医', 'ワクチン', '予約'],
|
|
77
|
+
// suggestedComponents: ['PetService', 'ReservationService', 'VetScheduleService']
|
|
78
|
+
// }
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### CLI Usage
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
# Analyze requirements file
|
|
85
|
+
npx musubix design patterns --detect-domain storage/specs/REQ-001.md
|
|
86
|
+
|
|
87
|
+
# Get component recommendations
|
|
88
|
+
npx musubix design generate storage/specs/REQ-001.md --infer-components
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Component Inference
|
|
92
|
+
|
|
93
|
+
### Domain-Specific Components
|
|
94
|
+
|
|
95
|
+
Each domain has predefined components with:
|
|
96
|
+
- **Type**: Service, Repository, Controller, Factory, etc.
|
|
97
|
+
- **Layer**: Presentation, Application, Domain, Infrastructure
|
|
98
|
+
- **Dependencies**: Required collaborators
|
|
99
|
+
- **Patterns**: Recommended design patterns
|
|
100
|
+
- **Methods**: Domain-specific operations
|
|
101
|
+
|
|
102
|
+
### Example: Veterinary Domain
|
|
103
|
+
|
|
104
|
+
```typescript
|
|
105
|
+
const veterinaryComponents = [
|
|
106
|
+
{
|
|
107
|
+
name: 'PetService',
|
|
108
|
+
type: 'service',
|
|
109
|
+
layer: 'application',
|
|
110
|
+
description: 'ペット管理のビジネスロジック',
|
|
111
|
+
dependencies: ['PetRepository', 'PetHistoryRepository'],
|
|
112
|
+
patterns: ['Service'],
|
|
113
|
+
methods: [
|
|
114
|
+
{ name: 'register', returnType: 'Promise<Pet>' },
|
|
115
|
+
{ name: 'update', returnType: 'Promise<Pet>' },
|
|
116
|
+
{ name: 'getByOwner', returnType: 'Promise<Pet[]>' },
|
|
117
|
+
{ name: 'getHistory', returnType: 'Promise<PetHistory[]>' },
|
|
118
|
+
]
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
name: 'ReservationService',
|
|
122
|
+
type: 'service',
|
|
123
|
+
layer: 'application',
|
|
124
|
+
methods: [
|
|
125
|
+
{ name: 'create', returnType: 'Promise<Reservation>' },
|
|
126
|
+
{ name: 'confirm', returnType: 'Promise<Reservation>' },
|
|
127
|
+
{ name: 'cancel', returnType: 'Promise<Reservation>' },
|
|
128
|
+
{ name: 'getAvailableSlots', returnType: 'Promise<TimeSlot[]>' },
|
|
129
|
+
]
|
|
130
|
+
},
|
|
131
|
+
// ...more components
|
|
132
|
+
];
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Architecture Recommendations
|
|
136
|
+
|
|
137
|
+
Based on domain, MUSUBIX recommends:
|
|
138
|
+
|
|
139
|
+
| Domain Category | Architecture Style | Scaling Strategy |
|
|
140
|
+
|-----------------|-------------------|------------------|
|
|
141
|
+
| Business | Layered + DDD | Vertical with caching |
|
|
142
|
+
| Technology | Microservices | Horizontal scaling |
|
|
143
|
+
| Healthcare | Layered + Audit | Vertical with compliance |
|
|
144
|
+
| Service | Layered | Vertical with caching |
|
|
145
|
+
|
|
146
|
+
## Multi-Domain Projects
|
|
147
|
+
|
|
148
|
+
For projects spanning multiple domains:
|
|
149
|
+
|
|
150
|
+
```typescript
|
|
151
|
+
const result = domainDetector.detect(`
|
|
152
|
+
ECサイトで商品を販売し、配送追跡も行いたい。
|
|
153
|
+
在庫管理とサブスクリプション機能も必要。
|
|
154
|
+
`);
|
|
155
|
+
|
|
156
|
+
// Result:
|
|
157
|
+
// {
|
|
158
|
+
// primaryDomain: { id: 'ecommerce' },
|
|
159
|
+
// secondaryDomains: [
|
|
160
|
+
// { id: 'delivery' },
|
|
161
|
+
// { id: 'inventory' },
|
|
162
|
+
// { id: 'subscription' }
|
|
163
|
+
// ]
|
|
164
|
+
// }
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
## Using in Design Documents
|
|
168
|
+
|
|
169
|
+
```markdown
|
|
170
|
+
# DES-SHOP-001: ECサイト設計
|
|
171
|
+
|
|
172
|
+
## ドメイン分析
|
|
173
|
+
- **主ドメイン**: ecommerce
|
|
174
|
+
- **副ドメイン**: inventory, payment, delivery
|
|
175
|
+
|
|
176
|
+
## 推奨コンポーネント
|
|
177
|
+
|
|
178
|
+
### ecommerce ドメイン
|
|
179
|
+
| コンポーネント | 種別 | 責務 |
|
|
180
|
+
|---------------|------|------|
|
|
181
|
+
| CartService | Service | カート管理 |
|
|
182
|
+
| ProductCatalog | Service | 商品カタログ |
|
|
183
|
+
| OrderProcessor | Service | 注文処理 |
|
|
184
|
+
|
|
185
|
+
### inventory ドメイン
|
|
186
|
+
| コンポーネント | 種別 | 責務 |
|
|
187
|
+
|---------------|------|------|
|
|
188
|
+
| StockManager | Service | 在庫管理 |
|
|
189
|
+
| ReorderService | Service | 発注管理 |
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
## Related Skills
|
|
193
|
+
|
|
194
|
+
- `musubix-c4-design` - Create architecture with inferred components
|
|
195
|
+
- `musubix-code-generation` - Generate code for components
|
|
196
|
+
- `musubix-sdd-workflow` - Full workflow with domain awareness
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: musubix-test-generation
|
|
3
|
+
description: Guide for generating test code from designs and requirements. Use this when asked to create unit tests, integration tests, or test coverage analysis following TDD/BDD practices.
|
|
4
|
+
license: MIT
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# MUSUBIX Test Generation Skill
|
|
8
|
+
|
|
9
|
+
This skill guides you through generating comprehensive test suites that maintain traceability.
|
|
10
|
+
|
|
11
|
+
## Overview
|
|
12
|
+
|
|
13
|
+
MUSUBIX follows **Article III - Test-First**: Red-Green-Blue TDD cycle.
|
|
14
|
+
|
|
15
|
+
```mermaid
|
|
16
|
+
flowchart LR
|
|
17
|
+
RED[🔴 Red<br/>Failing Test] --> GREEN[🟢 Green<br/>Minimal Code]
|
|
18
|
+
GREEN --> BLUE[🔵 Blue<br/>Refactor]
|
|
19
|
+
BLUE --> RED
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Test Structure
|
|
23
|
+
|
|
24
|
+
### Unit Test Template
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
/**
|
|
28
|
+
* @requirement REQ-XXX-NNN
|
|
29
|
+
* @design DES-XXX-NNN
|
|
30
|
+
*/
|
|
31
|
+
import { describe, it, expect, beforeEach } from 'vitest';
|
|
32
|
+
import { XxxService } from './xxx-service.js';
|
|
33
|
+
import { resetXxxCounter } from './xxx-entity.js';
|
|
34
|
+
|
|
35
|
+
describe('XxxService', () => {
|
|
36
|
+
let service: XxxService;
|
|
37
|
+
let repository: MockXxxRepository;
|
|
38
|
+
|
|
39
|
+
beforeEach(() => {
|
|
40
|
+
// BP-TEST-001: Reset counters before each test
|
|
41
|
+
resetXxxCounter();
|
|
42
|
+
repository = new MockXxxRepository();
|
|
43
|
+
service = new XxxService(repository);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
describe('create', () => {
|
|
47
|
+
it('should create entity with valid input', async () => {
|
|
48
|
+
// Arrange
|
|
49
|
+
const input = { name: 'Test', value: 100 };
|
|
50
|
+
|
|
51
|
+
// Act
|
|
52
|
+
const result = await service.create(input);
|
|
53
|
+
|
|
54
|
+
// Assert
|
|
55
|
+
expect(result.isOk()).toBe(true);
|
|
56
|
+
if (result.isOk()) {
|
|
57
|
+
expect(result.value.name).toBe('Test');
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it('should return error for invalid input', async () => {
|
|
62
|
+
// Arrange
|
|
63
|
+
const input = { name: '', value: -1 };
|
|
64
|
+
|
|
65
|
+
// Act
|
|
66
|
+
const result = await service.create(input);
|
|
67
|
+
|
|
68
|
+
// Assert
|
|
69
|
+
expect(result.isErr()).toBe(true);
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Integration Test Template
|
|
76
|
+
|
|
77
|
+
```typescript
|
|
78
|
+
/**
|
|
79
|
+
* @requirement REQ-XXX-NNN
|
|
80
|
+
* @design DES-XXX-NNN
|
|
81
|
+
*/
|
|
82
|
+
import { describe, it, expect, beforeAll, afterAll } from 'vitest';
|
|
83
|
+
|
|
84
|
+
describe('XxxService Integration', () => {
|
|
85
|
+
beforeAll(async () => {
|
|
86
|
+
// Setup test environment
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
afterAll(async () => {
|
|
90
|
+
// Cleanup
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it('should complete full workflow', async () => {
|
|
94
|
+
// Test full user journey
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Best Practices for Testing
|
|
100
|
+
|
|
101
|
+
### BP-TEST-001: Test Counter Reset
|
|
102
|
+
|
|
103
|
+
```typescript
|
|
104
|
+
beforeEach(() => {
|
|
105
|
+
resetPetCounter(); // Reset ID counters
|
|
106
|
+
resetReservationCounter();
|
|
107
|
+
});
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### BP-TEST-002: Verify API Before Test
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
// ✅ Check actual API signature first
|
|
114
|
+
const service = new PetService(repository);
|
|
115
|
+
// Verify method exists and parameters match
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### BP-TEST-004: Result Type Test Pattern
|
|
119
|
+
|
|
120
|
+
```typescript
|
|
121
|
+
// ✅ Test both success and failure cases
|
|
122
|
+
it('should handle success', async () => {
|
|
123
|
+
const result = await service.create(validInput);
|
|
124
|
+
expect(result.isOk()).toBe(true);
|
|
125
|
+
if (result.isOk()) {
|
|
126
|
+
expect(result.value.id).toBeDefined();
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it('should handle failure', async () => {
|
|
131
|
+
const result = await service.create(invalidInput);
|
|
132
|
+
expect(result.isErr()).toBe(true);
|
|
133
|
+
if (result.isErr()) {
|
|
134
|
+
expect(result.error.message).toContain('validation');
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### BP-TEST-005: Status Transition Testing
|
|
140
|
+
|
|
141
|
+
```typescript
|
|
142
|
+
describe('status transitions', () => {
|
|
143
|
+
// Valid transitions
|
|
144
|
+
it('should allow draft -> active', () => {
|
|
145
|
+
const result = workflow.transition('draft', 'activate');
|
|
146
|
+
expect(result).toBe('active');
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
// Invalid transitions
|
|
150
|
+
it('should reject completed -> draft', () => {
|
|
151
|
+
expect(() => workflow.transition('completed', 'revert'))
|
|
152
|
+
.toThrow('Invalid transition');
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## Test Categories
|
|
158
|
+
|
|
159
|
+
| Category | Purpose | Location |
|
|
160
|
+
|----------|---------|----------|
|
|
161
|
+
| Unit | Single component | `__tests__/unit/` |
|
|
162
|
+
| Integration | Multiple components | `__tests__/integration/` |
|
|
163
|
+
| E2E | Full user flows | `__tests__/e2e/` |
|
|
164
|
+
|
|
165
|
+
## CLI Commands
|
|
166
|
+
|
|
167
|
+
```bash
|
|
168
|
+
# Generate tests from design
|
|
169
|
+
npx musubix test generate storage/design/DES-XXX.md
|
|
170
|
+
|
|
171
|
+
# Run all tests
|
|
172
|
+
npm test
|
|
173
|
+
|
|
174
|
+
# Coverage report
|
|
175
|
+
npx musubix test coverage src/
|
|
176
|
+
|
|
177
|
+
# Run specific test file
|
|
178
|
+
npm test -- xxx.test.ts
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
## Vitest Configuration
|
|
182
|
+
|
|
183
|
+
```typescript
|
|
184
|
+
// vitest.config.ts
|
|
185
|
+
import { defineConfig } from 'vitest/config';
|
|
186
|
+
|
|
187
|
+
export default defineConfig({
|
|
188
|
+
test: {
|
|
189
|
+
globals: true,
|
|
190
|
+
environment: 'node',
|
|
191
|
+
include: ['**/*.test.ts'],
|
|
192
|
+
coverage: {
|
|
193
|
+
provider: 'v8',
|
|
194
|
+
reporter: ['text', 'json', 'html'],
|
|
195
|
+
},
|
|
196
|
+
},
|
|
197
|
+
});
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
## Coverage Targets
|
|
201
|
+
|
|
202
|
+
| Metric | Target |
|
|
203
|
+
|--------|--------|
|
|
204
|
+
| Line Coverage | ≥80% |
|
|
205
|
+
| Branch Coverage | ≥75% |
|
|
206
|
+
| Function Coverage | ≥90% |
|
|
207
|
+
|
|
208
|
+
## Related Skills
|
|
209
|
+
|
|
210
|
+
- `musubix-sdd-workflow` - Full SDD workflow with TDD
|
|
211
|
+
- `musubix-code-generation` - Generate code to test
|
|
212
|
+
- `musubix-traceability` - Link tests to requirements
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: musubix-traceability
|
|
3
|
+
description: Guide for managing traceability between requirements, designs, code, and tests. Use this when asked to verify traceability, create traceability matrices, or perform impact analysis.
|
|
4
|
+
license: MIT
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# MUSUBIX Traceability Skill
|
|
8
|
+
|
|
9
|
+
This skill guides you through maintaining full traceability across the development lifecycle.
|
|
10
|
+
|
|
11
|
+
## Overview
|
|
12
|
+
|
|
13
|
+
MUSUBIX enforces **Article V - Traceability**: Complete bidirectional tracing between:
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
Requirements (REQ-*) ↔ Design (DES-*) ↔ Tasks (TSK-*) ↔ Code ↔ Tests
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Traceability Matrix
|
|
20
|
+
|
|
21
|
+
### Creating a Traceability Matrix
|
|
22
|
+
|
|
23
|
+
```markdown
|
|
24
|
+
# Traceability Matrix
|
|
25
|
+
|
|
26
|
+
| 要件ID | 設計ID | タスクID | コード | テスト |
|
|
27
|
+
|--------|--------|---------|--------|--------|
|
|
28
|
+
| REQ-AUTH-001 | DES-AUTH-001 | TSK-001 | src/auth/auth-service.ts | auth.test.ts |
|
|
29
|
+
| REQ-AUTH-002 | DES-AUTH-001 | TSK-002 | src/auth/token-manager.ts | token.test.ts |
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### CLI Commands
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
# Generate traceability matrix
|
|
36
|
+
npx musubix trace matrix
|
|
37
|
+
|
|
38
|
+
# Impact analysis for a specific requirement
|
|
39
|
+
npx musubix trace impact REQ-AUTH-001
|
|
40
|
+
|
|
41
|
+
# Validate all traceability links
|
|
42
|
+
npx musubix trace validate
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Traceability in Code
|
|
46
|
+
|
|
47
|
+
### Adding Traceability Comments
|
|
48
|
+
|
|
49
|
+
```typescript
|
|
50
|
+
/**
|
|
51
|
+
* AuthService - 認証サービス
|
|
52
|
+
* @requirement REQ-AUTH-001
|
|
53
|
+
* @design DES-AUTH-001
|
|
54
|
+
* @task TSK-001
|
|
55
|
+
*/
|
|
56
|
+
export class AuthService {
|
|
57
|
+
/**
|
|
58
|
+
* ユーザー認証
|
|
59
|
+
* @requirement REQ-AUTH-001
|
|
60
|
+
*/
|
|
61
|
+
async authenticate(credentials: Credentials): Promise<Result<Token, AuthError>> {
|
|
62
|
+
// Implementation
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Test Traceability
|
|
68
|
+
|
|
69
|
+
```typescript
|
|
70
|
+
/**
|
|
71
|
+
* @requirement REQ-AUTH-001
|
|
72
|
+
* @design DES-AUTH-001
|
|
73
|
+
*/
|
|
74
|
+
describe('AuthService', () => {
|
|
75
|
+
describe('authenticate', () => {
|
|
76
|
+
it('should return token for valid credentials', async () => {
|
|
77
|
+
// Test implementation
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Impact Analysis
|
|
84
|
+
|
|
85
|
+
When a requirement changes, identify all affected artifacts:
|
|
86
|
+
|
|
87
|
+
```mermaid
|
|
88
|
+
flowchart LR
|
|
89
|
+
REQ[REQ-AUTH-001<br/>変更] --> DES[DES-AUTH-001<br/>設計]
|
|
90
|
+
DES --> TSK1[TSK-001<br/>タスク]
|
|
91
|
+
DES --> TSK2[TSK-002<br/>タスク]
|
|
92
|
+
TSK1 --> CODE1[auth-service.ts]
|
|
93
|
+
TSK2 --> CODE2[token-manager.ts]
|
|
94
|
+
CODE1 --> TEST1[auth.test.ts]
|
|
95
|
+
CODE2 --> TEST2[token.test.ts]
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Impact Analysis Steps
|
|
99
|
+
|
|
100
|
+
1. Identify changed requirement (REQ-*)
|
|
101
|
+
2. Find linked designs (DES-*)
|
|
102
|
+
3. Find linked tasks (TSK-*)
|
|
103
|
+
4. Locate affected code files
|
|
104
|
+
5. Identify tests to update
|
|
105
|
+
6. Update all artifacts
|
|
106
|
+
|
|
107
|
+
## Traceability Storage
|
|
108
|
+
|
|
109
|
+
```
|
|
110
|
+
storage/traceability/
|
|
111
|
+
├── matrix.json # Full traceability matrix
|
|
112
|
+
├── requirements-map.json # REQ -> DES mappings
|
|
113
|
+
├── design-map.json # DES -> TSK mappings
|
|
114
|
+
└── code-map.json # TSK -> Code mappings
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## Verification Checklist
|
|
118
|
+
|
|
119
|
+
Before completing any feature:
|
|
120
|
+
|
|
121
|
+
- [ ] All requirements have linked designs
|
|
122
|
+
- [ ] All designs have linked tasks
|
|
123
|
+
- [ ] All tasks have linked code
|
|
124
|
+
- [ ] All code has linked tests
|
|
125
|
+
- [ ] Traceability comments in code
|
|
126
|
+
- [ ] Matrix updated
|
|
127
|
+
|
|
128
|
+
## MCP Tool
|
|
129
|
+
|
|
130
|
+
Use MCP tool for automated validation:
|
|
131
|
+
|
|
132
|
+
```
|
|
133
|
+
Tool: sdd_validate_traceability
|
|
134
|
+
Description: Validates bidirectional traceability across all artifacts
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## Related Skills
|
|
138
|
+
|
|
139
|
+
- `musubix-sdd-workflow` - Full SDD workflow
|
|
140
|
+
- `musubix-ears-validation` - Requirements validation
|
|
141
|
+
- `musubix-test-generation` - Generate tests with traceability
|
package/AGENTS.md
CHANGED
|
@@ -8,14 +8,15 @@
|
|
|
8
8
|
|
|
9
9
|
| 項目 | 詳細 |
|
|
10
10
|
|------|------|
|
|
11
|
-
| **バージョン** | 1.1.
|
|
11
|
+
| **バージョン** | 1.1.11 |
|
|
12
12
|
| **言語** | TypeScript |
|
|
13
13
|
| **ランタイム** | Node.js >= 20.0.0 |
|
|
14
14
|
| **パッケージマネージャ** | npm >= 10.0.0 |
|
|
15
15
|
| **ビルドシステム** | モノレポ(npm workspaces) |
|
|
16
16
|
| **テストフレームワーク** | Vitest |
|
|
17
|
-
| **テスト数** |
|
|
18
|
-
| **コンポーネント数** |
|
|
17
|
+
| **テスト数** | 459 (全合格) |
|
|
18
|
+
| **コンポーネント数** | 224 (62ドメイン対応) |
|
|
19
|
+
| **Agent Skills** | 9 (Claude Code対応) |
|
|
19
20
|
|
|
20
21
|
---
|
|
21
22
|
|
|
@@ -276,9 +277,9 @@ npx musubix codegen generate <design.md> --output src/
|
|
|
276
277
|
|
|
277
278
|
---
|
|
278
279
|
|
|
279
|
-
## � 学習済みベストプラクティス(v1.1.
|
|
280
|
+
## � 学習済みベストプラクティス(v1.1.10 Updated!)
|
|
280
281
|
|
|
281
|
-
Project-07
|
|
282
|
+
Project-07〜14の実装から学習したパターンです。
|
|
282
283
|
|
|
283
284
|
### コードパターン
|
|
284
285
|
|
|
@@ -287,19 +288,29 @@ Project-07 Medical Clinic、Project-08 Property Rentalの実装から学習し
|
|
|
287
288
|
| BP-CODE-001 | Entity Input DTO | エンティティ作成にInput DTOオブジェクトを使用 | 95% |
|
|
288
289
|
| BP-CODE-002 | Date-based ID Format | PREFIX-YYYYMMDD-NNN形式でIDを生成 | 90% |
|
|
289
290
|
| BP-CODE-003 | Value Objects | ドメイン概念にValue Objectを使用 | 90% |
|
|
291
|
+
| BP-CODE-004 | Function-based Value Objects | クラスではなくinterface+factory関数でVO実装 | 95% |
|
|
292
|
+
| BP-CODE-005 | Result Type | 失敗可能な操作にResult<T, E>を使用 | 95% |
|
|
290
293
|
|
|
291
|
-
**
|
|
294
|
+
**Function-based Value Object例**:
|
|
292
295
|
```typescript
|
|
293
|
-
// ✅ 推奨:
|
|
294
|
-
interface
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
contact: ContactInfo;
|
|
296
|
+
// ✅ 推奨: Interface + Factory Function
|
|
297
|
+
interface Price {
|
|
298
|
+
readonly amount: number;
|
|
299
|
+
readonly currency: 'JPY';
|
|
298
300
|
}
|
|
299
|
-
function createPatient(input: CreatePatientInput): Patient { ... }
|
|
300
301
|
|
|
301
|
-
|
|
302
|
-
|
|
302
|
+
function createPrice(amount: number): Result<Price, ValidationError> {
|
|
303
|
+
if (amount < 100 || amount > 1_000_000) {
|
|
304
|
+
return err(new ValidationError('Price must be between 100 and 1,000,000 JPY'));
|
|
305
|
+
}
|
|
306
|
+
return ok({ amount, currency: 'JPY' });
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
// ❌ 非推奨: クラスベース(構造的型付けと相性が悪い)
|
|
310
|
+
class Price {
|
|
311
|
+
private constructor(readonly amount: number) {}
|
|
312
|
+
static create(amount: number): Price { ... }
|
|
313
|
+
}
|
|
303
314
|
```
|
|
304
315
|
|
|
305
316
|
### 設計パターン
|
|
@@ -309,15 +320,18 @@ function createPatient(name: PersonName, dob: Date, contact: ContactInfo): Patie
|
|
|
309
320
|
| BP-DESIGN-001 | Status Transition Map | 有効なステータス遷移をMapで定義 | 95% |
|
|
310
321
|
| BP-DESIGN-002 | Repository Async Pattern | 将来のDB移行に備えてasync化 | 85% |
|
|
311
322
|
| BP-DESIGN-003 | Service Layer with DI | リポジトリをDIしたService層 | 90% |
|
|
323
|
+
| BP-DESIGN-004 | Optimistic Locking | 同時編集検出のためのversion管理 | 90% |
|
|
324
|
+
| BP-DESIGN-005 | AuditService | データ変更の監査ログ記録 | 85% |
|
|
325
|
+
| BP-DESIGN-006 | Entity Counter Reset | テスト用のresetXxxCounter()関数を提供 | 95% |
|
|
326
|
+
| BP-DESIGN-007 | Expiry Time Logic | 有効期限をexpiresAtフィールドで明示管理 | 90% |
|
|
312
327
|
|
|
313
328
|
**Status Transition Map例**:
|
|
314
329
|
```typescript
|
|
315
330
|
const validStatusTransitions: Record<Status, Status[]> = {
|
|
316
|
-
draft: ['active'],
|
|
317
|
-
active: ['
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
expired: ['renewed'],
|
|
331
|
+
draft: ['active', 'cancelled'],
|
|
332
|
+
active: ['completed', 'cancelled'],
|
|
333
|
+
completed: [],
|
|
334
|
+
cancelled: [],
|
|
321
335
|
};
|
|
322
336
|
```
|
|
323
337
|
|
|
@@ -328,16 +342,27 @@ const validStatusTransitions: Record<Status, Status[]> = {
|
|
|
328
342
|
| BP-TEST-001 | Test Counter Reset | beforeEachでIDカウンターをリセット | 95% |
|
|
329
343
|
| BP-TEST-002 | Verify API Before Test | テスト前にAPIシグネチャを確認 | 80% |
|
|
330
344
|
| BP-TEST-003 | Vitest ESM Configuration | Vitest + TypeScript ESM構成 | 85% |
|
|
345
|
+
| BP-TEST-004 | Result Type Test Pattern | isOk()/isErr()で両方のケースをテスト | 95% |
|
|
346
|
+
| BP-TEST-005 | Status Transition Testing | 有効・無効な遷移を網羅的にテスト | 90% |
|
|
331
347
|
|
|
332
|
-
**
|
|
348
|
+
**Result Type Test例**:
|
|
333
349
|
```typescript
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
350
|
+
describe('createPrice', () => {
|
|
351
|
+
it('should create valid price', () => {
|
|
352
|
+
const result = createPrice(1000);
|
|
353
|
+
expect(result.isOk()).toBe(true);
|
|
354
|
+
if (result.isOk()) {
|
|
355
|
+
expect(result.value.amount).toBe(1000);
|
|
356
|
+
}
|
|
357
|
+
});
|
|
358
|
+
|
|
359
|
+
it('should reject price below minimum', () => {
|
|
360
|
+
const result = createPrice(50);
|
|
361
|
+
expect(result.isErr()).toBe(true);
|
|
362
|
+
if (result.isErr()) {
|
|
363
|
+
expect(result.error.message).toContain('100');
|
|
364
|
+
}
|
|
365
|
+
});
|
|
341
366
|
});
|
|
342
367
|
```
|
|
343
368
|
|
|
@@ -399,6 +424,6 @@ npx musubix learn best-practices --format markdown
|
|
|
399
424
|
---
|
|
400
425
|
|
|
401
426
|
**Agent**: GitHub Copilot / Claude
|
|
402
|
-
**Last Updated**: 2026-01-
|
|
403
|
-
**Version**: 1.1.
|
|
427
|
+
**Last Updated**: 2026-01-04
|
|
428
|
+
**Version**: 1.1.10
|
|
404
429
|
**Repository**: https://github.com/nahisaho/MUSUBIX
|