gpt-engineer-app[bot] commited on
Commit
0426577
Β·
1 Parent(s): 005d016
src/server/branch-debug.functions.ts CHANGED
@@ -244,7 +244,7 @@ For each hunk that plausibly caused the failure, return a suspect entry with:
244
 
245
  Rank by likelihood. Be conservative; if a hunk is unrelated, do not include it. Always call submit_root_cause_analysis.`;
246
 
247
- export async function analyzeDiff(diff: string, failureDescription: string): Promise<DebugResult> {
248
  getAIConfig();
249
 
250
  const { sanitized, reverseMap, stats, audit } = sanitize(diff);
@@ -270,7 +270,7 @@ export async function analyzeDiff(diff: string, failureDescription: string): Pro
270
  ],
271
  tools: [analysisTool],
272
  tool_choice: { type: "function", function: { name: "submit_root_cause_analysis" } },
273
- }), "google/gemini-2.5-pro", "debugBranch");
274
 
275
  if (!resp.ok) {
276
  const text = await resp.text();
@@ -320,8 +320,8 @@ export async function analyzeDiff(diff: string, failureDescription: string): Pro
320
  export const debugBranch = createServerFn({ method: "POST" })
321
  .middleware([requireSupabaseAuth])
322
  .inputValidator((d: unknown) => InputSchema.parse(d))
323
- .handler(async ({ data }): Promise<DebugResult> => {
324
- return analyzeDiff(data.diff, data.failureDescription);
325
  });
326
 
327
  // ───────────────────────── Snippet mode (no diff) ─────────────────────────
@@ -390,6 +390,7 @@ export async function analyzeSnippet(
390
  snippet: string,
391
  failureDescription: string,
392
  language?: string,
 
393
  ): Promise<DebugResult> {
394
  getAIConfig();
395
 
@@ -405,7 +406,7 @@ export async function analyzeSnippet(
405
  ],
406
  tools: [snippetTool],
407
  tool_choice: { type: "function", function: { name: "submit_snippet_analysis" } },
408
- }), "google/gemini-2.5-pro", "debugSnippet");
409
 
410
  if (!resp.ok) {
411
  const text = await resp.text();
@@ -450,7 +451,7 @@ export async function analyzeSnippet(
450
  export const debugSnippet = createServerFn({ method: "POST" })
451
  .middleware([requireSupabaseAuth])
452
  .inputValidator((d: unknown) => SnippetInputSchema.parse(d))
453
- .handler(async ({ data }): Promise<DebugResult> => {
454
- return analyzeSnippet(data.snippet, data.failureDescription, data.language);
455
  });
456
 
 
244
 
245
  Rank by likelihood. Be conservative; if a hunk is unrelated, do not include it. Always call submit_root_cause_analysis.`;
246
 
247
+ export async function analyzeDiff(diff: string, failureDescription: string, userId?: string | null): Promise<DebugResult> {
248
  getAIConfig();
249
 
250
  const { sanitized, reverseMap, stats, audit } = sanitize(diff);
 
270
  ],
271
  tools: [analysisTool],
272
  tool_choice: { type: "function", function: { name: "submit_root_cause_analysis" } },
273
+ }), "google/gemini-2.5-pro", "debugBranch", userId);
274
 
275
  if (!resp.ok) {
276
  const text = await resp.text();
 
320
  export const debugBranch = createServerFn({ method: "POST" })
321
  .middleware([requireSupabaseAuth])
322
  .inputValidator((d: unknown) => InputSchema.parse(d))
323
+ .handler(async ({ data, context }): Promise<DebugResult> => {
324
+ return analyzeDiff(data.diff, data.failureDescription, context.userId);
325
  });
326
 
327
  // ───────────────────────── Snippet mode (no diff) ─────────────────────────
 
390
  snippet: string,
391
  failureDescription: string,
392
  language?: string,
393
+ userId?: string | null,
394
  ): Promise<DebugResult> {
395
  getAIConfig();
396
 
 
406
  ],
407
  tools: [snippetTool],
408
  tool_choice: { type: "function", function: { name: "submit_snippet_analysis" } },
409
+ }), "google/gemini-2.5-pro", "debugSnippet", userId);
410
 
411
  if (!resp.ok) {
412
  const text = await resp.text();
 
451
  export const debugSnippet = createServerFn({ method: "POST" })
452
  .middleware([requireSupabaseAuth])
453
  .inputValidator((d: unknown) => SnippetInputSchema.parse(d))
454
+ .handler(async ({ data, context }): Promise<DebugResult> => {
455
+ return analyzeSnippet(data.snippet, data.failureDescription, data.language, context.userId);
456
  });
457
 
src/server/forensic.functions.ts CHANGED
@@ -471,7 +471,7 @@ function deepRestore(value: any, rev: Map<string, string>): any {
471
  export const runForensicStage = createServerFn({ method: "POST" })
472
  .middleware([requireSupabaseAuth])
473
  .inputValidator((d: unknown) => StageInput.parse(d))
474
- .handler(async ({ data }): Promise<{ result: StageResult; sanitizationStats: { identifiersTokenized: number; commentsStripped: number; secretsBlocked: number } }> => {
475
  getAIConfig();
476
 
477
  const codeS = sanitize(data.code);
@@ -504,7 +504,7 @@ export const runForensicStage = createServerFn({ method: "POST" })
504
  ],
505
  tools,
506
  tool_choice: { type: "function", function: { name: toolName } },
507
- }), "google/gemini-2.5-flash", `forensicStage${data.stage}`);
508
 
509
  if (!resp.ok) {
510
  const text = await resp.text();
 
471
  export const runForensicStage = createServerFn({ method: "POST" })
472
  .middleware([requireSupabaseAuth])
473
  .inputValidator((d: unknown) => StageInput.parse(d))
474
+ .handler(async ({ data, context }): Promise<{ result: StageResult; sanitizationStats: { identifiersTokenized: number; commentsStripped: number; secretsBlocked: number } }> => {
475
  getAIConfig();
476
 
477
  const codeS = sanitize(data.code);
 
504
  ],
505
  tools,
506
  tool_choice: { type: "function", function: { name: toolName } },
507
+ }), "google/gemini-2.5-flash", `forensicStage${data.stage}`, context.userId);
508
 
509
  if (!resp.ok) {
510
  const text = await resp.text();