lacuna-cli 0.1.9 → 0.2.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.
Files changed (40) hide show
  1. package/README.md +57 -3
  2. package/dist/agent/fix-loop.d.ts +1 -0
  3. package/dist/agent/fix-loop.d.ts.map +1 -1
  4. package/dist/agent/fix-loop.js +110 -20
  5. package/dist/agent/fix-loop.js.map +1 -1
  6. package/dist/agent/generator.d.ts +5 -0
  7. package/dist/agent/generator.d.ts.map +1 -1
  8. package/dist/agent/generator.js +149 -20
  9. package/dist/agent/generator.js.map +1 -1
  10. package/dist/agent/loop.d.ts.map +1 -1
  11. package/dist/agent/loop.js +88 -22
  12. package/dist/agent/loop.js.map +1 -1
  13. package/dist/agent/prompts/index.d.ts +2 -1
  14. package/dist/agent/prompts/index.d.ts.map +1 -1
  15. package/dist/agent/prompts/index.js +39 -8
  16. package/dist/agent/prompts/index.js.map +1 -1
  17. package/dist/commands/fix.d.ts +1 -0
  18. package/dist/commands/fix.d.ts.map +1 -1
  19. package/dist/commands/fix.js +20 -5
  20. package/dist/commands/fix.js.map +1 -1
  21. package/dist/commands/generate.d.ts.map +1 -1
  22. package/dist/commands/generate.js +6 -0
  23. package/dist/commands/generate.js.map +1 -1
  24. package/dist/commands/init.d.ts.map +1 -1
  25. package/dist/commands/init.js +6 -1
  26. package/dist/commands/init.js.map +1 -1
  27. package/dist/lib/config.d.ts +4 -2
  28. package/dist/lib/config.d.ts.map +1 -1
  29. package/dist/lib/config.js +43 -30
  30. package/dist/lib/config.js.map +1 -1
  31. package/dist/lib/typecheck.d.ts +1 -0
  32. package/dist/lib/typecheck.d.ts.map +1 -1
  33. package/dist/lib/typecheck.js +119 -7
  34. package/dist/lib/typecheck.js.map +1 -1
  35. package/dist/lib/validate.d.ts +12 -1
  36. package/dist/lib/validate.d.ts.map +1 -1
  37. package/dist/lib/validate.js +106 -19
  38. package/dist/lib/validate.js.map +1 -1
  39. package/lacuna.schema.json +150 -0
  40. package/package.json +6 -4
@@ -1,6 +1,63 @@
1
+ import { writeFile, appendFile, mkdir } from 'fs/promises';
2
+ import { basename, extname, dirname } from 'path';
1
3
  import { createProvider } from '../lib/providers/index.js';
2
4
  export { ModelStallError } from '../lib/providers/types.js';
