opencodekit 0.15.21 → 0.16.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/dist/index.js +5 -7
- package/dist/template/.opencode/AGENTS.md +85 -23
- package/dist/template/.opencode/agent/build.md +88 -7
- package/dist/template/.opencode/agent/explore.md +1 -1
- package/dist/template/.opencode/agent/general.md +54 -4
- package/dist/template/.opencode/agent/looker.md +1 -1
- package/dist/template/.opencode/agent/painter.md +1 -1
- package/dist/template/.opencode/agent/plan.md +52 -0
- package/dist/template/.opencode/agent/review.md +1 -1
- package/dist/template/.opencode/agent/scout.md +3 -3
- package/dist/template/.opencode/agent/vision.md +1 -1
- package/dist/template/.opencode/command/create.md +231 -91
- package/dist/template/.opencode/command/design.md +40 -7
- package/dist/template/.opencode/command/handoff.md +22 -0
- package/dist/template/.opencode/command/init.md +49 -78
- package/dist/template/.opencode/command/plan.md +36 -16
- package/dist/template/.opencode/command/pr.md +15 -0
- package/dist/template/.opencode/command/research.md +3 -0
- package/dist/template/.opencode/command/resume.md +8 -18
- package/dist/template/.opencode/command/review-codebase.md +30 -0
- package/dist/template/.opencode/command/ship.md +199 -0
- package/dist/template/.opencode/command/start.md +316 -28
- package/dist/template/.opencode/command/status.md +24 -1
- package/dist/template/.opencode/command/ui-review.md +36 -7
- package/dist/template/.opencode/command/verify.md +307 -0
- package/dist/template/.opencode/memory/_templates/prd.md +29 -0
- package/dist/template/.opencode/memory/_templates/proposal.md +38 -0
- package/dist/template/.opencode/memory/_templates/spec.md +66 -0
- package/dist/template/.opencode/memory/_templates/tasks.md +198 -0
- package/dist/template/.opencode/memory/_templates/tech-stack.md +50 -0
- package/dist/template/.opencode/memory/project/tech-stack.md +53 -0
- package/dist/template/.opencode/memory/research/ccpm-analysis.md +334 -0
- package/dist/template/.opencode/memory/research/openspec-analysis.md +226 -0
- package/dist/template/.opencode/memory.db +0 -0
- package/dist/template/.opencode/memory.db-shm +0 -0
- package/dist/template/.opencode/memory.db-wal +0 -0
- package/dist/template/.opencode/opencode.json +18 -4
- package/dist/template/.opencode/package.json +1 -0
- package/dist/template/.opencode/plans/1770006237537-mighty-otter.md +418 -0
- package/dist/template/.opencode/plans/1770006913647-glowing-forest.md +170 -0
- package/dist/template/.opencode/plans/1770013678126-witty-planet.md +278 -0
- package/dist/template/.opencode/plugin/lib/memory-db.ts +828 -0
- package/dist/template/.opencode/plugin/memory.ts +38 -1
- package/dist/template/.opencode/skill/index-knowledge/SKILL.md +76 -31
- package/dist/template/.opencode/skill/memory-system/SKILL.md +110 -55
- package/dist/template/.opencode/skill/tool-priority/SKILL.md +2 -2
- package/dist/template/.opencode/tool/memory-get.ts +143 -0
- package/dist/template/.opencode/tool/memory-maintain.ts +167 -0
- package/dist/template/.opencode/tool/memory-migrate.ts +319 -0
- package/dist/template/.opencode/tool/memory-read.ts +17 -46
- package/dist/template/.opencode/tool/memory-search.ts +131 -28
- package/dist/template/.opencode/tool/memory-timeline.ts +105 -0
- package/dist/template/.opencode/tool/memory-update.ts +21 -26
- package/dist/template/.opencode/tool/observation.ts +112 -100
- package/dist/template/.opencode/tsconfig.json +19 -19
- package/package.json +1 -1
- package/dist/template/.opencode/command/accessibility-check.md +0 -331
- package/dist/template/.opencode/command/agent-browser.md +0 -21
- package/dist/template/.opencode/command/analyze-mockup.md +0 -423
- package/dist/template/.opencode/command/analyze-project.md +0 -295
- package/dist/template/.opencode/command/brainstorm.md +0 -373
- package/dist/template/.opencode/command/cloudflare.md +0 -70
- package/dist/template/.opencode/command/commit.md +0 -245
- package/dist/template/.opencode/command/complete-next-task.md +0 -77
- package/dist/template/.opencode/command/design-audit.md +0 -480
- package/dist/template/.opencode/command/edit-image.md +0 -242
- package/dist/template/.opencode/command/finish.md +0 -255
- package/dist/template/.opencode/command/fix-ci.md +0 -109
- package/dist/template/.opencode/command/fix-types.md +0 -104
- package/dist/template/.opencode/command/fix-ui.md +0 -117
- package/dist/template/.opencode/command/fix.md +0 -168
- package/dist/template/.opencode/command/frontend-design.md +0 -21
- package/dist/template/.opencode/command/generate-diagram.md +0 -349
- package/dist/template/.opencode/command/generate-icon.md +0 -283
- package/dist/template/.opencode/command/generate-image.md +0 -246
- package/dist/template/.opencode/command/generate-pattern.md +0 -247
- package/dist/template/.opencode/command/generate-storyboard.md +0 -250
- package/dist/template/.opencode/command/implement.md +0 -609
- package/dist/template/.opencode/command/import-plan.md +0 -406
- package/dist/template/.opencode/command/index-knowledge.md +0 -25
- package/dist/template/.opencode/command/integration-test.md +0 -424
- package/dist/template/.opencode/command/issue.md +0 -102
- package/dist/template/.opencode/command/new-feature.md +0 -651
- package/dist/template/.opencode/command/opensrc.md +0 -58
- package/dist/template/.opencode/command/quick-build.md +0 -238
- package/dist/template/.opencode/command/ralph.md +0 -41
- package/dist/template/.opencode/command/research-and-implement.md +0 -148
- package/dist/template/.opencode/command/research-ui.md +0 -466
- package/dist/template/.opencode/command/restore-image.md +0 -424
- package/dist/template/.opencode/command/revert-feature.md +0 -386
- package/dist/template/.opencode/command/skill-create.md +0 -517
- package/dist/template/.opencode/command/skill-optimize.md +0 -556
- package/dist/template/.opencode/command/summarize.md +0 -412
- package/dist/template/.opencode/command/triage.md +0 -398
- package/dist/template/.opencode/memory/_templates/README.md +0 -35
- package/dist/template/.opencode/memory/_templates/observation.md +0 -39
- package/dist/template/.opencode/memory/_templates/project/architecture.md +0 -60
- package/dist/template/.opencode/memory/_templates/project/commands.md +0 -72
- package/dist/template/.opencode/memory/_templates/project/conventions.md +0 -68
- package/dist/template/.opencode/memory/_templates/project/gotchas.md +0 -41
- package/dist/template/.opencode/memory/_templates/prompt-engineering.md +0 -333
- package/dist/template/.opencode/memory/observations/2026-01-22-decision-agents-md-prompt-engineering-improvement.md +0 -29
- package/dist/template/.opencode/memory/observations/2026-01-25-decision-agent-roles-build-orchestrates-general-e.md +0 -14
- package/dist/template/.opencode/memory/observations/2026-01-25-decision-simplified-swarm-helper-tool-to-fix-type.md +0 -20
- package/dist/template/.opencode/memory/observations/2026-01-25-decision-use-beads-as-swarm-board-source-of-truth.md +0 -14
- package/dist/template/.opencode/memory/observations/2026-01-25-learning-user-wants-real-swarm-coordination-guida.md +0 -15
- package/dist/template/.opencode/memory/observations/2026-01-28-decision-created-deep-research-skill-for-thorough.md +0 -29
- package/dist/template/.opencode/memory/observations/2026-01-28-decision-gh-grep-mcp-wrapper-vs-native-grep-searc.md +0 -21
- package/dist/template/.opencode/memory/observations/2026-01-28-decision-oracle-tool-optimal-usage-patterns.md +0 -32
- package/dist/template/.opencode/memory/observations/2026-01-28-learning-ampcode-deep-mode-research-integration-w.md +0 -42
- package/dist/template/.opencode/memory/observations/2026-01-28-pattern-research-delegation-pattern-explore-for-.md +0 -32
- package/dist/template/.opencode/memory/observations/2026-01-29-decision-copilot-auth-plugin-rate-limit-handling.md +0 -27
- package/dist/template/.opencode/memory/observations/2026-01-29-decision-spec-driven-approach-for-opencodekit.md +0 -21
- package/dist/template/.opencode/memory/observations/2026-01-29-learning-karpathy-llm-coding-insights-dec-2025.md +0 -44
- package/dist/template/.opencode/memory/observations/2026-01-30-decision-github-copilot-claude-routing-keep-disab.md +0 -32
- package/dist/template/.opencode/memory/observations/2026-01-30-discovery-context-management-research-critical-gap.md +0 -14
- package/dist/template/.opencode/memory/observations/2026-01-30-discovery-kimi-k2-5-agent-swarm-architecture-patte.md +0 -45
- package/dist/template/.opencode/memory/observations/2026-01-30-pattern-swarm-tools-architecture.md +0 -28
- package/dist/template/.opencode/memory/observations/2026-01-31-decision-copilot-auth-plugin-updated-with-baseurl.md +0 -63
- package/dist/template/.opencode/memory/observations/2026-01-31-decision-created-dedicated-worker-agent-for-swarm.md +0 -20
- package/dist/template/.opencode/memory/observations/2026-01-31-decision-rollback-to-v1-1-47-for-copilot-claude-r.md +0 -21
- package/dist/template/.opencode/memory/observations/2026-01-31-decision-simplified-swarm-to-task-tool-pattern.md +0 -44
- package/dist/template/.opencode/memory/observations/2026-01-31-decision-swarm-architecture-task-tool-over-tmux.md +0 -33
- package/dist/template/.opencode/memory/observations/2026-01-31-decision-worker-skills-defined-for-swarm-delegati.md +0 -30
- package/dist/template/.opencode/memory/observations/2026-01-31-learning-gpt-reasoning-config-for-github-copilot.md +0 -51
- package/dist/template/.opencode/memory/observations/2026-01-31-learning-opencode-copilot-auth-comparison-finding.md +0 -61
- package/dist/template/.opencode/memory/observations/2026-01-31-learning-opencode-copilot-reasoning-architecture-.md +0 -66
- package/dist/template/.opencode/memory/observations/2026-01-31-learning-opencode-custom-tools-api.md +0 -48
- package/dist/template/.opencode/memory/observations/2026-01-31-learning-opencode-v1-1-48-skills-as-slash-command.md +0 -21
- package/dist/template/.opencode/memory/observations/2026-01-31-learning-swarm-system-simplified-removed-mailbox-.md +0 -30
- package/dist/template/.opencode/memory/observations/2026-01-31-learning-v1-1-48-native-copilot-reasoning-via-pr-.md +0 -45
- package/dist/template/.opencode/memory/observations/2026-01-31-warning-cannot-add-custom-config-to-opencode-jso.md +0 -18
- package/dist/template/.opencode/memory/observations/2026-01-31-warning-copilot-claude-v1-endpoint-returns-404-c.md +0 -48
- package/dist/template/.opencode/memory/observations/2026-01-31-warning-opencode-v1-1-48-claude-thinking-block-s.md +0 -51
- package/dist/template/.opencode/memory/project/architecture.md +0 -60
- package/dist/template/.opencode/memory/project/commands.md +0 -72
- package/dist/template/.opencode/memory/project/conventions.md +0 -68
- package/dist/template/.opencode/memory/project/gotchas.md +0 -41
- package/dist/template/.opencode/skill/notebooklm/SKILL.md +0 -272
- package/dist/template/.opencode/skill/notebooklm/references/setup.md +0 -353
- package/dist/template/.opencode/tool/notebooklm.ts +0 -488
- package/dist/template/.opencode/tool/oracle.ts +0 -240
- /package/dist/template/.opencode/memory/{user.example.md → _templates/user.md} +0 -0
- /package/dist/template/.opencode/memory/{user.md → project/user.md} +0 -0
|
@@ -1,424 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: Create integration tests within task constraints
|
|
3
|
-
argument-hint: "<bead-id|path> [--pattern=<pattern>] [--framework=<framework>]"
|
|
4
|
-
agent: build
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# Integration Test: $ARGUMENTS
|
|
8
|
-
|
|
9
|
-
Create integration tests that verify module boundaries and system interactions.
|
|
10
|
-
|
|
11
|
-
## Load Skills
|
|
12
|
-
|
|
13
|
-
```typescript
|
|
14
|
-
skill({ name: "beads" }); // Session protocol
|
|
15
|
-
skill({ name: "test-driven-development" });
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
```typescript
|
|
19
|
-
skill({ name: "test-driven-development" });
|
|
20
|
-
skill({ name: "condition-based-waiting" }); // For async tests
|
|
21
|
-
skill({ name: "testing-anti-patterns" }); // Avoid common mistakes
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
---
|
|
25
|
-
|
|
26
|
-
## What Are Integration Tests?
|
|
27
|
-
|
|
28
|
-
| Test Type | Scope | Speed | Dependencies |
|
|
29
|
-
| --------------- | --------------------------- | ------------ | -------------------- |
|
|
30
|
-
| **Unit** | Single function/class | Fast (ms) | All mocked |
|
|
31
|
-
| **Integration** | Module boundaries, APIs, DB | Medium (s) | Real or test doubles |
|
|
32
|
-
| **E2E** | Full user flows | Slow (s-min) | Real everything |
|
|
33
|
-
|
|
34
|
-
**Integration tests verify:**
|
|
35
|
-
|
|
36
|
-
- API endpoints work end-to-end
|
|
37
|
-
- Database queries return correct data
|
|
38
|
-
- Services communicate correctly
|
|
39
|
-
- External integrations behave as expected
|
|
40
|
-
|
|
41
|
-
---
|
|
42
|
-
|
|
43
|
-
## Phase 1: Task Validation
|
|
44
|
-
|
|
45
|
-
!`bd show $ARGUMENTS`
|
|
46
|
-
|
|
47
|
-
```typescript
|
|
48
|
-
// Read test constraints
|
|
49
|
-
read({ filePath: ".beads/artifacts/$ARGUMENTS/spec.md" });
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
If bead missing: STOP. Create with `/create` first.
|
|
53
|
-
|
|
54
|
-
---
|
|
55
|
-
|
|
56
|
-
## Phase 2: Framework Detection
|
|
57
|
-
|
|
58
|
-
```typescript
|
|
59
|
-
glob({ pattern: "**/jest.config.*" });
|
|
60
|
-
glob({ pattern: "**/vitest.config.*" });
|
|
61
|
-
glob({ pattern: "**/pytest.ini" });
|
|
62
|
-
glob({ pattern: "**/pyproject.toml" });
|
|
63
|
-
|
|
64
|
-
// Read package.json for test command
|
|
65
|
-
read({ filePath: "package.json" });
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
| Framework | File Pattern | Test Command |
|
|
69
|
-
| --------- | ------------------------ | ------------ |
|
|
70
|
-
| Jest | `*.test.ts`, `*.spec.ts` | `npm test` |
|
|
71
|
-
| Vitest | `*.test.ts`, `*.spec.ts` | `npm test` |
|
|
72
|
-
| pytest | `test_*.py`, `*_test.py` | `pytest` |
|
|
73
|
-
| Go | `*_test.go` | `go test` |
|
|
74
|
-
|
|
75
|
-
---
|
|
76
|
-
|
|
77
|
-
## Phase 3: Test Structure
|
|
78
|
-
|
|
79
|
-
### File Location
|
|
80
|
-
|
|
81
|
-
```
|
|
82
|
-
src/
|
|
83
|
-
├── auth/
|
|
84
|
-
│ ├── login.ts
|
|
85
|
-
│ └── login.test.ts # Co-located unit tests
|
|
86
|
-
tests/
|
|
87
|
-
├── integration/
|
|
88
|
-
│ ├── auth.test.ts # Integration tests here
|
|
89
|
-
│ ├── api.test.ts
|
|
90
|
-
│ └── database.test.ts
|
|
91
|
-
└── fixtures/
|
|
92
|
-
├── users.json
|
|
93
|
-
└── factories.ts
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
### Test File Structure
|
|
97
|
-
|
|
98
|
-
```typescript
|
|
99
|
-
// tests/integration/auth.test.ts
|
|
100
|
-
|
|
101
|
-
import { describe, it, expect, beforeAll, afterAll, beforeEach } from "vitest";
|
|
102
|
-
import { createTestDatabase, cleanupDatabase } from "../fixtures/database";
|
|
103
|
-
import { createTestUser } from "../fixtures/factories";
|
|
104
|
-
import { app } from "../../src/app";
|
|
105
|
-
|
|
106
|
-
describe("Auth Integration", () => {
|
|
107
|
-
let db: TestDatabase;
|
|
108
|
-
|
|
109
|
-
beforeAll(async () => {
|
|
110
|
-
db = await createTestDatabase();
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
afterAll(async () => {
|
|
114
|
-
await cleanupDatabase(db);
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
beforeEach(async () => {
|
|
118
|
-
await db.clear(); // Clean slate each test
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
describe("POST /login", () => {
|
|
122
|
-
it("returns JWT for valid credentials", async () => {
|
|
123
|
-
// Arrange
|
|
124
|
-
const user = await createTestUser(db, { email: "test@example.com" });
|
|
125
|
-
|
|
126
|
-
// Act
|
|
127
|
-
const response = await app.request("/login", {
|
|
128
|
-
method: "POST",
|
|
129
|
-
body: JSON.stringify({ email: user.email, password: "password123" }),
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
// Assert
|
|
133
|
-
expect(response.status).toBe(200);
|
|
134
|
-
const body = await response.json();
|
|
135
|
-
expect(body.token).toBeDefined();
|
|
136
|
-
expect(body.user.email).toBe(user.email);
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
it("returns 401 for invalid password", async () => {
|
|
140
|
-
const user = await createTestUser(db);
|
|
141
|
-
|
|
142
|
-
const response = await app.request("/login", {
|
|
143
|
-
method: "POST",
|
|
144
|
-
body: JSON.stringify({ email: user.email, password: "wrong" }),
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
expect(response.status).toBe(401);
|
|
148
|
-
});
|
|
149
|
-
});
|
|
150
|
-
});
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
---
|
|
154
|
-
|
|
155
|
-
## Phase 4: Common Test Patterns
|
|
156
|
-
|
|
157
|
-
### Database Integration
|
|
158
|
-
|
|
159
|
-
```typescript
|
|
160
|
-
describe("User Repository", () => {
|
|
161
|
-
let db: Database;
|
|
162
|
-
|
|
163
|
-
beforeAll(async () => {
|
|
164
|
-
db = await createTestDatabase();
|
|
165
|
-
await db.migrate();
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
afterEach(async () => {
|
|
169
|
-
await db.exec("DELETE FROM users"); // Clean between tests
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
afterAll(async () => {
|
|
173
|
-
await db.close();
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
it("creates user with hashed password", async () => {
|
|
177
|
-
const repo = new UserRepository(db);
|
|
178
|
-
|
|
179
|
-
const user = await repo.create({
|
|
180
|
-
email: "test@example.com",
|
|
181
|
-
password: "plaintext123",
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
expect(user.id).toBeDefined();
|
|
185
|
-
expect(user.password).not.toBe("plaintext123"); // Should be hashed
|
|
186
|
-
});
|
|
187
|
-
});
|
|
188
|
-
```
|
|
189
|
-
|
|
190
|
-
### API Integration
|
|
191
|
-
|
|
192
|
-
```typescript
|
|
193
|
-
describe("API Integration", () => {
|
|
194
|
-
let server: TestServer;
|
|
195
|
-
|
|
196
|
-
beforeAll(async () => {
|
|
197
|
-
server = await createTestServer();
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
afterAll(async () => {
|
|
201
|
-
await server.close();
|
|
202
|
-
});
|
|
203
|
-
|
|
204
|
-
it("GET /users returns paginated list", async () => {
|
|
205
|
-
// Seed data
|
|
206
|
-
await seedUsers(10);
|
|
207
|
-
|
|
208
|
-
const response = await fetch(`${server.url}/users?page=1&limit=5`);
|
|
209
|
-
const data = await response.json();
|
|
210
|
-
|
|
211
|
-
expect(response.status).toBe(200);
|
|
212
|
-
expect(data.users).toHaveLength(5);
|
|
213
|
-
expect(data.total).toBe(10);
|
|
214
|
-
expect(data.page).toBe(1);
|
|
215
|
-
});
|
|
216
|
-
});
|
|
217
|
-
```
|
|
218
|
-
|
|
219
|
-
### External Service Integration
|
|
220
|
-
|
|
221
|
-
```typescript
|
|
222
|
-
describe("Payment Service", () => {
|
|
223
|
-
it("processes payment with Stripe test mode", async () => {
|
|
224
|
-
const stripe = new Stripe(process.env.STRIPE_TEST_KEY);
|
|
225
|
-
|
|
226
|
-
const paymentIntent = await stripe.paymentIntents.create({
|
|
227
|
-
amount: 1000,
|
|
228
|
-
currency: "usd",
|
|
229
|
-
payment_method: "pm_card_visa", // Stripe test card
|
|
230
|
-
confirm: true,
|
|
231
|
-
});
|
|
232
|
-
|
|
233
|
-
expect(paymentIntent.status).toBe("succeeded");
|
|
234
|
-
});
|
|
235
|
-
});
|
|
236
|
-
```
|
|
237
|
-
|
|
238
|
-
### Async/Queue Integration
|
|
239
|
-
|
|
240
|
-
```typescript
|
|
241
|
-
describe("Job Queue", () => {
|
|
242
|
-
it("processes email job within timeout", async () => {
|
|
243
|
-
const queue = createTestQueue();
|
|
244
|
-
|
|
245
|
-
// Add job
|
|
246
|
-
await queue.add("send-email", { to: "test@example.com" });
|
|
247
|
-
|
|
248
|
-
// Wait for processing (use condition-based-waiting skill)
|
|
249
|
-
await waitFor(
|
|
250
|
-
async () => {
|
|
251
|
-
const job = await queue.getJob("send-email");
|
|
252
|
-
return job?.status === "completed";
|
|
253
|
-
},
|
|
254
|
-
{ timeout: 5000, interval: 100 },
|
|
255
|
-
);
|
|
256
|
-
|
|
257
|
-
const job = await queue.getJob("send-email");
|
|
258
|
-
expect(job.status).toBe("completed");
|
|
259
|
-
});
|
|
260
|
-
});
|
|
261
|
-
```
|
|
262
|
-
|
|
263
|
-
---
|
|
264
|
-
|
|
265
|
-
## Phase 5: Test Data Management
|
|
266
|
-
|
|
267
|
-
### Factories
|
|
268
|
-
|
|
269
|
-
```typescript
|
|
270
|
-
// tests/fixtures/factories.ts
|
|
271
|
-
|
|
272
|
-
export function createTestUser(db: Database, overrides = {}) {
|
|
273
|
-
return db.insert("users", {
|
|
274
|
-
id: randomUUID(),
|
|
275
|
-
email: `test-${Date.now()}@example.com`,
|
|
276
|
-
password: hashSync("password123", 10),
|
|
277
|
-
createdAt: new Date(),
|
|
278
|
-
...overrides,
|
|
279
|
-
});
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
export function createTestOrder(db: Database, userId: string, overrides = {}) {
|
|
283
|
-
return db.insert("orders", {
|
|
284
|
-
id: randomUUID(),
|
|
285
|
-
userId,
|
|
286
|
-
status: "pending",
|
|
287
|
-
total: 100,
|
|
288
|
-
...overrides,
|
|
289
|
-
});
|
|
290
|
-
}
|
|
291
|
-
```
|
|
292
|
-
|
|
293
|
-
### Cleanup Strategies
|
|
294
|
-
|
|
295
|
-
| Strategy | Pros | Cons |
|
|
296
|
-
| ------------------------ | ----------- | ------------------ |
|
|
297
|
-
| **Transaction rollback** | Fast, clean | Complex setup |
|
|
298
|
-
| **DELETE after each** | Simple | Slower |
|
|
299
|
-
| **Fresh DB per test** | Isolated | Very slow |
|
|
300
|
-
| **Truncate tables** | Fast reset | May miss FK issues |
|
|
301
|
-
|
|
302
|
-
**Recommended:** Transaction rollback for speed, DELETE for simplicity.
|
|
303
|
-
|
|
304
|
-
---
|
|
305
|
-
|
|
306
|
-
## Phase 6: Isolation Patterns
|
|
307
|
-
|
|
308
|
-
### Database Isolation
|
|
309
|
-
|
|
310
|
-
```typescript
|
|
311
|
-
// Wrap each test in transaction that rolls back
|
|
312
|
-
beforeEach(async () => {
|
|
313
|
-
await db.exec("BEGIN");
|
|
314
|
-
});
|
|
315
|
-
|
|
316
|
-
afterEach(async () => {
|
|
317
|
-
await db.exec("ROLLBACK");
|
|
318
|
-
});
|
|
319
|
-
```
|
|
320
|
-
|
|
321
|
-
### Port Isolation (Parallel Tests)
|
|
322
|
-
|
|
323
|
-
```typescript
|
|
324
|
-
// Use dynamic ports for parallel test runners
|
|
325
|
-
const server = await app.listen(0); // Random available port
|
|
326
|
-
const port = server.address().port;
|
|
327
|
-
```
|
|
328
|
-
|
|
329
|
-
### Environment Isolation
|
|
330
|
-
|
|
331
|
-
```bash
|
|
332
|
-
# .env.test
|
|
333
|
-
DATABASE_URL=postgres://localhost/myapp_test
|
|
334
|
-
STRIPE_KEY=sk_test_xxx
|
|
335
|
-
REDIS_URL=redis://localhost:6379/1 # Separate DB number
|
|
336
|
-
```
|
|
337
|
-
|
|
338
|
-
---
|
|
339
|
-
|
|
340
|
-
## Phase 7: TDD Workflow
|
|
341
|
-
|
|
342
|
-
Follow the cycle:
|
|
343
|
-
|
|
344
|
-
1. **Write failing test first**
|
|
345
|
-
- Test should fail for the RIGHT reason
|
|
346
|
-
- Not a syntax error, but missing functionality
|
|
347
|
-
|
|
348
|
-
2. **Verify failure message**
|
|
349
|
-
- Should clearly indicate what's missing
|
|
350
|
-
- "Expected 200, got 404" = endpoint missing
|
|
351
|
-
|
|
352
|
-
3. **Implement minimal code**
|
|
353
|
-
- Just enough to pass
|
|
354
|
-
- Don't over-engineer
|
|
355
|
-
|
|
356
|
-
4. **Refactor while green**
|
|
357
|
-
- Improve code quality
|
|
358
|
-
- Keep tests passing
|
|
359
|
-
|
|
360
|
-
---
|
|
361
|
-
|
|
362
|
-
## Anti-Patterns to Avoid
|
|
363
|
-
|
|
364
|
-
| Anti-Pattern | Problem | Do Instead |
|
|
365
|
-
| ------------------------------ | --------------------------- | --------------------------------- |
|
|
366
|
-
| Testing implementation details | Brittle tests | Test behavior/outcomes |
|
|
367
|
-
| Excessive mocking | Tests don't reflect reality | Use real dependencies |
|
|
368
|
-
| Shared mutable state | Flaky tests | Isolate each test |
|
|
369
|
-
| Testing third-party code | Waste of time | Trust libraries, test integration |
|
|
370
|
-
| No cleanup | Tests affect each other | Always clean up |
|
|
371
|
-
| Hardcoded test data | Fragile | Use factories |
|
|
372
|
-
|
|
373
|
-
---
|
|
374
|
-
|
|
375
|
-
## Coverage Guidelines
|
|
376
|
-
|
|
377
|
-
| Coverage Type | Target | Notes |
|
|
378
|
-
| -------------------- | --------- | ----------------------------- |
|
|
379
|
-
| Line coverage | 70-80% | Higher for critical paths |
|
|
380
|
-
| Branch coverage | 60-70% | Cover main branches |
|
|
381
|
-
| Integration coverage | Key paths | All API endpoints, main flows |
|
|
382
|
-
|
|
383
|
-
**Focus on:** Happy paths, error cases, edge cases in that order.
|
|
384
|
-
|
|
385
|
-
---
|
|
386
|
-
|
|
387
|
-
## CI Considerations
|
|
388
|
-
|
|
389
|
-
```yaml
|
|
390
|
-
# .github/workflows/test.yml
|
|
391
|
-
jobs:
|
|
392
|
-
integration-tests:
|
|
393
|
-
services:
|
|
394
|
-
postgres:
|
|
395
|
-
image: postgres:15
|
|
396
|
-
env:
|
|
397
|
-
POSTGRES_DB: test
|
|
398
|
-
steps:
|
|
399
|
-
- run: npm run test:integration
|
|
400
|
-
env:
|
|
401
|
-
DATABASE_URL: postgres://postgres@localhost/test
|
|
402
|
-
```
|
|
403
|
-
|
|
404
|
-
---
|
|
405
|
-
|
|
406
|
-
## Output
|
|
407
|
-
|
|
408
|
-
After writing tests:
|
|
409
|
-
|
|
410
|
-
1. **Run tests**: Verify all pass
|
|
411
|
-
2. **Check coverage**: Meet guidelines
|
|
412
|
-
3. **Update review.md**: `.beads/artifacts/$ARGUMENTS/review.md`
|
|
413
|
-
4. **Complete**: `/finish $ARGUMENTS`
|
|
414
|
-
|
|
415
|
-
---
|
|
416
|
-
|
|
417
|
-
## Related Commands
|
|
418
|
-
|
|
419
|
-
| Need | Command |
|
|
420
|
-
| ------------------- | ------------------------- |
|
|
421
|
-
| Create unit tests | Use TDD skill directly |
|
|
422
|
-
| Fix failing tests | `/fix` |
|
|
423
|
-
| Review test quality | `/review-codebase tests/` |
|
|
424
|
-
| Complete task | `/finish <bead-id>` |
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: Import GitHub issue as tracked bead
|
|
3
|
-
argument-hint: "<issue-number>"
|
|
4
|
-
agent: build
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# Issue: $ARGUMENTS
|
|
8
|
-
|
|
9
|
-
You're importing a GitHub issue into beads for tracking.
|
|
10
|
-
|
|
11
|
-
## Check For Duplicates
|
|
12
|
-
|
|
13
|
-
!`bd list --status=all | grep -i "[keywords from issue]"`
|
|
14
|
-
|
|
15
|
-
If similar bead exists, link to it instead of creating duplicate.
|
|
16
|
-
|
|
17
|
-
## Fetch The Issue
|
|
18
|
-
|
|
19
|
-
!`gh issue view $ARGUMENTS --json title,body,labels,state`
|
|
20
|
-
|
|
21
|
-
Extract:
|
|
22
|
-
|
|
23
|
-
- **Title** - issue title
|
|
24
|
-
- **Labels** - for type/priority mapping
|
|
25
|
-
- **Body** - problem description, reproduction steps
|
|
26
|
-
|
|
27
|
-
## Map Labels
|
|
28
|
-
|
|
29
|
-
| GitHub Label | Bead Type | Priority |
|
|
30
|
-
| -------------------- | --------- | -------- |
|
|
31
|
-
| bug | bug | 1 |
|
|
32
|
-
| feature, enhancement | feature | 2 |
|
|
33
|
-
| critical, blocker | - | 0 |
|
|
34
|
-
| low, backlog | - | 4 |
|
|
35
|
-
|
|
36
|
-
## Create The Bead
|
|
37
|
-
|
|
38
|
-
```bash
|
|
39
|
-
bd create "[issue title]" -t [type] -p [priority]
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
## Create Spec
|
|
43
|
-
|
|
44
|
-
Write `.beads/artifacts/<bead-id>/spec.md`:
|
|
45
|
-
|
|
46
|
-
```markdown
|
|
47
|
-
# [Issue Title]
|
|
48
|
-
|
|
49
|
-
**Bead:** <bead-id>
|
|
50
|
-
**GitHub:** #$ARGUMENTS
|
|
51
|
-
**Created:** [date]
|
|
52
|
-
|
|
53
|
-
## Goal
|
|
54
|
-
|
|
55
|
-
[What we're fixing/building from issue body]
|
|
56
|
-
|
|
57
|
-
## Reproduction
|
|
58
|
-
|
|
59
|
-
[Steps from issue if bug]
|
|
60
|
-
|
|
61
|
-
## Success Criteria
|
|
62
|
-
|
|
63
|
-
- [ ] [From issue acceptance criteria]
|
|
64
|
-
- Verify: `[command]`
|
|
65
|
-
- [ ] No regression
|
|
66
|
-
- Verify: `npm test`
|
|
67
|
-
|
|
68
|
-
## Constraints
|
|
69
|
-
|
|
70
|
-
[From issue if any]
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
## Comment On GitHub
|
|
74
|
-
|
|
75
|
-
```bash
|
|
76
|
-
gh issue comment $ARGUMENTS --body "Tracking: \`<bead-id>\`
|
|
77
|
-
|
|
78
|
-
Estimate: [S/M/L]
|
|
79
|
-
Next: [/implement or /research]"
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
## Sync
|
|
83
|
-
|
|
84
|
-
```bash
|
|
85
|
-
bd sync
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
## Output
|
|
89
|
-
|
|
90
|
-
```
|
|
91
|
-
Imported: #$ARGUMENTS
|
|
92
|
-
|
|
93
|
-
Bead: <bead-id>
|
|
94
|
-
Type: [bug/feature/task]
|
|
95
|
-
Priority: [0-4]
|
|
96
|
-
Spec: .beads/artifacts/<bead-id>/spec.md
|
|
97
|
-
|
|
98
|
-
Next:
|
|
99
|
-
- S/M estimate: /implement <bead-id>
|
|
100
|
-
- L estimate: /research <bead-id>
|
|
101
|
-
- XL: Decompose first
|
|
102
|
-
```
|