create-stitchkit 0.6.23 → 0.7.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/CHANGELOG.md +49 -0
- package/README.md +9 -1
- package/UPGRADING.md +72 -17
- package/dist/cli.js +83 -56
- package/examples/repository/packages/backend/src/surface.snapshot.json +175 -88
- package/examples/repository/scripts/runtime-smoke.ts +156 -126
- package/package.json +7 -4
- package/template/README.md +12 -2
- package/template/_gitignore +1 -0
- package/template/bun.lock +5 -5
- package/template/docs/ADDING_A_FEATURE.md +21 -7
- package/template/package.json +3 -3
- package/template/packages/backend/src/cli.ts +1 -0
- package/template/packages/backend/src/index.ts +3 -0
- package/template/packages/backend/src/surface.snapshot.json +90 -50
- package/template/packages/backend/src/tools.ts +1 -1
- package/template/packages/frontend/package.json +1 -1
- package/template/scripts/acceptance-environment.test.ts +59 -0
- package/template/scripts/acceptance-environment.ts +52 -0
- package/template/scripts/acceptance-local.ts +8 -28
- package/template/scripts/runtime-smoke.test.ts +49 -0
- package/template/scripts/runtime-smoke.ts +2 -2
- package/template/scripts/surface-snapshot.ts +135 -14
- package/templates/agent/package.json +2 -2
- package/templates/agent/src/runtime.ts +1 -1
- package/templates/telegram-bot/package.json +1 -1
- package/template/.data/board.sqlite +0 -0
- package/template/packages/backend/src/surface-manifest.test.ts +0 -237
- package/template/packages/backend/src/surface-manifest.ts +0 -220
- package/template/scripts/surface-conformance.ts +0 -173
|
@@ -1,90 +1,177 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
"
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
1
|
+
{
|
|
2
|
+
"manifestVersion": 3,
|
|
3
|
+
"digestVersion": 1,
|
|
4
|
+
"operations": [
|
|
5
|
+
{
|
|
6
|
+
"kind": "contract",
|
|
7
|
+
"service": "board",
|
|
8
|
+
"action": "list",
|
|
9
|
+
"method": "GET",
|
|
10
|
+
"scope": "public",
|
|
11
|
+
"description": "Read the board",
|
|
12
|
+
"schemas": {
|
|
13
|
+
"params": null,
|
|
14
|
+
"input": null,
|
|
15
|
+
"output": "e486aa374f9a13e0",
|
|
16
|
+
"multipart": null
|
|
17
|
+
},
|
|
18
|
+
"mcp": null,
|
|
19
|
+
"http": [
|
|
20
|
+
{
|
|
21
|
+
"method": "GET",
|
|
22
|
+
"path": "/api/board"
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"kind": "contract",
|
|
28
|
+
"service": "board",
|
|
29
|
+
"action": "post",
|
|
30
|
+
"method": "POST",
|
|
31
|
+
"scope": "public",
|
|
32
|
+
"description": "Add a note to the board",
|
|
33
|
+
"schemas": {
|
|
34
|
+
"params": null,
|
|
35
|
+
"input": "c23c53a4b15afe81",
|
|
36
|
+
"output": "e486aa374f9a13e0",
|
|
37
|
+
"multipart": null
|
|
38
|
+
},
|
|
39
|
+
"mcp": null,
|
|
40
|
+
"http": [
|
|
41
|
+
{
|
|
42
|
+
"method": "POST",
|
|
43
|
+
"path": "/api/board"
|
|
44
|
+
}
|
|
45
|
+
]
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"kind": "contract",
|
|
49
|
+
"service": "repository",
|
|
50
|
+
"action": "read",
|
|
51
|
+
"method": "GET",
|
|
52
|
+
"scope": "public",
|
|
53
|
+
"description": "Read the server-cached repository snapshot",
|
|
54
|
+
"schemas": {
|
|
55
|
+
"params": null,
|
|
56
|
+
"input": null,
|
|
57
|
+
"output": "5ae5b88ae9390b60",
|
|
58
|
+
"multipart": null
|
|
59
|
+
},
|
|
60
|
+
"mcp": null,
|
|
61
|
+
"http": [
|
|
62
|
+
{
|
|
63
|
+
"method": "GET",
|
|
64
|
+
"path": "/api/repository"
|
|
65
|
+
}
|
|
66
|
+
]
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"kind": "contract",
|
|
70
|
+
"service": "repository",
|
|
71
|
+
"action": "refresh",
|
|
72
|
+
"method": "POST",
|
|
73
|
+
"scope": "public",
|
|
74
|
+
"description": "Refresh the repository snapshot from GitHub",
|
|
75
|
+
"schemas": {
|
|
76
|
+
"params": null,
|
|
77
|
+
"input": null,
|
|
78
|
+
"output": "5ae5b88ae9390b60",
|
|
79
|
+
"multipart": null
|
|
80
|
+
},
|
|
81
|
+
"mcp": null,
|
|
82
|
+
"http": [
|
|
83
|
+
{
|
|
84
|
+
"method": "POST",
|
|
85
|
+
"path": "/api/repository/refresh"
|
|
86
|
+
}
|
|
87
|
+
]
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
"kind": "contract",
|
|
91
|
+
"service": "system",
|
|
92
|
+
"action": "status",
|
|
93
|
+
"method": "GET",
|
|
94
|
+
"scope": "public",
|
|
95
|
+
"description": "Read application readiness",
|
|
96
|
+
"schemas": {
|
|
97
|
+
"params": null,
|
|
98
|
+
"input": null,
|
|
99
|
+
"output": "14a186301eeae875",
|
|
100
|
+
"multipart": null
|
|
101
|
+
},
|
|
102
|
+
"mcp": null,
|
|
103
|
+
"http": [
|
|
104
|
+
{
|
|
105
|
+
"method": "GET",
|
|
106
|
+
"path": "/api/system/status"
|
|
107
|
+
}
|
|
108
|
+
]
|
|
52
109
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
110
|
+
],
|
|
111
|
+
"toolSurfaces": [
|
|
112
|
+
{
|
|
113
|
+
"transport": "AGENT",
|
|
114
|
+
"surface": null,
|
|
115
|
+
"tools": [
|
|
116
|
+
{
|
|
117
|
+
"kind": "contract",
|
|
118
|
+
"service": "repository",
|
|
119
|
+
"action": "read",
|
|
120
|
+
"name": "repository_read",
|
|
121
|
+
"input": "7a014b717a77aac9"
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
"kind": "contract",
|
|
125
|
+
"service": "repository",
|
|
126
|
+
"action": "refresh",
|
|
127
|
+
"name": "repository_refresh",
|
|
128
|
+
"input": "7a014b717a77aac9"
|
|
129
|
+
}
|
|
130
|
+
]
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
"transport": "CLI",
|
|
134
|
+
"surface": null,
|
|
135
|
+
"tools": [
|
|
136
|
+
{
|
|
137
|
+
"kind": "contract",
|
|
138
|
+
"service": "repository",
|
|
139
|
+
"action": "read",
|
|
140
|
+
"name": "repository_read",
|
|
141
|
+
"input": "7a014b717a77aac9"
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
"kind": "contract",
|
|
145
|
+
"service": "repository",
|
|
146
|
+
"action": "refresh",
|
|
147
|
+
"name": "repository_refresh",
|
|
148
|
+
"input": "7a014b717a77aac9"
|
|
149
|
+
}
|
|
150
|
+
]
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
"transport": "MCP",
|
|
154
|
+
"surface": null,
|
|
155
|
+
"tools": [
|
|
156
|
+
{
|
|
157
|
+
"kind": "contract",
|
|
158
|
+
"service": "repository",
|
|
159
|
+
"action": "read",
|
|
160
|
+
"name": "repository_read",
|
|
161
|
+
"input": "7a014b717a77aac9"
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
"kind": "contract",
|
|
165
|
+
"service": "repository",
|
|
166
|
+
"action": "refresh",
|
|
167
|
+
"name": "repository_refresh",
|
|
168
|
+
"input": "7a014b717a77aac9"
|
|
169
|
+
}
|
|
170
|
+
]
|
|
72
171
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
"hasOutput": true,
|
|
80
|
-
"inputShape": null,
|
|
81
|
-
"outputShape": "58b078ade3ee6167",
|
|
82
|
-
"http": [
|
|
83
|
-
{
|
|
84
|
-
"method": "GET",
|
|
85
|
-
"path": "/api/system/status"
|
|
86
|
-
}
|
|
87
|
-
],
|
|
88
|
-
"tools": {}
|
|
89
|
-
}
|
|
90
|
-
]
|
|
172
|
+
],
|
|
173
|
+
"realtimeContracts": [],
|
|
174
|
+
"realtime": [],
|
|
175
|
+
"cliOnly": [],
|
|
176
|
+
"extensions": []
|
|
177
|
+
}
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { RepositorySnapshotSchema, repositoryRealtimeContract } from '@app/shared';
|
|
2
2
|
import { createRealtimeClient, defineRealtimeContract } from 'stitchkit';
|
|
3
|
+
import {
|
|
4
|
+
type RealtimeRejectionObservation,
|
|
5
|
+
runSurfaceProbes,
|
|
6
|
+
type TransportObservation,
|
|
7
|
+
} from 'stitchkit/testing';
|
|
3
8
|
import { z } from 'zod';
|
|
4
9
|
import { assertDeploymentIsAnswering } from './deployment-preflight';
|
|
5
|
-
import {
|
|
10
|
+
import { assertLiveSurface } from './surface-snapshot';
|
|
6
11
|
import { loadToolingEnv } from './tooling-env';
|
|
7
12
|
import { assertArtifactIsPlacementFree, assertPublicWebSurface } from './web-surface-smoke';
|
|
8
13
|
|
|
@@ -17,7 +22,7 @@ await assertDeploymentIsAnswering({
|
|
|
17
22
|
async function json(path: string, init?: RequestInit): Promise<unknown> {
|
|
18
23
|
const response = await fetch(`${apiOrigin}${path}`, {
|
|
19
24
|
...init,
|
|
20
|
-
signal: AbortSignal.timeout(30_000),
|
|
25
|
+
signal: init?.signal ?? AbortSignal.timeout(30_000),
|
|
21
26
|
});
|
|
22
27
|
if (!response.ok)
|
|
23
28
|
throw new Error(`${init?.method ?? 'GET'} ${path} returned ${response.status}`);
|
|
@@ -26,136 +31,161 @@ async function json(path: string, init?: RequestInit): Promise<unknown> {
|
|
|
26
31
|
|
|
27
32
|
z.object({ status: z.literal('ok') }).parse(await json('/health'));
|
|
28
33
|
|
|
29
|
-
await
|
|
30
|
-
|
|
34
|
+
await assertLiveSurface(apiOrigin);
|
|
35
|
+
|
|
36
|
+
interface RepositoryProbeFixture {
|
|
37
|
+
path: '/api/repository/refresh';
|
|
38
|
+
mode: 'refresh' | 'divergent-contract';
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async function runRefreshProbe(
|
|
42
|
+
path: string,
|
|
43
|
+
signal: AbortSignal,
|
|
44
|
+
): Promise<TransportObservation> {
|
|
45
|
+
const rejected: string[] = [];
|
|
46
|
+
const socket = createRealtimeClient(repositoryRealtimeContract, {
|
|
47
|
+
url: apiOrigin,
|
|
48
|
+
transports: ['websocket'],
|
|
49
|
+
onRejected: ({ event, direction, phase }) => {
|
|
50
|
+
rejected.push(`${event}:${direction}:${phase}`);
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
try {
|
|
54
|
+
await new Promise<void>((resolve, reject) => {
|
|
55
|
+
const timeout = setTimeout(
|
|
56
|
+
() => reject(new Error('Socket.IO connection timed out')),
|
|
57
|
+
5_000,
|
|
58
|
+
);
|
|
59
|
+
const unsubscribe = socket.onConnectionChange((connected, reason) => {
|
|
60
|
+
if (!connected) {
|
|
61
|
+
if (reason) reject(new Error(`Socket.IO disconnected: ${reason}`));
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
clearTimeout(timeout);
|
|
65
|
+
unsubscribe();
|
|
66
|
+
resolve();
|
|
67
|
+
});
|
|
68
|
+
socket.connect();
|
|
69
|
+
});
|
|
70
|
+
const refreshedEvent = new Promise<string>((resolve, reject) => {
|
|
71
|
+
const timeout = setTimeout(
|
|
72
|
+
() => reject(new Error('Socket.IO repository refresh event timed out')),
|
|
73
|
+
5_000,
|
|
74
|
+
);
|
|
75
|
+
const unsubscribe = socket.on('repository:refreshed', (snapshot) => {
|
|
76
|
+
clearTimeout(timeout);
|
|
77
|
+
unsubscribe();
|
|
78
|
+
resolve(snapshot.fullName);
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
const refreshed = RepositorySnapshotSchema.parse(
|
|
82
|
+
await json(path, { method: 'POST', signal }),
|
|
83
|
+
);
|
|
84
|
+
if ((await refreshedEvent) !== refreshed.fullName) {
|
|
85
|
+
throw new Error('Socket.IO repository identity differs');
|
|
86
|
+
}
|
|
87
|
+
const cached = RepositorySnapshotSchema.parse(await json('/api/repository/', { signal }));
|
|
88
|
+
if (cached.fullName !== refreshed.fullName) {
|
|
89
|
+
throw new Error('Repository cache read differs');
|
|
90
|
+
}
|
|
91
|
+
if (rejected.length > 0) {
|
|
92
|
+
throw new Error(`Realtime contract rejected ${rejected.join(', ')}`);
|
|
93
|
+
}
|
|
94
|
+
return { outcome: 'success' };
|
|
95
|
+
} finally {
|
|
96
|
+
socket.disconnect();
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
async function runDivergentContractProbe(
|
|
101
|
+
path: string,
|
|
102
|
+
signal: AbortSignal,
|
|
103
|
+
): Promise<TransportObservation> {
|
|
104
|
+
// NEGATIVE probe: a client whose local contract disagrees with the
|
|
105
|
+
// server must see the real payload REJECTED — this executes the
|
|
106
|
+
// rejection path instead of merely asserting its absence. Matched by
|
|
107
|
+
// structured rejection observation, never by message text.
|
|
108
|
+
const divergentContract = defineRealtimeContract({
|
|
109
|
+
serverToClient: {
|
|
110
|
+
'repository:refreshed': { args: z.tuple([z.object({ bogus: z.string() })]) },
|
|
111
|
+
},
|
|
112
|
+
clientToServer: {},
|
|
113
|
+
});
|
|
114
|
+
const rejections: RealtimeRejectionObservation[] = [];
|
|
115
|
+
const socket = createRealtimeClient(divergentContract, {
|
|
116
|
+
url: apiOrigin,
|
|
117
|
+
transports: ['websocket'],
|
|
118
|
+
onRejected: ({ direction, phase, reason, fault }) => {
|
|
119
|
+
rejections.push({ direction, phase, reason, fault });
|
|
120
|
+
},
|
|
121
|
+
});
|
|
122
|
+
try {
|
|
123
|
+
await new Promise<void>((resolve, reject) => {
|
|
124
|
+
const timeout = setTimeout(
|
|
125
|
+
() => reject(new Error('Socket.IO connection timed out')),
|
|
126
|
+
5_000,
|
|
127
|
+
);
|
|
128
|
+
const unsubscribe = socket.onConnectionChange((connected) => {
|
|
129
|
+
if (!connected) return;
|
|
130
|
+
clearTimeout(timeout);
|
|
131
|
+
unsubscribe();
|
|
132
|
+
resolve();
|
|
133
|
+
});
|
|
134
|
+
socket.connect();
|
|
135
|
+
});
|
|
136
|
+
// A handler must be attached for the inbound frame to be validated.
|
|
137
|
+
const unsubscribe = socket.on('repository:refreshed', () => {
|
|
138
|
+
throw new Error('a payload outside the local contract reached the handler');
|
|
139
|
+
});
|
|
140
|
+
await json(path, { method: 'POST', signal });
|
|
141
|
+
const deadline = Date.now() + 5_000;
|
|
142
|
+
while (rejections.length === 0 && Date.now() < deadline) {
|
|
143
|
+
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
144
|
+
}
|
|
145
|
+
unsubscribe();
|
|
146
|
+
const rejection = rejections[0];
|
|
147
|
+
if (!rejection) {
|
|
148
|
+
throw new Error('the contract mismatch was never rejected');
|
|
149
|
+
}
|
|
150
|
+
return { outcome: 'realtime_rejected', rejection };
|
|
151
|
+
} finally {
|
|
152
|
+
socket.disconnect();
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
await runSurfaceProbes<RepositoryProbeFixture>({
|
|
31
157
|
probes: [
|
|
32
|
-
|
|
158
|
+
{
|
|
33
159
|
name: 'repository refresh lifecycle',
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const socket = createRealtimeClient(repositoryRealtimeContract, {
|
|
40
|
-
url: apiOrigin,
|
|
41
|
-
transports: ['websocket'],
|
|
42
|
-
onRejected: ({ event, direction, phase }) => {
|
|
43
|
-
rejected.push(`${event}:${direction}:${phase}`);
|
|
44
|
-
},
|
|
45
|
-
});
|
|
46
|
-
try {
|
|
47
|
-
await new Promise<void>((resolve, reject) => {
|
|
48
|
-
const timeout = setTimeout(
|
|
49
|
-
() => reject(new Error('Socket.IO connection timed out')),
|
|
50
|
-
5_000,
|
|
51
|
-
);
|
|
52
|
-
const unsubscribe = socket.onConnectionChange((connected, reason) => {
|
|
53
|
-
if (!connected) {
|
|
54
|
-
if (reason) reject(new Error(`Socket.IO disconnected: ${reason}`));
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
clearTimeout(timeout);
|
|
58
|
-
unsubscribe();
|
|
59
|
-
resolve();
|
|
60
|
-
});
|
|
61
|
-
socket.connect();
|
|
62
|
-
});
|
|
63
|
-
const refreshedEvent = new Promise<string>((resolve, reject) => {
|
|
64
|
-
const timeout = setTimeout(
|
|
65
|
-
() => reject(new Error('Socket.IO repository refresh event timed out')),
|
|
66
|
-
5_000,
|
|
67
|
-
);
|
|
68
|
-
const unsubscribe = socket.on('repository:refreshed', (snapshot) => {
|
|
69
|
-
clearTimeout(timeout);
|
|
70
|
-
unsubscribe();
|
|
71
|
-
resolve(snapshot.fullName);
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
const refreshed = RepositorySnapshotSchema.parse(
|
|
75
|
-
await json(path, { method: 'POST' }),
|
|
76
|
-
);
|
|
77
|
-
if ((await refreshedEvent) !== refreshed.fullName) {
|
|
78
|
-
throw new Error('Socket.IO repository identity differs');
|
|
79
|
-
}
|
|
80
|
-
const cached = RepositorySnapshotSchema.parse(await json('/api/repository/'));
|
|
81
|
-
if (cached.fullName !== refreshed.fullName) {
|
|
82
|
-
throw new Error('Repository cache read differs');
|
|
83
|
-
}
|
|
84
|
-
if (rejected.length > 0) {
|
|
85
|
-
throw new Error(`Realtime contract rejected ${rejected.join(', ')}`);
|
|
86
|
-
}
|
|
87
|
-
return refreshed;
|
|
88
|
-
} finally {
|
|
89
|
-
socket.disconnect();
|
|
90
|
-
}
|
|
91
|
-
},
|
|
92
|
-
}),
|
|
93
|
-
defineSurfaceProbe({
|
|
160
|
+
fixture: { path: '/api/repository/refresh', mode: 'refresh' },
|
|
161
|
+
transports: ['REALTIME'],
|
|
162
|
+
expected: { REALTIME: { outcome: 'success' } },
|
|
163
|
+
},
|
|
164
|
+
{
|
|
94
165
|
name: 'realtime rejection path fires on a contract mismatch',
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
166
|
+
fixture: { path: '/api/repository/refresh', mode: 'divergent-contract' },
|
|
167
|
+
transports: ['REALTIME'],
|
|
168
|
+
expected: {
|
|
169
|
+
REALTIME: {
|
|
170
|
+
outcome: 'realtime_rejected',
|
|
171
|
+
rejection: {
|
|
172
|
+
direction: 'client-inbound',
|
|
173
|
+
phase: 'arguments',
|
|
174
|
+
reason: 'invalid-arguments',
|
|
175
|
+
fault: 'peer',
|
|
105
176
|
},
|
|
106
|
-
|
|
107
|
-
});
|
|
108
|
-
const rejections: Array<{ event: string; direction: string; phase: string }> = [];
|
|
109
|
-
const socket = createRealtimeClient(divergentContract, {
|
|
110
|
-
url: apiOrigin,
|
|
111
|
-
transports: ['websocket'],
|
|
112
|
-
onRejected: ({ event, direction, phase }) => {
|
|
113
|
-
rejections.push({ event, direction, phase });
|
|
114
|
-
},
|
|
115
|
-
});
|
|
116
|
-
try {
|
|
117
|
-
await new Promise<void>((resolve, reject) => {
|
|
118
|
-
const timeout = setTimeout(
|
|
119
|
-
() => reject(new Error('Socket.IO connection timed out')),
|
|
120
|
-
5_000,
|
|
121
|
-
);
|
|
122
|
-
const unsubscribe = socket.onConnectionChange((connected) => {
|
|
123
|
-
if (!connected) return;
|
|
124
|
-
clearTimeout(timeout);
|
|
125
|
-
unsubscribe();
|
|
126
|
-
resolve();
|
|
127
|
-
});
|
|
128
|
-
socket.connect();
|
|
129
|
-
});
|
|
130
|
-
// A handler must be attached for the inbound frame to be validated.
|
|
131
|
-
const unsubscribe = socket.on('repository:refreshed', () => {
|
|
132
|
-
throw new Error('a payload outside the local contract reached the handler');
|
|
133
|
-
});
|
|
134
|
-
await json(path, { method: 'POST' });
|
|
135
|
-
const deadline = Date.now() + 5_000;
|
|
136
|
-
while (rejections.length === 0 && Date.now() < deadline) {
|
|
137
|
-
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
138
|
-
}
|
|
139
|
-
unsubscribe();
|
|
140
|
-
const rejection = rejections[0];
|
|
141
|
-
if (!rejection) {
|
|
142
|
-
throw new Error('the contract mismatch was never rejected');
|
|
143
|
-
}
|
|
144
|
-
if (
|
|
145
|
-
rejection.event !== 'repository:refreshed' ||
|
|
146
|
-
rejection.direction !== 'client-inbound' ||
|
|
147
|
-
rejection.phase !== 'arguments'
|
|
148
|
-
) {
|
|
149
|
-
throw new Error(
|
|
150
|
-
`unexpected rejection identity: ${rejection.event}:${rejection.direction}:${rejection.phase}`,
|
|
151
|
-
);
|
|
152
|
-
}
|
|
153
|
-
} finally {
|
|
154
|
-
socket.disconnect();
|
|
155
|
-
}
|
|
177
|
+
},
|
|
156
178
|
},
|
|
157
|
-
}
|
|
179
|
+
},
|
|
158
180
|
],
|
|
181
|
+
drivers: {
|
|
182
|
+
REALTIME: {
|
|
183
|
+
invoke: (fixture, signal) =>
|
|
184
|
+
fixture.mode === 'refresh'
|
|
185
|
+
? runRefreshProbe(fixture.path, signal)
|
|
186
|
+
: runDivergentContractProbe(fixture.path, signal),
|
|
187
|
+
},
|
|
188
|
+
},
|
|
159
189
|
});
|
|
160
190
|
|
|
161
191
|
{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-stitchkit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Create a production-shaped Stitchkit application",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Max Listov <maxlistov@gmail.com>",
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
"!template/**/.env",
|
|
22
22
|
"!template/**/.build-stamp.json",
|
|
23
23
|
"!template/**/node_modules/**",
|
|
24
|
+
"!template/**/.data/**",
|
|
24
25
|
"!template/**/.next/**",
|
|
25
26
|
"!template/**/.stitchkit/**",
|
|
26
27
|
"!template/**/dist/**",
|
|
@@ -34,6 +35,7 @@
|
|
|
34
35
|
"!templates/**/.env",
|
|
35
36
|
"!templates/**/.build-stamp.json",
|
|
36
37
|
"!templates/**/node_modules/**",
|
|
38
|
+
"!templates/**/.data/**",
|
|
37
39
|
"!templates/**/.next/**",
|
|
38
40
|
"!templates/**/.stitchkit/**",
|
|
39
41
|
"!templates/**/dist/**",
|
|
@@ -49,6 +51,7 @@
|
|
|
49
51
|
"!examples/**/.env",
|
|
50
52
|
"!examples/**/.build-stamp.json",
|
|
51
53
|
"!examples/**/node_modules/**",
|
|
54
|
+
"!examples/**/.data/**",
|
|
52
55
|
"!examples/**/.next/**",
|
|
53
56
|
"!examples/**/.stitchkit/**",
|
|
54
57
|
"!examples/**/dist/**",
|
|
@@ -69,7 +72,7 @@
|
|
|
69
72
|
},
|
|
70
73
|
"scripts": {
|
|
71
74
|
"check": "bun x tsc --noEmit",
|
|
72
|
-
"test": "bun test ./tests",
|
|
75
|
+
"test": "bun ../../scripts/test-leak-gate.ts --tmpdir -- bun test ./tests",
|
|
73
76
|
"build": "rm -rf dist && bun build src/cli.ts --outdir dist --target bun --packages external && chmod +x dist/cli.js",
|
|
74
77
|
"prepublishOnly": "bun run check && bun run test && bun run build"
|
|
75
78
|
},
|
|
@@ -85,11 +88,11 @@
|
|
|
85
88
|
"@types/react": "^19.3.0",
|
|
86
89
|
"ai": "^7.0.179",
|
|
87
90
|
"react": "^19.3.1",
|
|
88
|
-
"stitchkit": "0.
|
|
91
|
+
"stitchkit": "0.127.0",
|
|
89
92
|
"typescript": "^7.0.2"
|
|
90
93
|
},
|
|
91
94
|
"engines": {
|
|
92
|
-
"bun": ">=1.
|
|
95
|
+
"bun": ">=1.4.0"
|
|
93
96
|
},
|
|
94
97
|
"packageManager": "bun@1.4.5"
|
|
95
98
|
}
|
package/template/README.md
CHANGED
|
@@ -51,7 +51,17 @@ database migrations you add and launches:
|
|
|
51
51
|
- OpenAPI: <http://localhost:3211/openapi.json>
|
|
52
52
|
- MCP: <http://localhost:3211/mcp>
|
|
53
53
|
|
|
54
|
-
The home page
|
|
54
|
+
The home page carries one reference vertical feature, a notes board, and no
|
|
55
|
+
product of yours. The board is the slice you replace with your first feature:
|
|
56
|
+
`packages/shared/src/{schemas,contracts}/board.ts`, `packages/backend/src/lib/board.ts`,
|
|
57
|
+
`packages/backend/src/transport/board-service.ts`, the live channel in
|
|
58
|
+
`packages/backend/src/lib/live.ts` and `packages/shared/src/contracts/live.ts`,
|
|
59
|
+
`packages/frontend/src/features/board/`, and `BOARD_STORE_PATH` in
|
|
60
|
+
`packages/config/src/variables.ts`. Two checks lean on it: the end-to-end test in
|
|
61
|
+
`e2e/starter.spec.ts` proves the socket by posting a note from one tab to another,
|
|
62
|
+
and `packages/backend/src/surface.snapshot.json` records the board's operations.
|
|
63
|
+
Removing the board without giving the socket another probe leaves the socket
|
|
64
|
+
unproven.
|
|
55
65
|
Add application features as vertical schema → contract → service → client slices.
|
|
56
66
|
The exact workflow is in [`docs/ADDING_A_FEATURE.md`](docs/ADDING_A_FEATURE.md),
|
|
57
67
|
and root [`AGENTS.md`](AGENTS.md) gives coding agents the application boundaries.
|
|
@@ -141,7 +151,7 @@ Both read the catalogue or `/openapi.json`, so that deployment needs
|
|
|
141
151
|
|
|
142
152
|
## Requirements
|
|
143
153
|
|
|
144
|
-
- **Bun** and **Node ≥ 22**.
|
|
154
|
+
- **Bun ≥ 1.4** and **Node ≥ 22.3**.
|
|
145
155
|
- **PostgreSQL** — external infrastructure, in development and production
|
|
146
156
|
alike. This project owns its schema and migrations, never the database
|
|
147
157
|
process.
|