@myrialabs/clopen 0.4.37 → 0.4.39
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/README.md +2 -2
- package/backend/auth/permissions.ts +39 -0
- package/backend/bootstrap.ts +16 -0
- package/backend/chat/stream-manager.ts +1 -1
- package/backend/database/crypto/envelope.test.ts +93 -0
- package/backend/database/crypto/envelope.ts +127 -0
- package/backend/database/crypto/index.ts +22 -0
- package/backend/database/crypto/master-key.ts +129 -0
- package/backend/database/crypto/secret-columns.ts +151 -0
- package/backend/database/migrations/071_create_notes_tables.ts +90 -0
- package/backend/database/migrations/072_encrypt_stored_secrets.ts +107 -0
- package/backend/database/migrations/073_create_integration_tables.ts +119 -0
- package/backend/database/migrations/074_create_work_tables.ts +94 -0
- package/backend/database/migrations/075_create_deploy_bindings.ts +54 -0
- package/backend/database/migrations/076_remove_memory_code_graph.ts +229 -0
- package/backend/database/migrations/077_create_integration_db_links.ts +150 -0
- package/backend/database/migrations/index.ts +49 -0
- package/backend/database/queries/db-client-connection-queries.ts +42 -12
- package/backend/database/queries/deploy-queries.ts +124 -0
- package/backend/database/queries/engine-queries.ts +23 -10
- package/backend/database/queries/graph-queries.ts +291 -247
- package/backend/database/queries/index.ts +10 -1
- package/backend/database/queries/integration-db-link-queries.ts +168 -0
- package/backend/database/queries/integration-queries.ts +325 -0
- package/backend/database/queries/mcp-server-queries.ts +38 -11
- package/backend/database/queries/note-queries.test.ts +190 -0
- package/backend/database/queries/note-queries.ts +269 -0
- package/backend/database/queries/profile-queries.ts +1 -1
- package/backend/database/queries/ssh-connection-queries.ts +19 -8
- package/backend/database/queries/work-queries.ts +210 -0
- package/backend/db-client/integrations/index.ts +37 -0
- package/backend/db-client/integrations/links.ts +533 -0
- package/backend/db-client/integrations/projector.test.ts +280 -0
- package/backend/db-client/integrations/projector.ts +256 -0
- package/backend/db-client/integrations/supabase-service.ts +266 -0
- package/backend/db-client/providers/registry.ts +27 -0
- package/backend/db-client/providers/supabase/adapter.ts +500 -0
- package/backend/db-client/providers/supabase/api-types.ts +92 -0
- package/backend/db-client/providers/supabase/apply-migration.ts +104 -0
- package/backend/db-client/providers/supabase/client.ts +259 -0
- package/backend/db-client/providers/supabase/features.ts +502 -0
- package/backend/db-client/providers/supabase/local.test.ts +78 -0
- package/backend/db-client/providers/supabase/local.ts +137 -0
- package/backend/db-client/providers/types.ts +137 -0
- package/backend/deployments/bindings.test.ts +43 -0
- package/backend/deployments/bindings.ts +216 -0
- package/backend/deployments/index.ts +53 -0
- package/backend/deployments/log-streams.ts +214 -0
- package/backend/deployments/prompts.ts +70 -0
- package/backend/deployments/providers/vercel/adapter.ts +757 -0
- package/backend/deployments/providers/vercel/build-logs.test.ts +80 -0
- package/backend/deployments/providers/vercel/build-logs.ts +211 -0
- package/backend/deployments/providers/vercel/client.ts +203 -0
- package/backend/deployments/providers/vercel/list.test.ts +624 -0
- package/backend/deployments/providers/vercel/normalise.test.ts +115 -0
- package/backend/deployments/providers/vercel/normalise.ts +113 -0
- package/backend/deployments/providers/vercel/types.ts +104 -0
- package/backend/deployments/registry.ts +27 -0
- package/backend/deployments/service.ts +458 -0
- package/backend/deployments/types.ts +278 -0
- package/backend/engine/docs/artifacts.md +22 -9
- package/backend/files/os-clipboard.test.ts +209 -0
- package/backend/files/os-clipboard.ts +567 -0
- package/backend/http/integration-hooks.ts +42 -0
- package/backend/http/notes-images.test.ts +228 -0
- package/backend/http/notes-images.ts +196 -0
- package/backend/index.ts +13 -0
- package/backend/integrations/accounts.ts +229 -0
- package/backend/integrations/health.ts +146 -0
- package/backend/integrations/index.ts +36 -0
- package/backend/integrations/projections/index.ts +0 -0
- package/backend/integrations/projections/mcp-projector.test.ts +204 -0
- package/backend/integrations/projections/mcp-projector.ts +163 -0
- package/backend/integrations/projections/types.ts +63 -0
- package/backend/integrations/registry/define.ts +38 -0
- package/backend/integrations/registry/index.ts +60 -0
- package/backend/integrations/registry/providers/context7.ts +44 -0
- package/backend/integrations/registry/providers/firecrawl.ts +41 -0
- package/backend/integrations/registry/providers/github.ts +78 -0
- package/backend/integrations/registry/providers/supabase.ts +61 -0
- package/backend/integrations/registry/providers/vercel.ts +46 -0
- package/backend/integrations/registry/types.ts +96 -0
- package/backend/integrations/webhooks/gateway.ts +160 -0
- package/backend/integrations/webhooks/verify.ts +65 -0
- package/backend/mcp/README.md +25 -3
- package/backend/mcp/external/config.ts +35 -1
- package/backend/mcp/index.ts +1 -1
- package/backend/mcp/internal/config.ts +1 -1
- package/backend/mcp/internal/servers/memory-graph/description.ts +3 -3
- package/backend/mcp/internal/servers/memory-graph/runner.ts +4 -9
- package/backend/mcp/internal/servers/memory-graph/schema.ts +0 -4
- package/backend/memory/README.md +57 -34
- package/backend/memory/compose.test.ts +3 -3
- package/backend/memory/compose.ts +6 -9
- package/backend/memory/config.ts +0 -5
- package/backend/memory/consolidate.ts +1 -2
- package/backend/memory/context.test.ts +8 -54
- package/backend/memory/context.ts +19 -25
- package/backend/memory/extract/episodic.ts +10 -12
- package/backend/memory/extract/index.ts +23 -52
- package/backend/memory/extract/scheduler.ts +3 -6
- package/backend/memory/index.ts +6 -5
- package/backend/memory/invalidate.ts +36 -48
- package/backend/memory/layout.ts +319 -130
- package/backend/memory/retention.ts +12 -42
- package/backend/memory/retrieval.eval.test.ts +2 -2
- package/backend/memory/retrieval.test.ts +228 -183
- package/backend/memory/retrieval.ts +22 -21
- package/backend/memory/revise.test.ts +62 -116
- package/backend/memory/revise.ts +0 -1
- package/backend/memory/view.ts +8 -5
- package/backend/notes/access.test.ts +82 -0
- package/backend/notes/access.ts +27 -0
- package/backend/notes/storage.test.ts +77 -0
- package/backend/notes/storage.ts +114 -0
- package/backend/permissions/service.ts +2 -2
- package/backend/profiles/service.ts +1 -1
- package/backend/projects/project-cleanup.ts +6 -0
- package/backend/snapshot/helpers.ts +35 -41
- package/backend/snapshot/snapshot-service.ts +90 -0
- package/backend/snapshot/turn-changes.test.ts +163 -0
- package/backend/snapshot/turn-changes.ts +131 -0
- package/backend/work/bindings.ts +124 -0
- package/backend/work/index.ts +42 -0
- package/backend/work/prompts.ts +150 -0
- package/backend/work/providers/github/actions-logs.ts +180 -0
- package/backend/work/providers/github/adapter.test.ts +88 -0
- package/backend/work/providers/github/adapter.ts +1255 -0
- package/backend/work/providers/github/client.ts +280 -0
- package/backend/work/providers/github/list-range.test.ts +158 -0
- package/backend/work/providers/github/token-kind.test.ts +42 -0
- package/backend/work/pull-requests.ts +242 -0
- package/backend/work/registry.ts +27 -0
- package/backend/work/service.ts +436 -0
- package/backend/work/start-work.test.ts +71 -0
- package/backend/work/start-work.ts +232 -0
- package/backend/work/types.ts +180 -0
- package/backend/ws/db-client/accounts.ts +225 -0
- package/backend/ws/db-client/connections.ts +34 -3
- package/backend/ws/db-client/context.ts +37 -0
- package/backend/ws/db-client/index.ts +20 -1
- package/backend/ws/db-client/supabase.ts +188 -0
- package/backend/ws/deployments/actions.ts +360 -0
- package/backend/ws/deployments/context.ts +43 -0
- package/backend/ws/deployments/crud.ts +152 -0
- package/backend/ws/deployments/index.ts +15 -0
- package/backend/ws/deployments/schemas.ts +183 -0
- package/backend/ws/files/clipboard.ts +78 -0
- package/backend/ws/files/index.ts +5 -0
- package/backend/ws/git/diff-budget.ts +70 -11
- package/backend/ws/index.ts +16 -2
- package/backend/ws/integrations/crud.ts +219 -0
- package/backend/ws/integrations/index.ts +22 -0
- package/backend/ws/mcp/crud.ts +25 -1
- package/backend/ws/memory/crud.ts +4 -16
- package/backend/ws/notes/index.ts +278 -0
- package/backend/ws/profiles/crud.ts +1 -1
- package/backend/ws/snapshot/changes.ts +279 -0
- package/backend/ws/snapshot/index.ts +4 -3
- package/backend/ws/work/actions.ts +206 -0
- package/backend/ws/work/context.ts +51 -0
- package/backend/ws/work/crud.ts +347 -0
- package/backend/ws/work/index.ts +17 -0
- package/backend/ws/work/pull-requests.ts +177 -0
- package/backend/ws/work/schemas.ts +226 -0
- package/dist/assets/{index-sJmS_CCm.js → index-BrF6nqld.js} +1 -1
- package/dist/assets/{index-Bik9TCBi.js → index-C8Gi-b6U.js} +1 -1
- package/dist/assets/main-Bd3gb79F.css +1 -0
- package/dist/assets/main-Bo1hD7mt.js +1191 -0
- package/dist/index.html +2 -2
- package/package.json +1 -1
- package/shared/constants/engine-tools.ts +1 -1
- package/shared/constants/tool-icons.ts +42 -0
- package/shared/types/database/schema.ts +41 -0
- package/shared/types/db-client/connection.ts +6 -0
- package/shared/types/db-client/index.ts +2 -0
- package/shared/types/db-client/integrations.ts +174 -0
- package/shared/types/db-client/supabase.ts +131 -0
- package/shared/types/deployments.ts +382 -0
- package/shared/types/integrations.ts +140 -0
- package/shared/types/memory.ts +34 -51
- package/shared/types/stores/settings.ts +8 -0
- package/shared/types/ui/components.ts +1 -1
- package/shared/types/work.ts +426 -0
- package/shared/utils/diff-calculator.test.ts +89 -0
- package/shared/utils/diff-calculator.ts +30 -65
- package/shared/utils/logger.ts +4 -0
- package/backend/memory/extract/languages.ts +0 -176
- package/backend/memory/extract/structural.test.ts +0 -215
- package/backend/memory/extract/structural.ts +0 -364
- package/backend/ws/snapshot/content.ts +0 -85
- package/dist/assets/main-DLqolBI2.css +0 -1
- package/dist/assets/main-Df1I3hnw.js +0 -1096
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Following a running build's logs.
|
|
3
|
+
*
|
|
4
|
+
* A follow is an HTTP response that never ends, which is the one thing an
|
|
5
|
+
* ordinary request path cannot carry — it would read the body to completion and
|
|
6
|
+
* block forever. So it gets its own manager, and pays for that with hard
|
|
7
|
+
* limits: a bounded number of concurrent streams, a bounded ring buffer per
|
|
8
|
+
* stream, and an owner whose socket closing takes the stream with it.
|
|
9
|
+
*
|
|
10
|
+
* Output is coalesced and flushed on a short interval rather than pushed per
|
|
11
|
+
* chunk, the same way container logs are. A build emits hundreds of tiny
|
|
12
|
+
* writes, and one WebSocket frame each would cost more than the log is worth.
|
|
13
|
+
*
|
|
14
|
+
* One stream per user per deployment: a second tab watching the same build
|
|
15
|
+
* joins the first rather than opening a second follow against the provider.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { deployService } from './service';
|
|
19
|
+
import { getDeployAdapter } from './registry';
|
|
20
|
+
import { ws } from '$backend/utils/ws';
|
|
21
|
+
import { debug } from '$shared/utils/logger';
|
|
22
|
+
|
|
23
|
+
/** Lines held for a viewer that joins a build already in progress. */
|
|
24
|
+
const BUFFER_LINES = 2_000;
|
|
25
|
+
/**
|
|
26
|
+
* Streams one user may hold at once.
|
|
27
|
+
*
|
|
28
|
+
* Bounded because each one is an open socket against a metered API, and a user
|
|
29
|
+
* who opens six builds in six tabs should not silently hold six follows.
|
|
30
|
+
*/
|
|
31
|
+
const MAX_STREAMS_PER_USER = 4;
|
|
32
|
+
/** How often buffered output is pushed to the client. */
|
|
33
|
+
const FLUSH_INTERVAL_MS = 150;
|
|
34
|
+
|
|
35
|
+
interface BuildLogStream {
|
|
36
|
+
id: string;
|
|
37
|
+
userId: string;
|
|
38
|
+
deploymentId: string;
|
|
39
|
+
buffer: string[];
|
|
40
|
+
pending: string;
|
|
41
|
+
/** Stage the provider last reported, rendered above the log. */
|
|
42
|
+
phase: string | null;
|
|
43
|
+
flushTimer: ReturnType<typeof setInterval> | null;
|
|
44
|
+
stop: () => void;
|
|
45
|
+
stopped: boolean;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const streams = new Map<string, BuildLogStream>();
|
|
49
|
+
|
|
50
|
+
function streamIdFor(userId: string, accountId: string, deploymentId: string): string {
|
|
51
|
+
return `${userId}:${accountId}:${deploymentId}`;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function countForUser(userId: string): number {
|
|
55
|
+
let count = 0;
|
|
56
|
+
for (const stream of streams.values()) if (stream.userId === userId) count++;
|
|
57
|
+
return count;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Keep the ring bounded, counting lines rather than bytes so a trim never cuts
|
|
62
|
+
* a line in half. Chunks arrive at arbitrary boundaries, so the first piece of
|
|
63
|
+
* one continues whatever line the previous chunk left open.
|
|
64
|
+
*/
|
|
65
|
+
function appendToBuffer(stream: BuildLogStream, text: string): void {
|
|
66
|
+
const lines = text.split('\n');
|
|
67
|
+
if (stream.buffer.length > 0) {
|
|
68
|
+
stream.buffer[stream.buffer.length - 1] += lines.shift() ?? '';
|
|
69
|
+
}
|
|
70
|
+
for (const line of lines) stream.buffer.push(line);
|
|
71
|
+
if (stream.buffer.length > BUFFER_LINES) {
|
|
72
|
+
stream.buffer.splice(0, stream.buffer.length - BUFFER_LINES);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function flush(stream: BuildLogStream): void {
|
|
77
|
+
if (!stream.pending) return;
|
|
78
|
+
const data = stream.pending;
|
|
79
|
+
stream.pending = '';
|
|
80
|
+
ws.emit.user(stream.userId, 'deployments:log-chunk', {
|
|
81
|
+
streamId: stream.id,
|
|
82
|
+
deploymentId: stream.deploymentId,
|
|
83
|
+
data,
|
|
84
|
+
...(stream.phase && { phase: stream.phase })
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function finish(stream: BuildLogStream, error: string | null): void {
|
|
89
|
+
if (stream.stopped) return;
|
|
90
|
+
stream.stopped = true;
|
|
91
|
+
flush(stream);
|
|
92
|
+
if (stream.flushTimer) clearInterval(stream.flushTimer);
|
|
93
|
+
streams.delete(stream.id);
|
|
94
|
+
ws.emit.user(stream.userId, 'deployments:log-chunk', {
|
|
95
|
+
streamId: stream.id,
|
|
96
|
+
deploymentId: stream.deploymentId,
|
|
97
|
+
data: '',
|
|
98
|
+
done: true,
|
|
99
|
+
error
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export interface StartedBuildLogStream {
|
|
104
|
+
streamId: string;
|
|
105
|
+
/** Whatever the ring already holds, for a viewer joining late. */
|
|
106
|
+
backlog: string;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Start following a build, or join the stream already following it.
|
|
111
|
+
*
|
|
112
|
+
* The capability is checked before anything is opened: a provider without
|
|
113
|
+
* `streamLogs` must fall back to the fetched bundle on the client, and
|
|
114
|
+
* discovering that after a socket is open is a stream that immediately ends.
|
|
115
|
+
*/
|
|
116
|
+
export async function startBuildLogStream(
|
|
117
|
+
projectId: string,
|
|
118
|
+
accountId: string,
|
|
119
|
+
deploymentId: string,
|
|
120
|
+
userId: string
|
|
121
|
+
): Promise<StartedBuildLogStream> {
|
|
122
|
+
const id = streamIdFor(userId, accountId, deploymentId);
|
|
123
|
+
const existing = streams.get(id);
|
|
124
|
+
// Rejoined with the newlines the buffer strips, or the whole backlog would
|
|
125
|
+
// arrive as one enormous line.
|
|
126
|
+
if (existing) return { streamId: id, backlog: existing.buffer.join('\n') };
|
|
127
|
+
|
|
128
|
+
const { adapter, context } = deployService.require(projectId, accountId);
|
|
129
|
+
if (!adapter.capabilities.streamLogs || !adapter.streamLogs) {
|
|
130
|
+
throw new Error(`${context.account.label} does not stream build logs`);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (countForUser(userId) >= MAX_STREAMS_PER_USER) {
|
|
134
|
+
throw new Error(
|
|
135
|
+
`Already following ${MAX_STREAMS_PER_USER} builds. Close one before opening another.`
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const stream: BuildLogStream = {
|
|
140
|
+
id,
|
|
141
|
+
userId,
|
|
142
|
+
deploymentId,
|
|
143
|
+
buffer: [],
|
|
144
|
+
pending: '',
|
|
145
|
+
phase: null,
|
|
146
|
+
flushTimer: null,
|
|
147
|
+
stop: () => undefined,
|
|
148
|
+
stopped: false
|
|
149
|
+
};
|
|
150
|
+
streams.set(id, stream);
|
|
151
|
+
|
|
152
|
+
stream.flushTimer = setInterval(() => flush(stream), FLUSH_INTERVAL_MS);
|
|
153
|
+
stream.flushTimer.unref?.();
|
|
154
|
+
|
|
155
|
+
try {
|
|
156
|
+
const handle = await adapter.streamLogs(context, deploymentId, {
|
|
157
|
+
onChunk: (text) => {
|
|
158
|
+
if (stream.stopped) return;
|
|
159
|
+
appendToBuffer(stream, text);
|
|
160
|
+
stream.pending += text;
|
|
161
|
+
},
|
|
162
|
+
onPhase: (phase) => {
|
|
163
|
+
if (stream.stopped) return;
|
|
164
|
+
stream.phase = phase;
|
|
165
|
+
// Pushed immediately rather than on the flush interval: a phase
|
|
166
|
+
// change is the only sign of life during the stretches of a build
|
|
167
|
+
// that print nothing, so holding it back defeats its purpose.
|
|
168
|
+
ws.emit.user(stream.userId, 'deployments:log-chunk', {
|
|
169
|
+
streamId: stream.id,
|
|
170
|
+
deploymentId: stream.deploymentId,
|
|
171
|
+
data: '',
|
|
172
|
+
phase
|
|
173
|
+
});
|
|
174
|
+
},
|
|
175
|
+
onEnd: (error) => finish(stream, error)
|
|
176
|
+
});
|
|
177
|
+
stream.stop = handle.stop;
|
|
178
|
+
} catch (error) {
|
|
179
|
+
finish(stream, error instanceof Error ? error.message : String(error));
|
|
180
|
+
throw error;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
debug.log('deployments', `Following build logs for ${deploymentId}`);
|
|
184
|
+
return { streamId: id, backlog: '' };
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/** Stop one stream, if it belongs to this user. */
|
|
188
|
+
export function stopBuildLogStream(streamId: string, userId: string): void {
|
|
189
|
+
const stream = streams.get(streamId);
|
|
190
|
+
if (!stream || stream.userId !== userId) return;
|
|
191
|
+
stream.stop();
|
|
192
|
+
finish(stream, null);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/** Stop every stream a user holds, when their socket goes away. */
|
|
196
|
+
export function stopBuildLogStreamsForUser(userId: string): void {
|
|
197
|
+
for (const stream of [...streams.values()]) {
|
|
198
|
+
if (stream.userId === userId) {
|
|
199
|
+
stream.stop();
|
|
200
|
+
finish(stream, null);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/** Stop everything, when the process is shutting down. */
|
|
206
|
+
export function stopAllBuildLogStreams(): void {
|
|
207
|
+
for (const stream of [...streams.values()]) {
|
|
208
|
+
stream.stop();
|
|
209
|
+
finish(stream, null);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/** Exported for the adapter-capability check in tests. */
|
|
214
|
+
export { getDeployAdapter };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The prompt this surface sends into a chat session.
|
|
3
|
+
*
|
|
4
|
+
* It lives on the SERVER, next to the data that fills it, for the same reason
|
|
5
|
+
* the Issues surface's prompts do: the text is assembled from a provider
|
|
6
|
+
* response the client never receives in full, and duplicating the assembly on
|
|
7
|
+
* both sides would mean two versions of the instructions to keep in step.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import type { BuildLogBundle, DeploymentDetail } from '$shared/types/deployments';
|
|
11
|
+
|
|
12
|
+
/** Commit subject kept from the build. Enough to identify what was deployed. */
|
|
13
|
+
const MAX_COMMIT_CHARS = 500;
|
|
14
|
+
|
|
15
|
+
function clip(text: string, limit: number): string {
|
|
16
|
+
const trimmed = (text ?? '').trim();
|
|
17
|
+
return trimmed.length <= limit ? trimmed : `${trimmed.slice(0, limit)}…`;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The message sent when a failed build is pushed into the chat.
|
|
22
|
+
*
|
|
23
|
+
* The facts come before the log on purpose. `errorCode` is often the whole
|
|
24
|
+
* answer — `BUILD_FAILED` versus a function size limit versus an out-of-memory
|
|
25
|
+
* report are three different investigations — and an agent that reads it first
|
|
26
|
+
* does not have to infer it from the tail of a log.
|
|
27
|
+
*/
|
|
28
|
+
export function buildDeployFailurePrompt(
|
|
29
|
+
deployment: DeploymentDetail,
|
|
30
|
+
bundle: BuildLogBundle,
|
|
31
|
+
context: { projectName: string; providerName: string }
|
|
32
|
+
): string {
|
|
33
|
+
const sections: string[] = [
|
|
34
|
+
`A ${deployment.environment} deployment failed on ${context.providerName} for ${context.projectName}.`
|
|
35
|
+
];
|
|
36
|
+
|
|
37
|
+
const facts: string[] = [`State: ${deployment.stateDetail}`];
|
|
38
|
+
if (deployment.errorCode) facts.push(`Error code: ${deployment.errorCode}`);
|
|
39
|
+
if (deployment.branch) facts.push(`Branch: ${deployment.branch}`);
|
|
40
|
+
if (deployment.commitSha) facts.push(`Commit: ${deployment.commitSha.slice(0, 8)}`);
|
|
41
|
+
if (deployment.framework) facts.push(`Framework: ${deployment.framework}`);
|
|
42
|
+
sections.push(facts.join(' · '));
|
|
43
|
+
|
|
44
|
+
if (deployment.commitMessage) {
|
|
45
|
+
sections.push(`Commit message:\n${clip(deployment.commitMessage, MAX_COMMIT_CHARS)}`);
|
|
46
|
+
}
|
|
47
|
+
if (deployment.errorMessage) {
|
|
48
|
+
sections.push(`Provider message:\n${deployment.errorMessage}`);
|
|
49
|
+
}
|
|
50
|
+
if (deployment.inspectorUrl) {
|
|
51
|
+
sections.push(`Build page: ${deployment.inspectorUrl}`);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
sections.push(
|
|
55
|
+
bundle.truncated
|
|
56
|
+
? 'Build log (tail only — earlier output was dropped to fit):'
|
|
57
|
+
: 'Build log:'
|
|
58
|
+
);
|
|
59
|
+
sections.push(`\`\`\`\n${bundle.text}\n\`\`\``);
|
|
60
|
+
|
|
61
|
+
sections.push(
|
|
62
|
+
[
|
|
63
|
+
'Work out what failed and why from this log, then check the claim against the code in this worktree before proposing anything.',
|
|
64
|
+
'A deployment build runs in a clean environment, so treat "works locally" as evidence that the cause is configuration, a missing dependency, an environment variable, or a build-only code path — not as evidence the log is wrong.',
|
|
65
|
+
'Propose the smallest change that addresses the cause. If the log is not enough to tell, say what else you need rather than guessing.'
|
|
66
|
+
].join(' ')
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
return sections.join('\n\n');
|
|
70
|
+
}
|