@yasserkhanorg/impact-gate 2.1.3 → 2.1.4

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.
@@ -94,6 +94,7 @@ export async function runFixLoop(config, findings, browser, projectRoot) {
94
94
  screenshotDir,
95
95
  screenshotCounter: 100, // Start at 100 to avoid collisions with Phase 2 screenshots
96
96
  qaCommitHashes: new Set(),
97
+ pendingWrittenFiles: new Set(),
97
98
  };
98
99
  for (const finding of fixable) {
99
100
  if (wtf.shouldStop()) {
@@ -161,6 +161,7 @@ export function executeFixTool(ctx, name, input) {
161
161
  }
162
162
  const fullPath = resolve(ctx.projectRoot, filePath);
163
163
  writeFileSync(fullPath, String(input.content), 'utf-8');
164
+ ctx.pendingWrittenFiles.add(filePath);
164
165
  return { output: `Written: ${filePath}`, filesChanged: [filePath] };
165
166
  }
166
167
  case 'search_code': {
@@ -227,6 +228,7 @@ export function executeFixTool(ctx, name, input) {
227
228
  execFileSync('git', ['commit', '-m', message], { cwd: ctx.projectRoot, encoding: 'utf-8' });
228
229
  const hash = execFileSync('git', ['rev-parse', '--short', 'HEAD'], { cwd: ctx.projectRoot, encoding: 'utf-8' }).trim();
229
230
  ctx.qaCommitHashes.add(hash);
231
+ ctx.pendingWrittenFiles.clear();
230
232
  return { output: `Committed: ${hash} — ${message}`, commitHash: hash, filesChanged: files };
231
233
  }
232
234
  catch (err) {
@@ -252,9 +254,14 @@ export function executeFixTool(ctx, name, input) {
252
254
  }
253
255
  }
254
256
  case 'git_restore': {
257
+ const filesToRestore = [...ctx.pendingWrittenFiles];
258
+ if (filesToRestore.length === 0) {
259
+ return { output: 'No pending edits to restore.' };
260
+ }
255
261
  try {
256
- execFileSync('git', ['checkout', '--', '.'], { cwd: ctx.projectRoot, encoding: 'utf-8' });
257
- return { output: 'Restored working tree to last commit state. All uncommitted edits discarded.' };
262
+ execFileSync('git', ['checkout', '--', ...filesToRestore], { cwd: ctx.projectRoot, encoding: 'utf-8' });
263
+ ctx.pendingWrittenFiles.clear();
264
+ return { output: `Restored ${filesToRestore.length} file(s): ${filesToRestore.join(', ')}` };
258
265
  }
259
266
  catch (err) {
260
267
  const error = err;
@@ -1 +1 @@
1
- {"version":3,"file":"fix_loop.d.ts","sourceRoot":"","sources":["../../../src/qa-agent/phase25/fix_loop.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAC,OAAO,EAAqC,aAAa,EAAE,QAAQ,EAAC,MAAM,aAAa,CAAC;AACrG,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,4BAA4B,CAAC;AAyD7D,wBAAsB,UAAU,CAC5B,MAAM,EAAE,QAAQ,EAChB,QAAQ,EAAE,OAAO,EAAE,EACnB,OAAO,EAAE,YAAY,EACrB,WAAW,EAAE,MAAM,GACpB,OAAO,CAAC,aAAa,CAAC,CA4FxB"}
1
+ {"version":3,"file":"fix_loop.d.ts","sourceRoot":"","sources":["../../../src/qa-agent/phase25/fix_loop.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAC,OAAO,EAAqC,aAAa,EAAE,QAAQ,EAAC,MAAM,aAAa,CAAC;AACrG,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,4BAA4B,CAAC;AAyD7D,wBAAsB,UAAU,CAC5B,MAAM,EAAE,QAAQ,EAChB,QAAQ,EAAE,OAAO,EAAE,EACnB,OAAO,EAAE,YAAY,EACrB,WAAW,EAAE,MAAM,GACpB,OAAO,CAAC,aAAa,CAAC,CA6FxB"}
@@ -100,6 +100,7 @@ async function runFixLoop(config, findings, browser, projectRoot) {
100
100
  screenshotDir,
101
101
  screenshotCounter: 100, // Start at 100 to avoid collisions with Phase 2 screenshots
102
102
  qaCommitHashes: new Set(),
103
+ pendingWrittenFiles: new Set(),
103
104
  };
104
105
  for (const finding of fixable) {
105
106
  if (wtf.shouldStop()) {
@@ -9,6 +9,8 @@ export interface FixToolContext {
9
9
  screenshotCounter: number;
10
10
  /** Commit hashes created by the fix loop. Only these can be reverted. */
11
11
  qaCommitHashes: Set<string>;
12
+ /** Files written by the current fix attempt. Only these are restored on failure. */
13
+ pendingWrittenFiles: Set<string>;
12
14
  }
13
15
  export interface FixToolResult {
14
16
  output: string;
@@ -1 +1 @@
1
- {"version":3,"file":"fix_tools.d.ts","sourceRoot":"","sources":["../../../src/qa-agent/phase25/fix_tools.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,SAAS,MAAM,mBAAmB,CAAC;AAE/C,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,4BAA4B,CAAC;AAM7D,eAAO,MAAM,oBAAoB,EAAE,SAAS,CAAC,IAAI,EAgGhD,CAAC;AAMF,MAAM,WAAW,cAAc;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,YAAY,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,yEAAyE;IACzE,cAAc,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CAC/B;AAED,MAAM,WAAW,aAAa;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,0DAA0D;IAC1D,aAAa,CAAC,EAAE,OAAO,CAAC;CAC3B;AA2CD,wBAAgB,cAAc,CAC1B,GAAG,EAAE,cAAc,EACnB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,aAAa,CA8Jf"}
1
+ {"version":3,"file":"fix_tools.d.ts","sourceRoot":"","sources":["../../../src/qa-agent/phase25/fix_tools.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,SAAS,MAAM,mBAAmB,CAAC;AAE/C,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,4BAA4B,CAAC;AAM7D,eAAO,MAAM,oBAAoB,EAAE,SAAS,CAAC,IAAI,EAgGhD,CAAC;AAMF,MAAM,WAAW,cAAc;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,YAAY,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,yEAAyE;IACzE,cAAc,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC5B,oFAAoF;IACpF,mBAAmB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CACpC;AAED,MAAM,WAAW,aAAa;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,0DAA0D;IAC1D,aAAa,CAAC,EAAE,OAAO,CAAC;CAC3B;AA2CD,wBAAgB,cAAc,CAC1B,GAAG,EAAE,cAAc,EACnB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,aAAa,CAqKf"}
@@ -165,6 +165,7 @@ function executeFixTool(ctx, name, input) {
165
165
  }
166
166
  const fullPath = (0, path_1.resolve)(ctx.projectRoot, filePath);
167
167
  (0, fs_1.writeFileSync)(fullPath, String(input.content), 'utf-8');
168
+ ctx.pendingWrittenFiles.add(filePath);
168
169
  return { output: `Written: ${filePath}`, filesChanged: [filePath] };
169
170
  }
170
171
  case 'search_code': {
@@ -231,6 +232,7 @@ function executeFixTool(ctx, name, input) {
231
232
  (0, child_process_1.execFileSync)('git', ['commit', '-m', message], { cwd: ctx.projectRoot, encoding: 'utf-8' });
232
233
  const hash = (0, child_process_1.execFileSync)('git', ['rev-parse', '--short', 'HEAD'], { cwd: ctx.projectRoot, encoding: 'utf-8' }).trim();
233
234
  ctx.qaCommitHashes.add(hash);
235
+ ctx.pendingWrittenFiles.clear();
234
236
  return { output: `Committed: ${hash} — ${message}`, commitHash: hash, filesChanged: files };
235
237
  }
236
238
  catch (err) {
@@ -256,9 +258,14 @@ function executeFixTool(ctx, name, input) {
256
258
  }
257
259
  }
258
260
  case 'git_restore': {
261
+ const filesToRestore = [...ctx.pendingWrittenFiles];
262
+ if (filesToRestore.length === 0) {
263
+ return { output: 'No pending edits to restore.' };
264
+ }
259
265
  try {
260
- (0, child_process_1.execFileSync)('git', ['checkout', '--', '.'], { cwd: ctx.projectRoot, encoding: 'utf-8' });
261
- return { output: 'Restored working tree to last commit state. All uncommitted edits discarded.' };
266
+ (0, child_process_1.execFileSync)('git', ['checkout', '--', ...filesToRestore], { cwd: ctx.projectRoot, encoding: 'utf-8' });
267
+ ctx.pendingWrittenFiles.clear();
268
+ return { output: `Restored ${filesToRestore.length} file(s): ${filesToRestore.join(', ')}` };
262
269
  }
263
270
  catch (err) {
264
271
  const error = err;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yasserkhanorg/impact-gate",
3
- "version": "2.1.3",
3
+ "version": "2.1.4",
4
4
  "description": "Diff-aware E2E impact analysis and coverage gating for Playwright/Cypress teams. Optional AI features can suggest, generate, and heal tests once your project has a route-families.json manifest.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/esm/index.js",