@shipispec/tsfix 0.5.0 → 0.6.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.d.ts CHANGED
@@ -82,6 +82,12 @@ export interface ValidationLoopOptions {
82
82
  dryRun?: boolean;
83
83
  /** Default: a no-op logger. Pass your own to capture layer events. */
84
84
  logger?: Logger;
85
+ /**
86
+ * Per-error telemetry callback for Layer 1 (LSP fixer). Fires once per
87
+ * fixable error with `{layer: 1, errorCode, fixed, latencyMs, ts}`. Optional;
88
+ * undefined callback costs nothing. See `LayerEvent`.
89
+ */
90
+ onLayerEvent?: (event: LayerEvent) => void;
85
91
  }
86
92
  export interface ValidationLoopResult {
87
93
  passed: boolean;
@@ -156,6 +162,20 @@ export interface MendContext {
156
162
  priorTaskExports?: string;
157
163
  /** Compact type signatures of installed npm dependencies (helps prevent API hallucination). */
158
164
  installedTypes?: string;
165
+ /**
166
+ * Library-migration hints for installed deps whose breaking changes are
167
+ * known to mislead tsc's quick-fix. When non-empty, the Layer 2 prompt
168
+ * leads with these and the `taskDescription` is overridden to name them.
169
+ *
170
+ * Auto-populated by `runMendLoop` from `<workspaceRoot>/package.json` if
171
+ * the caller doesn't set it. Pass `[]` explicitly to opt out.
172
+ *
173
+ * See `libraryMigrations.ts` for the built-in registry.
174
+ */
175
+ libraryMigrations?: Array<{
176
+ name: string;
177
+ hint: string;
178
+ }>;
159
179
  }
160
180
  /**
161
181
  * Per-layer event for streaming telemetry across the validate → fix → mend
@@ -189,8 +209,88 @@ export type { TypeContextOptions, TypeContext } from "./typeContext.js";
189
209
  export { parseEditBlocks, applySingleBlock, applyEditBlocks } from "./applyEditBlock.js";
190
210
  export type { EditBlock, ApplyEditBlocksOptions, ApplyResult, SingleBlockResult, } from "./applyEditBlock.js";
191
211
  export { mendSingleFile } from "./mendAgent.js";
192
- export type { MendSingleFileOptions, MendSingleFileResult, LLMCall } from "./mendAgent.js";
212
+ export type { MendSingleFileOptions, MendSingleFileResult, LLMCall, LLMProvider, } from "./mendAgent.js";
193
213
  export { runMendLoop } from "./runMendLoop.js";
194
214
  export type { RunMendLoopOptions, RunMendLoopResult, MendLoopIteration, StopReason, } from "./runMendLoop.js";
195
215
  export { stubAndContinue } from "./stubAndContinue.js";
196
216
  export type { StubAndContinueOptions, StubAndContinueResult, AppliedStub, SkippedStub, } from "./stubAndContinue.js";
217
+ export { BUILT_IN_LIBRARY_MIGRATIONS, detectLibraryMigrations, formatLibraryMigrationsBlock, formatLibraryMigrationsTaskDescription, } from "./libraryMigrations.js";
218
+ export type { LibraryMigrationHint } from "./libraryMigrations.js";
219
+ import { type RunMendLoopResult } from "./runMendLoop.js";
220
+ import type { AppliedStub } from "./stubAndContinue.js";
221
+ import type { LLMProvider } from "./mendAgent.js";
222
+ export interface RunFullStackOptions {
223
+ /** Absolute path to the workspace (must contain `tsconfig.json`). */
224
+ workspaceRoot: string;
225
+ /** Files to scope to. If omitted, all `.ts`/`.tsx` files under workspaceRoot. */
226
+ targetFiles?: string[];
227
+ /** Skip Layer 0/1 LSP auto-fixer. Default false. */
228
+ skipLSPFixer?: boolean;
229
+ /**
230
+ * Layer 2 config. If omitted, the loop stops after Layer 0/1 (matches
231
+ * `runValidationLoop` behavior — no LLM calls).
232
+ */
233
+ llm?: {
234
+ provider: LLMProvider;
235
+ model: string;
236
+ apiKey: string;
237
+ maxIterations?: number;
238
+ };
239
+ /**
240
+ * After Layer 2 (if any), insert `// @ts-expect-error - tsfix: …` above
241
+ * each unresolved error site so tsc exits 0. Opt-in. Default false.
242
+ */
243
+ stubOnFailure?: boolean;
244
+ /**
245
+ * Run all layers in memory; report counts but don't write. Default false.
246
+ * Layer 2 is auto-skipped under dryRun (it writes patches; would be a
247
+ * no-op).
248
+ */
249
+ dryRun?: boolean;
250
+ /** Logger. Default no-op. */
251
+ logger?: Logger;
252
+ /** Per-layer telemetry stream. Forwarded to Layer 1, 2, 4. */
253
+ onLayerEvent?: (event: LayerEvent) => void;
254
+ /** @internal — LLM call override. Tests inject a fake; real callers leave it. */
255
+ _callLLM?: import("./mendAgent.js").LLMCall;
256
+ }
257
+ export interface RunFullStackResult {
258
+ /** True if `errorsAfterAllLayers === 0`. */
259
+ passed: boolean;
260
+ /** Errors detected before any fix attempt. */
261
+ errorsBefore: number;
262
+ /** Errors remaining after Layer 0/1 (before Layer 2 + 4). */
263
+ errorsAfterLayer1: number;
264
+ /** Errors remaining after every layer that ran. */
265
+ errorsAfterAllLayers: number;
266
+ /** Per-layer sub-results. `layer2` is null when `llm` was omitted; `layer4` is null when `stubOnFailure` was false (or had no candidates). */
267
+ layer1: ValidationLoopResult["lspFixer"];
268
+ layer2: RunMendLoopResult | null;
269
+ layer4: {
270
+ stubsApplied: AppliedStub[];
271
+ } | null;
272
+ /** USD spent on Layer 2. 0 when Layer 2 didn't run. */
273
+ totalCostUsd: number;
274
+ /** Wall-clock total across all layers. */
275
+ totalLatencyMs: number;
276
+ /** Remaining diagnostics, grouped by TS code (e.g. `{TS2339: 3}`). */
277
+ remainingByCode: Record<string, number>;
278
+ /** Remaining diagnostics, grouped by file path (relative to workspaceRoot). */
279
+ remainingByFile: Record<string, number>;
280
+ }
281
+ /**
282
+ * Run the full tsfix stack (Layer 0/1 → Layer 2 → Layer 4) end-to-end.
283
+ *
284
+ * @example
285
+ * ```ts
286
+ * const result = await runFullStack({
287
+ * workspaceRoot: "/path/to/project",
288
+ * llm: { provider: "anthropic", model: "claude-haiku-4-5", apiKey: KEY },
289
+ * stubOnFailure: true,
290
+ * onLayerEvent: (e) => console.log(e),
291
+ * });
292
+ * if (!result.passed) { ... }
293
+ * console.log(`Spent $${result.totalCostUsd.toFixed(4)}`);
294
+ * ```
295
+ */
296
+ export declare function runFullStack(opts: RunFullStackOptions): Promise<RunFullStackResult>;