@xdevops/issue-auto-finish 1.0.93 → 1.0.95

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 (39) hide show
  1. package/dist/{PtyRunner-XMWDMH3L.js → PtyRunner-6RSDKUMM.js} +2 -2
  2. package/dist/ai-runner/PlanFileResolver.d.ts +1 -0
  3. package/dist/ai-runner/PlanFileResolver.d.ts.map +1 -1
  4. package/dist/ai-runner/PtyRunner.d.ts.map +1 -1
  5. package/dist/{ai-runner-S2ATTGWX.js → ai-runner-45IRCBIR.js} +2 -2
  6. package/dist/{analyze-DAVYPBHK.js → analyze-7TY5DYBT.js} +2 -2
  7. package/dist/{braindump-A4R3A4QT.js → braindump-FLX6HEVB.js} +2 -2
  8. package/dist/{chunk-HD6V7KPE.js → chunk-36G3DPO3.js} +80 -40
  9. package/dist/chunk-36G3DPO3.js.map +1 -0
  10. package/dist/{chunk-BPVRMZU4.js → chunk-527T6WEJ.js} +9 -9
  11. package/dist/{chunk-OPWP73PW.js → chunk-P3YTEJU6.js} +66 -31
  12. package/dist/{chunk-OPWP73PW.js.map → chunk-P3YTEJU6.js.map} +1 -1
  13. package/dist/{chunk-2XACBKPB.js → chunk-RR65A7J4.js} +2 -2
  14. package/dist/{chunk-SNSEW7DS.js → chunk-ZDWRD4Y7.js} +1 -1
  15. package/dist/cli.js +5 -5
  16. package/dist/hooks/HookInjector.d.ts +6 -0
  17. package/dist/hooks/HookInjector.d.ts.map +1 -1
  18. package/dist/index.js +4 -4
  19. package/dist/{init-OD7CLRWK.js → init-O7XJLCP3.js} +2 -2
  20. package/dist/lib.js +2 -2
  21. package/dist/orchestrator/steps/PhaseHelpers.d.ts +1 -1
  22. package/dist/orchestrator/steps/PhaseHelpers.d.ts.map +1 -1
  23. package/dist/orchestrator/steps/SetupStep.d.ts +7 -0
  24. package/dist/orchestrator/steps/SetupStep.d.ts.map +1 -1
  25. package/dist/{restart-JVVOYC6C.js → restart-JYSJQVH6.js} +2 -2
  26. package/dist/run.js +4 -4
  27. package/dist/{start-INU24RRG.js → start-UDBD3UPK.js} +2 -2
  28. package/package.json +1 -1
  29. package/dist/chunk-HD6V7KPE.js.map +0 -1
  30. /package/dist/{PtyRunner-XMWDMH3L.js.map → PtyRunner-6RSDKUMM.js.map} +0 -0
  31. /package/dist/{ai-runner-S2ATTGWX.js.map → ai-runner-45IRCBIR.js.map} +0 -0
  32. /package/dist/{analyze-DAVYPBHK.js.map → analyze-7TY5DYBT.js.map} +0 -0
  33. /package/dist/{braindump-A4R3A4QT.js.map → braindump-FLX6HEVB.js.map} +0 -0
  34. /package/dist/{chunk-BPVRMZU4.js.map → chunk-527T6WEJ.js.map} +0 -0
  35. /package/dist/{chunk-2XACBKPB.js.map → chunk-RR65A7J4.js.map} +0 -0
  36. /package/dist/{chunk-SNSEW7DS.js.map → chunk-ZDWRD4Y7.js.map} +0 -0
  37. /package/dist/{init-OD7CLRWK.js.map → init-O7XJLCP3.js.map} +0 -0
  38. /package/dist/{restart-JVVOYC6C.js.map → restart-JYSJQVH6.js.map} +0 -0
  39. /package/dist/{start-INU24RRG.js.map → start-UDBD3UPK.js.map} +0 -0
@@ -20,7 +20,7 @@ import {
20
20
  } from "./chunk-GPZX4DSY.js";
21
21
  import {
22
22
  HookInjector
23
- } from "./chunk-HD6V7KPE.js";
23
+ } from "./chunk-36G3DPO3.js";
24
24
  import {
25
25
  getProjectKnowledge
26
26
  } from "./chunk-ACVOOHAR.js";
@@ -236,8 +236,8 @@ var GongfengClient = class {
236
236
  const encoded = encodeURIComponent(this.projectPath);
237
237
  return `${this.apiUrl}/api/v3/projects/${encoded}`;
238
238
  }