3
- import { buildSystemPrompt, buildGeneratePrompt, buildFixPrompt, buildRetryPrompt, buildPollutionFixPrompt } from './prompts/index.js';
5
+ import { buildSystemPrompt, buildGeneratePrompt, buildFixPrompt, buildRetryPrompt, buildPollutionFixPrompt, PATCH_MODE_LINE_THRESHOLD } from './prompts/index.js';
6
+ // When debug is enabled (config `debug: true` or the LACUNA_DEBUG env var), every raw model
7
+ // exchange is written to a per-file log. Each target file gets its own log (e.g.
8
+ // lacuna-debug.MessagingService.txt), cleared at the start of that file's generate()/fix() and
9
+ // appended through its retries — so parallel workers and multi-file runs never share/clobber
10
+ // one stream. The base is fixed; perFileDebugPath appends the target file name.
11
+ // Usage: LACUNA_DEBUG=1 lacuna generate | { "debug": true } in .lacuna.json
12
+ const DEFAULT_DEBUG_BASE = 'lacuna-debug.txt';
13
+ // Resolves the debug base path, or null when disabled. Debug is a simple on/off switch.
14
+ // Env var wins: any LACUNA_DEBUG value enables it (default base) except an explicit off
15
+ // (0/false/no/off). Otherwise config `debug: true` enables it; false/absent → off.
16
+ function resolveDebugBase(configDebug) {
17
+ const env = process.env.LACUNA_DEBUG;
18
+ if (env != null && env !== '')
19
+ return /^(0|false|no|off)$/i.test(env) ? null : DEFAULT_DEBUG_BASE;
20
+ return configDebug === true ? DEFAULT_DEBUG_BASE : null;
21
+ }
22
+ // User-facing pattern of where per-file debug logs are written, or null when disabled.
23
+ // e.g. "lacuna-debug.<file>.txt". Used by the command headers to surface debug state.
24
+ export function debugLogPattern(configDebug) {
25
+ const base = resolveDebugBase(configDebug);
26
+ if (!base)
27
+ return null;
28
+ const ext = extname(base);
29
+ return `${ext ? base.slice(0, -ext.length) : base}.<file>${ext}`;
30
+ }
31
+ const SEP = '═'.repeat(72);
32
+ // Derives a per-file debug path from the configured base by inserting the target file's
33
+ // name before the extension: "lacuna-debug.txt" + "MessagingService.test.ts" →
34
+ // "lacuna-debug.MessagingService.txt". Returns null when debug is disabled.
35
+ function perFileDebugPath(base, filePath) {
36
+ if (!base)
37
+ return null;
38
+ const slug = basename(filePath)
39
+ .replace(/\.(test|spec)\.[jt]sx?$/, '')
40
+ .replace(/\.[jt]sx?$/, '')
41
+ .replace(/[^a-zA-Z0-9._-]/g, '_') || 'file';
42
+ const ext = extname(base);
43
+ const baseNoExt = ext ? base.slice(0, -ext.length) : base;
44
+ return `${baseNoExt}.${slug}${ext}`;
45
+ }
46
+ async function debugWrite(file, label, content, clear = false) {
47
+ if (!file)
48
+ return;
49
+ const header = `\n${SEP}\n${label} — ${new Date().toISOString()}\n${SEP}\n`;
50
+ try {
51
+ if (clear) {
52
+ await mkdir(dirname(file), { recursive: true }); // support a custom base in a subdir
53
+ await writeFile(file, header + content + '\n', 'utf-8');
54
+ }
55
+ else {
56
+ await appendFile(file, header + content + '\n', 'utf-8');
57
+ }
58
+ }
59
+ catch { /* best-effort — never crash the agent for debug I/O */ }
60
+ }
4
61
  // Thrown when the model's output was cut off before </code_output> was emitted.
5
62
  // The partial code is attached so callers can include it in the retry message.
