@su-record/vibe 2.4.56 → 2.4.57
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 +7 -18
- package/agents/compounder.md +1 -1
- package/agents/implementer.md +2 -1
- package/agents/simplifier.md +2 -1
- package/commands/vibe.run.md +4 -1
- package/commands/vibe.spec.md +56 -3
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +0 -4
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/postinstall.js +32 -1
- package/dist/cli/postinstall.js.map +1 -1
- package/dist/cli/setup.d.ts +18 -4
- package/dist/cli/setup.d.ts.map +1 -1
- package/dist/cli/setup.js +87 -27
- package/dist/cli/setup.js.map +1 -1
- package/dist/cli/types.d.ts +6 -0
- package/dist/cli/types.d.ts.map +1 -1
- package/languages/csharp-unity.md +516 -0
- package/languages/gdscript-godot.md +470 -0
- package/languages/ruby-rails.md +489 -0
- package/languages/typescript-angular.md +433 -0
- package/languages/typescript-astro.md +416 -0
- package/languages/typescript-electron.md +407 -0
- package/languages/typescript-nestjs.md +524 -0
- package/languages/typescript-svelte.md +407 -0
- package/languages/typescript-tauri.md +366 -0
- package/package.json +1 -1
- package/skills/vibe-capabilities.md +1 -1
- package/vibe/constitution.md +130 -97
- package/vibe/rules/core/communication-guide.md +50 -56
- package/vibe/rules/core/development-philosophy.md +35 -36
- package/vibe/rules/core/quick-start.md +66 -85
- package/vibe/rules/quality/bdd-contract-testing.md +94 -89
- package/vibe/rules/quality/checklist.md +132 -132
- package/vibe/rules/quality/testing-strategy.md +132 -129
- package/vibe/rules/standards/anti-patterns.md +74 -74
- package/vibe/rules/standards/code-structure.md +44 -44
- package/vibe/rules/standards/complexity-metrics.md +63 -62
- package/vibe/rules/standards/naming-conventions.md +72 -72
- package/vibe/templates/constitution-template.md +153 -95
- package/vibe/templates/contract-backend-template.md +41 -32
- package/vibe/templates/contract-frontend-template.md +35 -30
- package/vibe/templates/feature-template.md +33 -33
- package/vibe/templates/spec-template.md +118 -96
|
@@ -1,66 +1,66 @@
|
|
|
1
1
|
# BDD + Contract Testing Guide
|
|
2
2
|
|
|
3
|
-
**
|
|
3
|
+
**Testing strategy optimized for AI-driven development**
|
|
4
4
|
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
##
|
|
7
|
+
## Overview
|
|
8
8
|
|
|
9
|
-
BDD (Behavior-Driven Development)
|
|
9
|
+
BDD (Behavior-Driven Development) and Contract Testing are essential for **AI agents to accurately understand requirements and generate verifiable code**.
|
|
10
10
|
|
|
11
|
-
###
|
|
11
|
+
### Why is it useful for AI-driven development?
|
|
12
12
|
|
|
13
|
-
1.
|
|
14
|
-
2.
|
|
15
|
-
3.
|
|
16
|
-
4.
|
|
13
|
+
1. **Clear input/output contracts** → AI can implement accurately
|
|
14
|
+
2. **Automated verification** → Immediately verify AI-generated code quality
|
|
15
|
+
3. **Regression prevention** → AI modifications don't break existing functionality
|
|
16
|
+
4. **Automated documentation** → Tests serve as executable specifications
|
|
17
17
|
|
|
18
18
|
---
|
|
19
19
|
|
|
20
20
|
## Workflow
|
|
21
21
|
|
|
22
22
|
```
|
|
23
|
-
SPEC
|
|
23
|
+
Write SPEC (Requirements)
|
|
24
24
|
↓
|
|
25
|
-
Feature
|
|
25
|
+
Generate Feature file (Gherkin)
|
|
26
26
|
↓
|
|
27
|
-
Contract
|
|
27
|
+
Generate Contract tests (API schema)
|
|
28
28
|
↓
|
|
29
|
-
|
|
29
|
+
Run tests (Red)
|
|
30
30
|
↓
|
|
31
|
-
AI
|
|
31
|
+
AI agent implementation
|
|
32
32
|
↓
|
|
33
|
-
|
|
33
|
+
Run tests (Green)
|
|
34
34
|
↓
|
|
35
|
-
|
|
35
|
+
Refactoring
|
|
36
36
|
↓
|
|
37
|
-
|
|
37
|
+
Run tests again (Stay Green)
|
|
38
38
|
```
|
|
39
39
|
|
|
40
40
|
---
|
|
41
41
|
|
|
42
42
|
## 1. BDD (Behavior-Driven Development)
|
|
43
43
|
|
|
44
|
-
### Gherkin
|
|
44
|
+
### Gherkin Syntax
|
|
45
45
|
|
|
46
46
|
```gherkin
|
|
47
|
-
Feature:
|
|
48
|
-
As a
|
|
49
|
-
I want to
|
|
50
|
-
So that
|
|
51
|
-
|
|
52
|
-
Scenario:
|
|
53
|
-
Given
|
|
54
|
-
When "test@example.com"
|
|
55
|
-
Then
|
|
56
|
-
And JWT
|
|
57
|
-
And
|
|
58
|
-
|
|
59
|
-
Scenario:
|
|
60
|
-
Given
|
|
61
|
-
When "test@example.com"
|
|
62
|
-
Then
|
|
63
|
-
And "Invalid credentials"
|
|
47
|
+
Feature: User Login
|
|
48
|
+
As a user
|
|
49
|
+
I want to login
|
|
50
|
+
So that I can access personalized services
|
|
51
|
+
|
|
52
|
+
Scenario: Successful login with valid credentials
|
|
53
|
+
Given user is registered with "test@example.com" and "password123"
|
|
54
|
+
When login is attempted with "test@example.com" and "password123"
|
|
55
|
+
Then login succeeds
|
|
56
|
+
And receives JWT token
|
|
57
|
+
And redirected to home screen
|
|
58
|
+
|
|
59
|
+
Scenario: Failed login with wrong password
|
|
60
|
+
Given user is registered with "test@example.com"
|
|
61
|
+
When login is attempted with "test@example.com" and "wrong-password"
|
|
62
|
+
Then login fails
|
|
63
|
+
And receives "Invalid credentials" error message
|
|
64
64
|
```
|
|
65
65
|
|
|
66
66
|
### Step Definitions (Python)
|
|
@@ -70,19 +70,19 @@ from pytest_bdd import scenarios, given, when, then, parsers
|
|
|
70
70
|
|
|
71
71
|
scenarios('features/login.feature')
|
|
72
72
|
|
|
73
|
-
@given(parsers.parse('
|
|
73
|
+
@given(parsers.parse('user is registered with "{email}" and "{password}"'))
|
|
74
74
|
def user_exists(context, email, password):
|
|
75
75
|
context.user = create_user(email=email, password=password)
|
|
76
76
|
|
|
77
|
-
@when(parsers.parse('"{email}"
|
|
77
|
+
@when(parsers.parse('login is attempted with "{email}" and "{password}"'))
|
|
78
78
|
def attempt_login(context, email, password):
|
|
79
79
|
context.response = login(email=email, password=password)
|
|
80
80
|
|
|
81
|
-
@then('
|
|
81
|
+
@then('login succeeds')
|
|
82
82
|
def login_succeeds(context):
|
|
83
83
|
assert context.response.status_code == 200
|
|
84
84
|
|
|
85
|
-
@then('JWT
|
|
85
|
+
@then('receives JWT token')
|
|
86
86
|
def receives_token(context):
|
|
87
87
|
assert 'access_token' in context.response.json()
|
|
88
88
|
```
|
|
@@ -91,7 +91,7 @@ def receives_token(context):
|
|
|
91
91
|
|
|
92
92
|
## 2. Contract Testing
|
|
93
93
|
|
|
94
|
-
### API
|
|
94
|
+
### API Contract Definition
|
|
95
95
|
|
|
96
96
|
```json
|
|
97
97
|
{
|
|
@@ -118,7 +118,7 @@ def receives_token(context):
|
|
|
118
118
|
}
|
|
119
119
|
```
|
|
120
120
|
|
|
121
|
-
### Contract
|
|
121
|
+
### Contract Test (Python)
|
|
122
122
|
|
|
123
123
|
```python
|
|
124
124
|
import pytest
|
|
@@ -143,7 +143,7 @@ RESPONSE_SCHEMA = {
|
|
|
143
143
|
}
|
|
144
144
|
|
|
145
145
|
def test_login_response_contract():
|
|
146
|
-
"""
|
|
146
|
+
"""Verify login response adheres to contract"""
|
|
147
147
|
response = client.post("/api/auth/login", json={
|
|
148
148
|
"email": "test@example.com",
|
|
149
149
|
"password": "password123"
|
|
@@ -151,56 +151,60 @@ def test_login_response_contract():
|
|
|
151
151
|
|
|
152
152
|
assert response.status_code == 200
|
|
153
153
|
|
|
154
|
-
#
|
|
154
|
+
# Validate response schema
|
|
155
155
|
validate(instance=response.json(), schema=RESPONSE_SCHEMA)
|
|
156
156
|
|
|
157
|
-
# JWT
|
|
157
|
+
# Validate JWT token format
|
|
158
158
|
token = response.json()["access_token"]
|
|
159
|
-
assert len(token.split('.')) == 3 # JWT
|
|
159
|
+
assert len(token.split('.')) == 3 # JWT has 3 parts
|
|
160
160
|
```
|
|
161
161
|
|
|
162
162
|
---
|
|
163
163
|
|
|
164
|
-
## 3. AI
|
|
164
|
+
## 3. AI Agent Utilization
|
|
165
165
|
|
|
166
|
-
### SPEC → Feature
|
|
166
|
+
### SPEC → Feature Auto-generation
|
|
167
167
|
|
|
168
|
-
AI
|
|
168
|
+
AI agent automatically converts SPEC Acceptance Criteria to Gherkin Scenarios:
|
|
169
169
|
|
|
170
170
|
**SPEC**:
|
|
171
|
+
|
|
171
172
|
```markdown
|
|
172
|
-
### REQ-001:
|
|
173
|
-
**WHEN**
|
|
174
|
-
**THEN** JWT
|
|
173
|
+
### REQ-001: User Login
|
|
174
|
+
**WHEN** login with valid credentials
|
|
175
|
+
**THEN** receive JWT token
|
|
175
176
|
|
|
176
177
|
#### Acceptance Criteria
|
|
177
|
-
- [ ]
|
|
178
|
-
- [ ] access_token
|
|
179
|
-
- [ ]
|
|
178
|
+
- [ ] Login with email and password
|
|
179
|
+
- [ ] Return access_token and refresh_token
|
|
180
|
+
- [ ] Invalid credentials return 400 error
|
|
180
181
|
```
|
|
181
182
|
|
|
182
183
|
**Generated Feature**:
|
|
184
|
+
|
|
183
185
|
```gherkin
|
|
184
|
-
Scenario:
|
|
185
|
-
Given
|
|
186
|
-
When
|
|
187
|
-
Then JWT access_token
|
|
188
|
-
And JWT refresh_token
|
|
186
|
+
Scenario: Successful login with valid credentials
|
|
187
|
+
Given user is registered
|
|
188
|
+
When login with valid email and password
|
|
189
|
+
Then receive JWT access_token
|
|
190
|
+
And receive JWT refresh_token
|
|
189
191
|
```
|
|
190
192
|
|
|
191
|
-
### API
|
|
193
|
+
### API Schema → Contract Auto-generation
|
|
192
194
|
|
|
193
|
-
AI
|
|
195
|
+
AI agent automatically converts SPEC API contracts to Contract tests:
|
|
194
196
|
|
|
195
197
|
**SPEC**:
|
|
198
|
+
|
|
196
199
|
```markdown
|
|
197
|
-
### Endpoint:
|
|
200
|
+
### Endpoint: Login
|
|
198
201
|
POST /api/auth/login
|
|
199
202
|
Request: { email, password }
|
|
200
203
|
Response: { access_token, refresh_token, user }
|
|
201
204
|
```
|
|
202
205
|
|
|
203
206
|
**Generated Contract Test**:
|
|
207
|
+
|
|
204
208
|
```python
|
|
205
209
|
def test_login_contract():
|
|
206
210
|
response = client.post("/api/auth/login", json=valid_credentials)
|
|
@@ -210,34 +214,34 @@ def test_login_contract():
|
|
|
210
214
|
|
|
211
215
|
---
|
|
212
216
|
|
|
213
|
-
## 4. Vibe
|
|
217
|
+
## 4. Vibe Commands
|
|
214
218
|
|
|
215
|
-
### Feature
|
|
219
|
+
### Generate Feature File
|
|
216
220
|
|
|
217
221
|
```bash
|
|
218
222
|
vibe feature "user login"
|
|
219
|
-
# → .claude/vibe/features/user-login.feature
|
|
223
|
+
# → Creates .claude/vibe/features/user-login.feature
|
|
220
224
|
```
|
|
221
225
|
|
|
222
|
-
### Contract
|
|
226
|
+
### Generate Contract Test
|
|
223
227
|
|
|
224
228
|
```bash
|
|
225
229
|
vibe contract "user login"
|
|
226
|
-
# → tests/contract/test_user_login_contract.py
|
|
230
|
+
# → Creates tests/contract/test_user_login_contract.py
|
|
227
231
|
```
|
|
228
232
|
|
|
229
|
-
###
|
|
233
|
+
### Run Tests
|
|
230
234
|
|
|
231
235
|
```bash
|
|
232
236
|
vibe test "user login"
|
|
233
|
-
# → BDD + Contract
|
|
237
|
+
# → Runs BDD + Contract tests
|
|
234
238
|
```
|
|
235
239
|
|
|
236
|
-
###
|
|
240
|
+
### Verify
|
|
237
241
|
|
|
238
242
|
```bash
|
|
239
243
|
vibe verify "user login"
|
|
240
|
-
# → SPEC Acceptance Criteria
|
|
244
|
+
# → Confirms 100% SPEC Acceptance Criteria met
|
|
241
245
|
```
|
|
242
246
|
|
|
243
247
|
---
|
|
@@ -246,18 +250,18 @@ vibe verify "user login"
|
|
|
246
250
|
|
|
247
251
|
### ✅ DO
|
|
248
252
|
|
|
249
|
-
1. **SPEC
|
|
250
|
-
2. **Given-When-Then**
|
|
251
|
-
3.
|
|
252
|
-
4.
|
|
253
|
-
5.
|
|
253
|
+
1. **Write SPEC first** → Feature → Contract → Implementation
|
|
254
|
+
2. **Clearly separate Given-When-Then**
|
|
255
|
+
3. **Be specific with contracts** (specify types, formats, constraints)
|
|
256
|
+
4. **Independent scenarios** (can run in any order)
|
|
257
|
+
5. **Include error cases** (Happy path + Sad path)
|
|
254
258
|
|
|
255
259
|
### ❌ DON'T
|
|
256
260
|
|
|
257
|
-
1.
|
|
258
|
-
2. **
|
|
259
|
-
3.
|
|
260
|
-
4.
|
|
261
|
+
1. **Don't expose implementation details** (keep in Step Definitions only)
|
|
262
|
+
2. **Don't confuse with UI testing** (BDD is for business logic)
|
|
263
|
+
3. **Don't overuse Background** (only for deduplication)
|
|
264
|
+
4. **Don't allow contract violations** (version up on schema changes)
|
|
261
265
|
|
|
262
266
|
---
|
|
263
267
|
|
|
@@ -305,7 +309,7 @@ jobs:
|
|
|
305
309
|
### Python (FastAPI)
|
|
306
310
|
|
|
307
311
|
```bash
|
|
308
|
-
#
|
|
312
|
+
# Project structure
|
|
309
313
|
project/
|
|
310
314
|
├── tests/
|
|
311
315
|
│ ├── features/ # Gherkin feature files
|
|
@@ -319,7 +323,7 @@ project/
|
|
|
319
323
|
### Flutter (Dart)
|
|
320
324
|
|
|
321
325
|
```bash
|
|
322
|
-
#
|
|
326
|
+
# Project structure
|
|
323
327
|
project/
|
|
324
328
|
├── integration_test/
|
|
325
329
|
│ ├── features/ # Gherkin feature files
|
|
@@ -334,7 +338,7 @@ project/
|
|
|
334
338
|
### React (TypeScript)
|
|
335
339
|
|
|
336
340
|
```bash
|
|
337
|
-
#
|
|
341
|
+
# Project structure
|
|
338
342
|
project/
|
|
339
343
|
├── tests/
|
|
340
344
|
│ ├── features/ # Gherkin feature files
|
|
@@ -373,16 +377,17 @@ project/
|
|
|
373
377
|
|
|
374
378
|
## Summary
|
|
375
379
|
|
|
376
|
-
BDD + Contract Testing
|
|
380
|
+
BDD + Contract Testing enables **AI agents to accurately implement SPECs and automatically verify**:
|
|
381
|
+
|
|
382
|
+
1. **Clear requirements** → Express business language with Gherkin
|
|
383
|
+
2. **Contract-based development** → Independent Frontend/Backend development with API schema
|
|
384
|
+
3. **Automated verification** → Immediately verify AI-generated code quality
|
|
385
|
+
4. **Regression prevention** → Protect existing functionality
|
|
377
386
|
|
|
378
|
-
|
|
379
|
-
2. **계약 기반 개발** → API 스키마로 Frontend/Backend 독립 개발
|
|
380
|
-
3. **자동화된 검증** → AI 생성 코드 품질 즉시 확인
|
|
381
|
-
4. **회귀 방지** → 기존 기능 보호
|
|
387
|
+
**Usage in Vibe**:
|
|
382
388
|
|
|
383
|
-
**Vibe에서 사용**:
|
|
384
389
|
```bash
|
|
385
390
|
vibe spec "feature" → vibe feature "feature" → vibe contract "feature" → vibe run
|
|
386
391
|
```
|
|
387
392
|
|
|
388
|
-
**Test-First → AI
|
|
393
|
+
**Test-First → AI Implementation → Verify → Done** 🎉
|