239
- async requestRaw(path12, options = {}) {
240
- const url = `${this.projectApiBase}${path12}`;
239
+ async requestRaw(path13, options = {}) {
240
+ const url = `${this.projectApiBase}${path13}`;
241
241
  logger4.debug("API request", { method: options.method || "GET", url });
242
242
  return this.circuitBreaker.execute(
243
243
  () => this.retryPolicy.execute(async () => {
@@ -254,11 +254,11 @@ var GongfengClient = class {
254
254
  throw new GongfengApiError(resp.status, `Gongfeng API error ${resp.status}: ${body}`, body);
255
255
  }
256
256
  return resp;
257
- }, `requestRaw ${options.method || "GET"} ${path12}`)
257
+ }, `requestRaw ${options.method || "GET"} ${path13}`)
258
258
  );
259
259
  }
260
- async request(path12, options = {}) {
261
- const resp = await this.requestRaw(path12, options);
260
+ async request(path13, options = {}) {
261
+ const resp = await this.requestRaw(path13, options);
262
262
  return resp.json();
263
263
  }
264
264
  async createIssue(title, description, labels) {
@@ -437,8 +437,8 @@ var GongfengClient = class {
437
437
  }
438
438
  return mr;
439
439
  }
440
- async requestGlobal(path12, options = {}) {
441
- const url = `${this.apiUrl}${path12}`;
440
+ async requestGlobal(path13, options = {}) {
441
+ const url = `${this.apiUrl}${path13}`;
442
442
  logger4.debug("API request (global)", { method: options.method || "GET", url });
443
443
  const resp = await this.circuitBreaker.execute(
444
444
  () => this.retryPolicy.execute(async () => {
@@ -455,7 +455,7 @@ var GongfengClient = class {
455
455
  throw new GongfengApiError(r.status, `Gongfeng API error ${r.status}: ${body}`, body);
456
456
  }
457
457
  return r;
458
- }, `requestGlobal ${options.method || "GET"} ${path12}`)
458
+ }, `requestGlobal ${options.method || "GET"} ${path13}`)
459
459
  );
460
460
  return resp.json();
461
461
  }
@@ -3134,8 +3134,8 @@ var WorkspaceManager = class {
3134
3134
  };
3135
3135
 
3136
3136
  // src/orchestrator/PipelineOrchestrator.ts
3137
- import path11 from "path";
3138
- import fs9 from "fs/promises";
3137
+ import path12 from "path";
3138
+ import fs10 from "fs/promises";
3139
3139
  import fsSync from "fs";
3140
3140
  import { execFile as execFile2 } from "child_process";
3141
3141
  import { promisify as promisify2 } from "util";