6
63
  export class TruncatedOutputError extends Error {
@@ -74,10 +131,10 @@ function normalizeCode(code) {
74
131
  return code.replace(/\s+/g, '');
75
132
  }
76
133
  const TRUNCATION_RETRY_MESSAGE = 'Your previous output produced no valid code — either it was cut off before completion, or your thinking block was not closed ' +
77
- 'before writing code (a <thinking> block was detected but no <code_output> section followed). ' +
134
+ 'before writing code (a <thinking> block was detected but no code section followed). ' +
78
135
  'IMMEDIATELY write the code — do NOT plan in a <thinking> block this time. ' +
79
- 'Write a short, focused test file. Cover the most important behaviors only — skip exhaustive edge cases. ' +
80
- 'Every function body must be closed. Use <code_output> tags.';
136
+ 'Keep it short and focused. Cover the most important behaviors only — skip exhaustive edge cases. ' +
137
+ 'Every function body must be closed. Write the code immediately in the required output format (the closing instruction below says which tag to use).';
81
138
  // Detect a prose repetition loop: the model wrote the same planning sentence 3+ times
82
139
  // without ever producing code. Only applied to the fallback path (no XML/fence tags).
83
140
  function isRepetitionLoop(text) {
@@ -130,15 +187,40 @@ function stripThinkingBleed(code) {
130
187
  s = s.replace(/^\s*<(thinking|think)>[\s\S]*/i, '');
131
188
  return s;
132
189
  }
190
+ // Strip a stray markdown code fence wrapping the output. Despite being told not to, models
191
+ // sometimes add an opening ```lang and/or a closing ``` around <code_output>/<code_patch>
192
+ // content. Written verbatim, a trailing ``` becomes an "Unterminated string literal" at EOF
193
+ // and a leading one breaks line 1. Only a fence occupying its own line at the very start or
194
+ // end is removed, so backticks inside template literals or string assertions are untouched.
195
+ function stripCodeFences(code) {
196
+ return code
197
+ .replace(/^\s*```(?:[a-zA-Z0-9]+)?[ \t]*\n/, '') // leading ```lang line
198
+ .replace(/\n[ \t]*```[ \t]*$/, '') // trailing ``` line
199
+ .replace(/^\s*```[ \t]*$/, '') // degenerate: output is only a fence
200
+ .trimEnd();
201
+ }
202
+ // Patch-operation header anchored at line start. Used to recognize patch output
203
+ // regardless of whether the model wrapped it in <code_patch> or — when nudged by the
204
+ // truncation retry message ("Use <code_output> tags") — inside <code_output>.
205
+ const PATCH_OP_RE = /^\/\/ @@@ (?:REPLACE_TEST|DELETE_TEST|ADD_AFTER_DESCRIBE|ADD_IMPORT|ADD_AFTER_IMPORTS|REPLACE):/m;
133
206
  function parseStructuredResponse(raw) {
134
207
  const thinkingMatch = raw.match(/<(?:thinking|think)>([\s\S]*?)<\/(?:thinking|think)>/i);
135
208
  const hypothesis = thinkingMatch ? thinkingMatch[1].trim() : '';
136
209
  // Check for <code_patch> FIRST — patch blocks are individually complete, skip truncation check.
137
210
  const lineAnchoredPatch = /(?:^|\n)<code_patch>[ \t]*(?:\n|$)/i;
138
- const patchMatch = lineAnchoredPatch.exec(raw);
211
+ let patchMatch = lineAnchoredPatch.exec(raw);
212
+ // Relaxed fallback: a real <code_patch> tag is sometimes glued to the end of a prose
213
+ // sentence ("...replace it.<code_patch>\n// @@@ REPLACE_TEST: ...") when the model skips
214
+ // the <thinking> wrapper and reasons in the open. Accept a non-line-anchored tag ONLY when
215
+ // actual patch ops follow it — so prose mentions ("use <code_patch> tags") never match.
216
+ if (!patchMatch) {
217
+ const glued = /<code_patch>[ \t]*\n/i.exec(raw);
218
+ if (glued && PATCH_OP_RE.test(raw.slice(glued.index + glued[0].length)))
219
+ patchMatch = glued;
220
+ }
139
221
  if (patchMatch) {
140
222
  const patchEnd = patchMatch.index + patchMatch[0].length;
141
- const code = stripThinkingBleed(raw.slice(patchEnd).trim());
223
+ const code = stripCodeFences(stripThinkingBleed(raw.slice(patchEnd).trim()));
142
224
  return { hypothesis, code, truncated: false, isPatch: true };
143
225
  }
144
226
  // The real <code_output> delimiter is always on its own line (preceded by \n or start-of-string).
@@ -149,13 +231,17 @@ function parseStructuredResponse(raw) {
149
231
  const openMatch = lineAnchoredOpen.exec(raw);
150
232
  if (openMatch) {
151
233
  const openEnd = openMatch.index + openMatch[0].length;
234
+ // Closing tag is usually absent — the </code_output> stop sequence fires cleanly.
152
235
  const closeMatch = lineAnchoredClose.exec(raw.slice(openEnd));
153
- if (closeMatch) {
154
- const code = stripThinkingBleed(raw.slice(openEnd, openEnd + closeMatch.index).trim());
155
- return { hypothesis, code, truncated: isCodeIncomplete(code), isPatch: false };
236
+ const code = stripCodeFences(stripThinkingBleed((closeMatch ? raw.slice(openEnd, openEnd + closeMatch.index) : raw.slice(openEnd)).trim()));
237
+ // A model told to "use <code_output> tags" (notably by the truncation retry message)
238
+ // may emit PATCH ops inside <code_output> rather than <code_patch>. Patch blocks are
239
+ // individually complete and embed intentionally unbalanced code fragments as anchors,
240
+ // so the full-file truncation check (isCodeIncomplete) would wrongly flag them as cut
241
+ // off and loop forever. Detect patch ops and treat them exactly like a <code_patch> block.
242
+ if (PATCH_OP_RE.test(code)) {
243
+ return { hypothesis, code, truncated: false, isPatch: true };
156
244
  }
157
- // No closing tag — normal when stop sequence fires cleanly
158
- const code = stripThinkingBleed(raw.slice(openEnd).trim());
159
245
  return { hypothesis, code, truncated: isCodeIncomplete(code), isPatch: false };
160
246
  }
161
247
  // No XML tags — extract the last fenced code block if present.
@@ -163,11 +249,23 @@ function parseStructuredResponse(raw) {
163
249
  // settling on a final answer; the last block is the intended output.
164
250
  // After extracting, check whether the content looks like patch ops (// @@@ headers) —
165
251
  // models that skip <code_patch> tags but follow the @@@-format still get patch mode.
166
- const fenceMatches = [...raw.matchAll(/```(?:typescript|tsx?|javascript|jsx?|python|go)?\s*\n([\s\S]*?)```/g)];
167
- if (fenceMatches.length > 0) {
168
- const code = stripThinkingBleed(fenceMatches[fenceMatches.length - 1][1].trim());
169
- const isPatch = /^\/\/ @@@ (REPLACE_TEST|DELETE_TEST|ADD_AFTER_DESCRIBE|ADD_IMPORT|ADD_AFTER_IMPORTS|REPLACE):/m.test(code);
170
- return { hypothesis, code, truncated: isCodeIncomplete(code), isPatch };
252
+ //
253
+ // IMPORTANT: skip fenced blocks when the entire response is inside an unclosed
254
+ // <thinking> block. DeepSeek sometimes quotes large test-file excerpts inside its
255
+ // analysis using backtick fences; picking up the last one as "output" produces a code
256
+ // snippet with no it() calls and fires a spurious "no tests" error. When thinking is
257
+ // unclosed, those fenced blocks are analysis, not code output — ignore them entirely.
258
+ const hasOpenThinking = /<(?:thinking|think)>/i.test(raw);
259
+ const hasCloseThinking = /<\/(?:thinking|think)>/i.test(raw);
260
+ const thinkingIsUnclosed = hasOpenThinking && !hasCloseThinking;
261
+ if (!thinkingIsUnclosed) {
262
+ const fenceMatches = [...raw.matchAll(/```(?:typescript|tsx?|javascript|jsx?|python|go)?\s*\n([\s\S]*?)```/g)];
263
+ if (fenceMatches.length > 0) {
264
+ const code = stripThinkingBleed(fenceMatches[fenceMatches.length - 1][1].trim());
265
+ const isPatch = PATCH_OP_RE.test(code);
266
+ // Patches are individually complete — don't run the full-file truncation check on them.
267
+ return { hypothesis, code, truncated: isPatch ? false : isCodeIncomplete(code), isPatch };
268
+ }
171
269
  }
172
270
  // No fenced blocks at all — strip any single fence pair and use as code.
173
271
  // Also catch repetition loops: if the raw text has the same prose sentence 3+ times,
@@ -176,9 +274,19 @@ function parseStructuredResponse(raw) {
176
274
  let fallback = raw.trim();
177
275
  fallback = fallback.replace(/^```(?:typescript|tsx?|javascript|jsx?|python|go)?\s*\n/, '');
178
276
  fallback = fallback.replace(/\n```\s*$/, '');
179
- const code = stripThinkingBleed(fallback.trim());
180
- const isPatch = /^\/\/ @@@ (REPLACE_TEST|DELETE_TEST|ADD_AFTER_DESCRIBE|ADD_IMPORT|ADD_AFTER_IMPORTS|REPLACE):/m.test(code);
181
- return { hypothesis, code, truncated: isCodeIncomplete(code) || isRepetitionLoop(raw), isPatch };
277
+ let code = stripThinkingBleed(fallback.trim());
278
+ // DeepSeek sometimes writes an unclosed <thinking> block and puts the entire patch
279
+ // inside it without a <code_patch> delimiter. stripThinkingBleed strips everything
280
+ // after the opening tag, leaving an empty string. Recover by scanning the raw
281
+ // response for the first patch-op header and using everything from there onward.
282
+ const PATCH_HEADER_RE = /\/\/ @@@ (?:REPLACE_TEST|DELETE_TEST|ADD_AFTER_DESCRIBE|ADD_IMPORT|ADD_AFTER_IMPORTS|REPLACE):/m;
283
+ if (!code.trim() && PATCH_HEADER_RE.test(raw)) {
284
+ const idx = raw.search(PATCH_HEADER_RE);
285
+ code = raw.slice(idx).trim();
286
+ }
287
+ const isPatch = PATCH_HEADER_RE.test(code);
288
+ // Patches are individually complete — only non-patch output can be syntactically truncated.
289
+ return { hypothesis, code, truncated: isPatch ? false : (isCodeIncomplete(code) || isRepetitionLoop(raw)), isPatch };
182
290
  }
183
291
  export class TestGenerator {
184
292
  provider;
@@ -191,11 +299,17 @@ export class TestGenerator {
191
299
  failedAttempts = [];
192
300
  previousCodes = []; // normalized codes from all attempts, for oscillation detection
193
301
  lastIsPatch = false;
302
+ patchMode = false; // file is large enough to require <code_patch> mode — retries must stay in it
303
+ reactish = false; // React/RN project — gates React-specific retry guidance
304
+ debugFile; // configured base path (or null)
305
+ activeDebugFile = null; // per-file path for the file currently being processed
194
306
  constructor(options) {
195
307
  this.provider = createProvider(options.config);
196
308
  this.env = options.env;
197
309
  this.rawOnToken = options.onToken;
198
310
  this.maxTokens = options.config.maxTokens ?? 16000;
311
+ // Resolve the debug base from config.debug (boolean | string) and LACUNA_DEBUG (env wins).
312
+ this.debugFile = resolveDebugBase(options.config.debug);
199
313
  }
200
314
  // Swap the token callback between files (e.g. to attach a StreamingFileViewer per file).
201
315
  // A fresh codeOnlyStream filter is created on every generate/fix/retry call anyway,
@@ -236,6 +350,9 @@ export class TestGenerator {
236
350
  this.lastHypothesis = '';
237
351
  this.failedAttempts = [];
238
352
  this.previousCodes = [];
353
+ // Mirrors buildGeneratePrompt's patch-mode decision so retries stay in the same mode.
354
+ this.patchMode = (context.existingTestCode?.split('\n').length ?? 0) > PATCH_MODE_LINE_THRESHOLD;
355
+ this.reactish = context.reactMajorVersion != null;
239
356
  this.history = [
240
357
  {
241
358
  role: 'user',
@@ -261,7 +378,11 @@ export class TestGenerator {
261
378
  }),
262
379
  },
263
380
  ];
381
+ const prompt = this.history[this.history.length - 1].content;
382
+ this.activeDebugFile = perFileDebugPath(this.debugFile, context.sourceFile);
383
+ await debugWrite(this.activeDebugFile, 'PROMPT (generate)', prompt, /* clear= */ true);
264
384
  const response = await this.provider.generate(this.history, buildSystemPrompt(this.env), this.buildOnToken(), estimateMaxTokens(context.sourceCode, this.maxTokens), GENERATE_TEMPERATURE);
385
+ await debugWrite(this.activeDebugFile, 'RESPONSE (generate)', response);
265
386
  const { hypothesis, code, truncated, isPatch } = parseStructuredResponse(response);
266
387
  this.lastHypothesis = hypothesis;
267
388
  this.lastIsPatch = isPatch;
@@ -275,8 +396,14 @@ export class TestGenerator {
275
396
  this.lastHypothesis = '';
276
397
  this.failedAttempts = [];
277
398
  this.previousCodes = [];
399
+ // Mirrors buildFixPrompt's patch-mode decision so retries stay in the same mode.
400
+ this.patchMode = (args.existingTestLineCount ?? 0) > PATCH_MODE_LINE_THRESHOLD;
401
+ this.reactish = args.reactMajorVersion != null;
278
402
  this.history = [{ role: 'user', content: buildFixPrompt(args) }];
403
+ this.activeDebugFile = perFileDebugPath(this.debugFile, args.testFile);
404
+ await debugWrite(this.activeDebugFile, 'PROMPT (fix)', this.history[0].content, /* clear= */ true);
279
405
  const response = await this.provider.generate(this.history, buildSystemPrompt(this.env), this.buildOnToken(), estimateMaxTokens(args.sourceCode, this.maxTokens), GENERATE_TEMPERATURE);
406
+ await debugWrite(this.activeDebugFile, 'RESPONSE (fix)', response);
280
407
  const { hypothesis, code, truncated, isPatch } = parseStructuredResponse(response);
281
408
  this.lastHypothesis = hypothesis;
282
409
  this.lastIsPatch = isPatch;
@@ -323,9 +450,11 @@ export class TestGenerator {
323
450
  : [original];
324
451
  this.history.push({
325
452
  role: 'user',
326
- content: buildRetryPrompt(failureOutput, this.failedAttempts),
453
+ content: buildRetryPrompt(failureOutput, this.failedAttempts, this.patchMode, this.reactish),
327
454
  });
455
+ await debugWrite(this.activeDebugFile, `PROMPT (retry ${this.failedAttempts.length})`, this.history[this.history.length - 1].content);
328
456
  const response = await this.provider.generate(this.history, buildSystemPrompt(this.env), this.buildOnToken(), this.maxTokens, RETRY_TEMPERATURE);
457
+ await debugWrite(this.activeDebugFile, `RESPONSE (retry ${this.failedAttempts.length})`, response);
329
458
  const { hypothesis, code, truncated, isPatch } = parseStructuredResponse(response);
330
459
  this.lastHypothesis = hypothesis;
331
460
  this.lastIsPatch = isPatch;
@@ -1 +1 @@
1
- {"version":3,"file":"generator.js","sourceRoot":"","sources":["../../src/agent/generator.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAC3D,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EA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AAE,aAAa,EAAiH,MAAM,gBAAgB,CAAA;AAQ7J,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,YAAY,CAAA;IACpB,GAAG,EAAE,mBAAmB,CAAA;IACxB,GAAG,EAAE,MAAM,CAAA;IACX,MAAM,EAAE,OAAO,CAAA;IACf,OAAO,EAAE,OAAO,CAAA;IAChB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAA;CAC3B;AAED,MAAM,WAAW,UAAU;IACzB,cAAc,EAAE,MAAM,CAAA;IACtB,YAAY,EAAE,MAAM,CAAA;IACpB,cAAc,EAAE,MAAM,CAAA;IACtB,aAAa,EAAE,MAAM,CAAA;IACrB,WAAW,EAAE,OAAO,CAAA;IACpB,MAAM,EAAE,MAAM,EAAE,CAAA;CACjB;AAWD,wBAAsB,UAAU,CAC9B,GAAG,EAAE,WAAW,EAChB,OAAO,EAAE,WAAW,EACpB,SAAS,EAAE,aAAa,EACxB,QAAQ,EAAE,OAAO,EACjB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,EACvC,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,EAC7B,gBAAgB,CAAC,EAAE,MAAM,GACxB,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAgXlE;AA0ED,wBAAsB,YAAY,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CA8L5E"}
@@ -11,7 +11,7 @@ import { TestGenerator, TruncatedOutputError, OscillationError, ModelStallError,
11
11
  import { ProjectMemory } from './project-memory.js';
12
12
  import { getActiveTips, createTipRotator, formatTip } from '../lib/tips.js';
13
13
  import { typeCheckFile } from '../lib/typecheck.js';
14
- import { hasTestFunctions, hasPlaceholderBodies, enrichNoTestsError, isZeroTestsOutput, parsePassCount, buildStructureBrokenMessage, buildRegressionMessage, sanitizeMocksContent, stripLeadingProse, mergeMocksContent, deduplicateViMocks, tryApplyPatch, tryApplyMocksPatch } from '../lib/validate.js';
14
+ import { hasTestFunctions, hasPlaceholderBodies, enrichNoTestsError, isZeroTestsOutput, parsePassCount, buildStructureBrokenMessage, buildRegressionMessage, sanitizeMocksContent, stripLeadingProse, mergeMocksContent, deduplicateViMocks, tryApplyPatchWithDiag, tryApplyMocksPatch } from '../lib/validate.js';
15
15
  import { extractTestFailure } from '../lib/extract-error.js';
16
16
  import { StreamingFileViewer } from '../lib/streaming-viewer.js';
17
17
  async function getCoverageRate(config, cwd) {
@@ -72,6 +72,17 @@ export async function processGap(gap, options, generator, parallel, onStatus, pr
72
72
  let firstPassCount = 0; // passing tests on attempt 1
73
73
  let stallRetries = 0;
74
74
  const MAX_STALL_RETRIES = 2;
75
+ let consecutivePatchFailures = 0;
76
+ // Best collecting attempt seen so far — used on failure to keep a net-improving partial
77
+ // result (which `lacuna fix` can finish) instead of discarding work. Only attempts that
78
+ // actually collected tests qualify, so a fence-broken / 0-test file is never kept.
79
+ let bestCode = null;
80
+ let bestPassCount = -1;
81
+ // Running base for patch-mode application. Starts as the original test file and is updated
82
+ // to the written content after each attempt, so a retry that patches a test ADDED by an
83
+ // earlier attempt anchors against the current file — not the frozen original (which would
84
+ // fail with "anchor not found").
85
+ let patchBase = context.existingTestCode;
75
86
  for (let attempt = 1; attempt <= config.maxIterations; attempt++) {
76
87
  if (!onStatus) {
77
88
  if (attempt > 1) {
@@ -158,27 +169,48 @@ export async function processGap(gap, options, generator, parallel, onStatus, pr
158
169
  return { success: true, testCode: generatedCode };
159
170
  }
160
171
  // Patch mode: model returned surgical edits — apply them to get the complete file
161
- if (generator.isPatch && context.existingTestCode) {
162
- const patched = tryApplyPatch(context.existingTestCode, generatedCode);
163
- if (patched !== null) {
164
- generatedCode = patched;
172
+ if (generator.isPatch && patchBase) {
173
+ const patchResult = tryApplyPatchWithDiag(patchBase, generatedCode);
174
+ if (patchResult.ok) {
175
+ generatedCode = patchResult.result;
176
+ consecutivePatchFailures = 0;
165
177
  }
166
178
  else {
167
- // Anchor(s) not found — do NOT write raw patch markers to disk
168
- lastError =
169
- 'PATCH APPLICATION FAILED: one or more anchor strings in your patch were not found in the test file.\n' +
170
- 'Anchors must be copied character-for-character (including quote style) from the CURRENT TEST FILE shown above.\n' +
171
- 'Checklist:\n' +
172
- ' • REPLACE_TEST / DELETE_TEST anchor = exact it/test name already in the file\n' +
173
- ' • ADD_AFTER_DESCRIBE anchor = exact describe() name already in the file\n' +
174
- ' • For a brand-new test, use ADD_AFTER_DESCRIBE with the enclosing describe name\n' +
175
- 'Re-read the test file, find the exact anchor names, and rewrite your patch.';
179
+ consecutivePatchFailures++;
180
+ if (consecutivePatchFailures >= 2) {
181
+ // Escape hatch: after 2 failed patches the model can't anchor correctly.
182
+ // Force a full-file rewrite on the next attempt so it bypasses patch matching entirely.
183
+ lastError =
184
+ `PATCH ANCHORS FAILED ${consecutivePatchFailures} TIMES SWITCH TO FULL REWRITE MODE.\n` +
185
+ `Your patch is not matching the file. On this attempt you MUST use <code_output> (NOT <code_patch>) and output the COMPLETE test file.\n` +
186
+ `Include every existing test verbatim and add the new ones you need.\n` +
187
+ `Do NOT use <code_patch> this time.`;
188
+ }
189
+ else {
190
+ // Give the model the exact anchor text that failed so it can correct it
191
+ const failedOp = patchResult.failedOp;
192
+ const anchorBlock = failedOp
193
+ ? `\nFailed operation: ${failedOp.type}\nAnchor that was NOT found in the file:\n"""\n${failedOp.anchor.slice(0, 600)}\n"""`
194
+ : '';
195
+ lastError =
196
+ `PATCH APPLICATION FAILED: an anchor string in your patch was not found in the test file.${anchorBlock}\n\n` +
197
+ `The anchor must be character-for-character identical to the text in the EXISTING TEST FILE shown in the original prompt.\n` +
198
+ `Checklist:\n` +
199
+ ` • REPLACE_TEST / DELETE_TEST anchor = exact it/test name string (without quotes)\n` +
200
+ ` • ADD_AFTER_DESCRIBE anchor = exact describe() name string\n` +
201
+ ` • REPLACE anchor = entire text block copied verbatim from the test file\n` +
202
+ `Re-read the test file in the original prompt, locate the exact text, and rewrite your patch.`;
203
+ }
176
204
  if (!onStatus)
177
205
  log(chalk.yellow(` Patch anchors not found — retrying...`));
178
206
  onStatus?.({ phase: 'retrying', file: shortPath, attempt, max: config.maxIterations });
179
207
  continue;
180
208
  }
181
209
  }
210
+ else if (!generator.isPatch) {
211
+ // Model switched to (or stayed in) full-file mode — reset patch failure counter
212
+ consecutivePatchFailures = 0;
213
+ }
182
214
  // Strip thinking/prose that leaked before the first real code line.
183
215
  // Happens under retry pressure when the model bleeds reasoning into <code_output>.
184
216
  const { code: cleanCode, stripped: bleedText } = stripLeadingProse(generatedCode);
@@ -258,6 +290,9 @@ export async function processGap(gap, options, generator, parallel, onStatus, pr
258
290
  onStatus?.({ phase: 'writing', file: shortPath });
259
291
  await mkdir(dirname(context.suggestedTestFile), { recursive: true });
260
292
  await writeFile(context.suggestedTestFile, testCode, 'utf-8');
293
+ // Next patch-mode retry anchors against what's actually on disk now (including tests this
294
+ // attempt added/changed), not the frozen original.
295
+ patchBase = testCode;
261
296
  if (!onStatus)
262
297
  log(chalk.dim(` Written. Running tests...`));
263
298
  onStatus?.({ phase: 'running', file: shortPath });
@@ -290,8 +325,9 @@ export async function processGap(gap, options, generator, parallel, onStatus, pr
290
325
  }
291
326
  // Last attempt — tests pass even though type errors remain.
292
327
  // Report as passed rather than discarding a working test file.
328
+ const relTest = context.suggestedTestFile.replace(cwd + '/', '');
293
329
  if (!onStatus)
294
- log(chalk.yellow(` ⚠ Type errors remain — tests pass. Run lacuna fix to clean up types.`));
330
+ log(chalk.yellow(` ⚠ Type errors remain — tests pass. Run \`lacuna fix --file ${relTest}\` to clean up types.`));
295
331
  }
296
332
  else {
297
333
  if (!onStatus)
@@ -302,8 +338,12 @@ export async function processGap(gap, options, generator, parallel, onStatus, pr
302
338
  }
303
339
  const rawRunOutput = runResult.stdout + '\n' + runResult.stderr;
304
340
  const rawExtracted = extractTestFailure(rawRunOutput);
305
- const extracted = enrichNoTestsError(rawExtracted);
341
+ const extracted = enrichNoTestsError(rawExtracted, rawRunOutput);
306
342
  const passCount = parsePassCount(rawRunOutput);
343
+ if (!isZeroTestsOutput(rawRunOutput) && passCount > bestPassCount) {
344
+ bestPassCount = passCount;
345
+ bestCode = testCode;
346
+ }
307
347
  if (attempt === 1) {
308
348
  firstError = extracted;
309
349
  firstPassCount = passCount;
@@ -330,14 +370,40 @@ export async function processGap(gap, options, generator, parallel, onStatus, pr
330
370
  log(chalk.dim(lastError.split('\n').slice(0, 20).join('\n')));
331
371
  }
332
372
  onStatus?.({ phase: 'failed', file: shortPath });
333
- if (originalTestContent !== null) {
334
- // Pre-existing file restore it so the workspace stays coherent
335
- await restoreTestFile(context.suggestedTestFile, originalTestContent);
373
+ const rel = context.suggestedTestFile.replace(cwd + '/', '');
374
+ const keepHint = () => {
375
+ if (!onStatus)
376
+ log(chalk.yellow(`\n Kept ${bestPassCount} passing test(s) at ${rel} — run ${chalk.cyan(`lacuna fix --file ${rel}`)} to repair the remaining failures`));
377
+ };
378
+ if (originalTestContent === null) {
379
+ // New file — keep the best collecting attempt so `lacuna fix` can repair it.
380
+ if (bestCode !== null) {
381
+ await writeFile(context.suggestedTestFile, bestCode, 'utf-8');
382
+ keepHint();
383
+ }
384
+ else if (!onStatus)
385
+ log(chalk.yellow(`\n Last attempt kept at ${rel} — run ${chalk.cyan(`lacuna fix --file ${rel}`)} to repair it`));
386
+ }
387
+ else if (parallel && bestCode !== null) {
388
+ // Existing file with a clean, collecting attempt. Keep it ONLY if it adds net-new passing
389
+ // tests vs the original — otherwise the generated tests broke the suite or added no value,
390
+ // so restore the original. parallel ⇒ testCmd is file-scoped, so parsePassCount reflects
391
+ // this file and the comparison is sound. Measure the baseline lazily (only here on failure).
392
+ await writeFile(context.suggestedTestFile, originalTestContent, 'utf-8');
393
+ const baseRun = await runCommand(testCmd, cwd);
394
+ const baselinePassCount = parsePassCount(baseRun.stdout + '\n' + baseRun.stderr);
395
+ if (bestPassCount > baselinePassCount) {
396
+ await writeFile(context.suggestedTestFile, bestCode, 'utf-8');
397
+ keepHint();
398
+ }
399
+ else if (!onStatus) {
400
+ log(chalk.dim(`\n Generated tests didn't improve on the existing file (${baselinePassCount} passing) — restored the original.`));
401
+ }
336
402
  }
337
403
  else {
338
- // New file keep the last attempt on disk so `lacuna fix` can repair it
339
- if (!onStatus)
340
- log(chalk.yellow(`\n Last attempt kept at ${context.suggestedTestFile.replace(cwd + '/', '')} — run ${chalk.cyan('lacuna fix')} to repair it`));
404
+ // Existing file under a full-suite run (per-file pass count not measurable) or no clean
405
+ // attempt — restore the original so the workspace stays coherent.
406
+ await restoreTestFile(context.suggestedTestFile, originalTestContent);
341
407
  }
342
408
  return {
343
409
  success: false,