@@ -3774,7 +3774,38 @@ metrics.registerCounter("iaf_braindump_batches_total", "Total braindump batches"
3774
3774
  metrics.registerCounter("iaf_braindump_tasks_total", "Total braindump tasks");
3775
3775
 
3776
3776
  // src/orchestrator/steps/SetupStep.ts
3777
+ import fs9 from "fs";
3778
+ import path11 from "path";
3777
3779
  var logger14 = logger.child("SetupStep");
3780
+ var PLAN_DIR_NAME = ".claude-plan";
3781
+ function cleanupStalePlanDirs(workDir, currentIid) {
3782
+ const claudePlanDir = path11.join(workDir, PLAN_DIR_NAME);
3783
+ if (!fs9.existsSync(claudePlanDir)) return;
3784
+ const currentDirName = `issue-${currentIid}`;
3785
+ let entries;
3786
+ try {
3787
+ entries = fs9.readdirSync(claudePlanDir);
3788
+ } catch {
3789
+ return;
3790
+ }
3791
+ for (const entry of entries) {
3792
+ if (entry.startsWith("issue-") && entry !== currentDirName) {
3793
+ const stalePath = path11.join(claudePlanDir, entry);
3794
+ try {
3795
+ fs9.rmSync(stalePath, { recursive: true, force: true });
3796
+ logger14.info("Removed stale plan directory from worktree", {
3797
+ removed: entry,
3798
+ currentIid
3799
+ });
3800
+ } catch (err) {
3801
+ logger14.warn("Failed to remove stale plan directory", {
3802
+ path: stalePath,
3803
+ error: err.message
3804
+ });
3805
+ }
3806
+ }
3807
+ }
3808
+ }
3778
3809
  async function executeSetup(ctx, deps) {
3779
3810
  const { issue, wtCtx, record, pipelineDef, branchName } = ctx;
3780
3811
  try {
@@ -3808,6 +3839,7 @@ async function executeSetup(ctx, deps) {
3808
3839
  const primaryGitRoot = wtCtx.workspace ? wtCtx.workspace.primary.gitRootDir : wtCtx.gitRootDir;
3809
3840
  const wtGit = new GitOperations(primaryGitRoot);
3810
3841
  const wtPlan = new PlanPersistence(primaryWorkDir, issue.iid);
3842
+ cleanupStalePlanDirs(primaryWorkDir, issue.iid);
3811
3843
  wtPlan.ensureDir();
3812
3844
  wtPlan.writeIssueMeta({
3813
3845
  id: issue.id,
@@ -3970,7 +4002,10 @@ function resolveUatRunner(deps, issueIid) {
3970
4002
  }
3971
4003
  return deps.aiRunner;
3972
4004
  }
3973
- async function commitPlanFiles(ctx, wtGit, wtGitMap, phaseName, displayId) {
4005
+ async function commitPlanFiles(ctx, wtGit, wtGitMap, phaseName, displayId, planWorkDir) {
4006
+ if (planWorkDir) {
4007
+ cleanupStalePlanDirs(planWorkDir, displayId);
4008
+ }
3974
4009
  const commitMsg = `chore(auto): ${phaseName} phase completed for issue #${displayId}`;
3975
4010
  if (ctx.workspace && ctx.workspace.repos.length > 1) {
3976
4011
  for (const repo of ctx.workspace.repos) {
@@ -4202,7 +4237,7 @@ var DefaultLifecycleHook = class {
4202
4237
  completedAt: (/* @__PURE__ */ new Date()).toISOString()
4203
4238
  });
4204
4239
  wtPlan.updatePhaseProgress(spec.name, "completed");
4205
- await commitPlanFiles(phaseCtx, wtGit, wtGitMap, spec.name, displayId);
4240
+ await commitPlanFiles(phaseCtx, wtGit, wtGitMap, spec.name, displayId, wtPlan.baseDir);
4206
4241
  if (phase) {
4207
4242
  await syncResultToIssue(phase, phaseCtx, displayId, spec.name, deps, issue.id, wtPlan);
4208
4243
  }
@@ -4350,7 +4385,7 @@ var AiPhaseStrategy = class {
4350
4385
  completedAt: (/* @__PURE__ */ new Date()).toISOString()
4351
4386
  });
4352
4387
  wtPlan.updatePhaseProgress(spec.name, "completed");
4353
- await commitPlanFiles(phaseCtx, wtGit, wtGitMap, spec.name, issue.iid);
4388
+ await commitPlanFiles(phaseCtx, wtGit, wtGitMap, spec.name, issue.iid, wtPlan.baseDir);
4354
4389
  const runner = this.resolveRunner(ctx);
4355
4390
  const phase = createPhase(spec.name, runner, wtGit, wtPlan, deps.config);
4356
4391
  await syncResultToIssue(phase, phaseCtx, issue.iid, spec.name, deps, issue.id, wtPlan);
@@ -4918,7 +4953,7 @@ var PipelineOrchestrator = class {
4918
4953
  });
4919
4954
  this.devServerManager = new DevServerManager();
4920
4955
  this.screenshotPublisher = new ScreenshotPublisher(gongfeng);
4921
- this.effectiveWorktreeBaseDir = this.tenantId === "default" ? config.project.worktreeBaseDir : path11.join(config.project.worktreeBaseDir, this.tenantId);
4956
+ this.effectiveWorktreeBaseDir = this.tenantId === "default" ? config.project.worktreeBaseDir : path12.join(config.project.worktreeBaseDir, this.tenantId);
4922
4957
  const effectiveWsConfig = wsConfig ?? buildSingleRepoWorkspace(config.project, config.gongfeng.projectPath);
4923
4958
  this.workspaceManager = new WorkspaceManager({
4924
4959
  wsConfig: effectiveWsConfig,
@@ -4957,9 +4992,9 @@ var PipelineOrchestrator = class {
4957
4992
  if (wtDir === repoGitRoot) continue;
4958
4993
  if (!wtDir.includes("/issue-")) continue;
4959
4994
  try {
4960
- const gitFile = path11.join(wtDir, ".git");
4995
+ const gitFile = path12.join(wtDir, ".git");
4961
4996
  try {
4962
- await fs9.access(gitFile);
4997
+ await fs10.access(gitFile);
4963
4998
  } catch {
4964
4999
  logger23.warn("Worktree corrupted (.git missing), force removing", { dir: wtDir });
4965
5000
  await this.mainGit.worktreeRemove(wtDir, true).catch(() => {
@@ -4974,9 +5009,9 @@ var PipelineOrchestrator = class {
4974
5009
  await wtGit.rebaseAbort();
4975
5010
  cleaned++;
4976
5011
  }
4977
- const indexLock = path11.join(wtDir, ".git", "index.lock");
5012
+ const indexLock = path12.join(wtDir, ".git", "index.lock");
4978
5013
  try {
4979
- await fs9.unlink(indexLock);
5014
+ await fs10.unlink(indexLock);
4980
5015
  logger23.warn("Removed stale index.lock", { path: indexLock });
4981
5016
  cleaned++;
4982
5017
  } catch {
@@ -4988,9 +5023,9 @@ var PipelineOrchestrator = class {
4988
5023
  } catch (err) {
4989
5024
  logger23.warn("Failed to list worktrees for cleanup", { error: err.message });
4990
5025
  }
4991
- const mainIndexLock = path11.join(repoGitRoot, ".git", "index.lock");
5026
+ const mainIndexLock = path12.join(repoGitRoot, ".git", "index.lock");
4992
5027
  try {
4993
- await fs9.unlink(mainIndexLock);
5028
+ await fs10.unlink(mainIndexLock);
4994
5029
  logger23.warn("Removed stale main repo index.lock", { path: mainIndexLock });
4995
5030
  cleaned++;
4996
5031
  } catch {
@@ -5106,17 +5141,17 @@ var PipelineOrchestrator = class {
5106
5141
  }
5107
5142
  }
5108
5143
  async ensureNodeModules(workDir) {
5109
- const targetBin = path11.join(workDir, "node_modules", ".bin");
5144
+ const targetBin = path12.join(workDir, "node_modules", ".bin");
5110
5145
  try {
5111
- await fs9.access(targetBin);
5146
+ await fs10.access(targetBin);
5112
5147
  logger23.info("node_modules already complete (has .bin/)");
5113
5148
  return true;
5114
5149
  } catch {
5115
5150
  }
5116
- const sourceNM = path11.join(this.config.project.workDir, "node_modules");
5117
- const targetNM = path11.join(workDir, "node_modules");
5151
+ const sourceNM = path12.join(this.config.project.workDir, "node_modules");
5152
+ const targetNM = path12.join(workDir, "node_modules");
5118
5153
  try {
5119
- await fs9.access(sourceNM);
5154
+ await fs10.access(sourceNM);
5120
5155
  } catch {
5121
5156
  logger23.warn("Main repo node_modules not found, skipping seed", { sourceNM });
5122
5157
  return false;
@@ -5203,10 +5238,10 @@ var PipelineOrchestrator = class {
5203
5238
  async cleanupE2eOutputs(issueIid) {
5204
5239
  const vendorDir = this.config.e2e.uatVendorDir;
5205
5240
  if (!vendorDir) return;
5206
- const abs = path11.isAbsolute(vendorDir) ? vendorDir : path11.resolve(this.config.project.workDir, vendorDir);
5207
- const outputDir = path11.join(abs, "outputs", `issue-${issueIid}`);
5241
+ const abs = path12.isAbsolute(vendorDir) ? vendorDir : path12.resolve(this.config.project.workDir, vendorDir);
5242
+ const outputDir = path12.join(abs, "outputs", `issue-${issueIid}`);
5208
5243
  try {
5209
- await fs9.rm(outputDir, { recursive: true, force: true });
5244
+ await fs10.rm(outputDir, { recursive: true, force: true });
5210
5245
  logger23.info("E2E outputs cleaned up", { issueIid, dir: outputDir });
5211
5246
  } catch (err) {
5212
5247
  logger23.warn("Failed to cleanup E2E outputs", { issueIid, dir: outputDir, error: err.message });
@@ -5221,7 +5256,7 @@ var PipelineOrchestrator = class {
5221
5256
  if (!this.workspaceManager) return;
5222
5257
  const wsRoot = this.workspaceManager.getWorkspaceRoot(issueIid);
5223
5258
  try {
5224
- await fs9.rm(wsRoot, { recursive: true, force: true });
5259
+ await fs10.rm(wsRoot, { recursive: true, force: true });
5225
5260
  logger23.info("Workspace root cleaned up", { issueIid, dir: wsRoot });
5226
5261
  } catch (err) {
5227
5262
  logger23.warn("Failed to cleanup workspace root", { issueIid, dir: wsRoot, error: err.message });
@@ -6073,4 +6108,4 @@ export {
6073
6108
  PipelineOrchestrator,
6074
6109
  BrainstormService
6075
6110
  };
6076
- //# sourceMappingURL=chunk-OPWP73PW.js.map
6111
+ //# sourceMappingURL=chunk-P3YTEJU6.js.map