claude-issue-solver 1.6.2 → 1.6.3

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.
@@ -45,9 +45,7 @@ const fs = __importStar(require("fs"));
45
45
  const path = __importStar(require("path"));
46
46
  const os = __importStar(require("os"));
47
47
  const child_process_1 = require("child_process");
48
- const github_1 = require("../utils/github");
49
48
  const git_1 = require("../utils/git");
50
- const helpers_1 = require("../utils/helpers");
51
49
  function closeWindowsWithPath(folderPath) {
52
50
  if (os.platform() !== 'darwin')
53
51
  return;
@@ -170,13 +168,25 @@ async function cleanAllCommand() {
170
168
  const spinner = (0, ora_1.default)(`Cleaning issue #${wt.issueNumber}...`).start();
171
169
  try {
172
170
  // Close terminal and VS Code windows for this worktree
173
- closeWindowsWithPath(wt.path);
171
+ try {
172
+ closeWindowsWithPath(wt.path);
173
+ }
174
+ catch {
175
+ // Ignore errors closing windows
176
+ }
174
177
  // Remove worktree
175
178
  if (fs.existsSync(wt.path)) {
176
- (0, child_process_1.execSync)(`git worktree remove "${wt.path}" --force`, {
177
- cwd: projectRoot,
178
- stdio: 'pipe',
179
- });
179
+ try {
180
+ (0, child_process_1.execSync)(`git worktree remove "${wt.path}" --force`, {
181
+ cwd: projectRoot,
182
+ stdio: 'pipe',
183
+ });
184
+ }
185
+ catch {
186
+ // If git worktree remove fails, try removing directory manually
187
+ fs.rmSync(wt.path, { recursive: true, force: true });
188
+ (0, child_process_1.execSync)('git worktree prune', { cwd: projectRoot, stdio: 'pipe' });
189
+ }
180
190
  }
181
191
  // Delete branch
182
192
  try {
@@ -191,7 +201,7 @@ async function cleanAllCommand() {
191
201
  spinner.succeed(`Cleaned issue #${wt.issueNumber}`);
192
202
  }
193
203
  catch (error) {
194
- spinner.fail(`Failed to clean issue #${wt.issueNumber}`);
204
+ spinner.fail(`Failed to clean issue #${wt.issueNumber}: ${error}`);
195
205
  }
196
206
  }
197
207
  // Prune stale worktrees
@@ -200,18 +210,46 @@ async function cleanAllCommand() {
200
210
  console.log(chalk_1.default.green(`✅ Cleaned up ${worktrees.length} issue worktree(s)!`));
201
211
  }
202
212
  async function cleanCommand(issueNumber) {
203
- const spinner = (0, ora_1.default)(`Fetching issue #${issueNumber}...`).start();
204
- const issue = (0, github_1.getIssue)(issueNumber);
205
- if (!issue) {
206
- spinner.fail(`Could not find issue #${issueNumber}`);
207
- process.exit(1);
208
- }
209
- spinner.succeed(`Found issue #${issueNumber}`);
210
213
  const projectRoot = (0, git_1.getProjectRoot)();
211
214
  const projectName = (0, git_1.getProjectName)();
212
- const branchSlug = (0, helpers_1.slugify)(issue.title);
213
- const branchName = `issue-${issueNumber}-${branchSlug}`;
214
- const worktreePath = path.join(path.dirname(projectRoot), `${projectName}-${branchName}`);
215
+ // Find the worktree for this issue number (don't need to fetch from GitHub)
216
+ const worktrees = getIssueWorktrees();
217
+ const worktree = worktrees.find((wt) => wt.issueNumber === String(issueNumber));
218
+ if (!worktree) {
219
+ // Try to find by looking for the branch pattern
220
+ const branchPattern = `issue-${issueNumber}-`;
221
+ const output = (0, git_1.exec)('git branch', projectRoot);
222
+ const branches = output.split('\n').map((b) => b.trim().replace('* ', ''));
223
+ const matchingBranch = branches.find((b) => b.startsWith(branchPattern));
224
+ if (!matchingBranch) {
225
+ console.log(chalk_1.default.red(`\n❌ No worktree or branch found for issue #${issueNumber}`));
226
+ return;
227
+ }
228
+ // Found a branch but no worktree - just delete the branch
229
+ console.log(chalk_1.default.bold(`\n🧹 Cleaning up issue #${issueNumber}`));
230
+ console.log(chalk_1.default.dim(` Branch: ${matchingBranch}`));
231
+ console.log(chalk_1.default.dim(` (No worktree found)`));
232
+ const { confirm } = await inquirer_1.default.prompt([
233
+ {
234
+ type: 'confirm',
235
+ name: 'confirm',
236
+ message: 'Delete branch?',
237
+ default: false,
238
+ },
239
+ ]);
240
+ if (confirm) {
241
+ try {
242
+ (0, child_process_1.execSync)(`git branch -D "${matchingBranch}"`, { cwd: projectRoot, stdio: 'pipe' });
243
+ console.log(chalk_1.default.green('\n✅ Branch deleted!'));
244
+ }
245
+ catch {
246
+ console.log(chalk_1.default.yellow('\n⚠️ Could not delete branch'));
247
+ }
248
+ }
249
+ return;
250
+ }
251
+ const branchName = worktree.branch;
252
+ const worktreePath = worktree.path;
215
253
  console.log();
216
254
  console.log(chalk_1.default.bold(`🧹 Cleaning up issue #${issueNumber}`));
217
255
  console.log(chalk_1.default.dim(` Branch: ${branchName}`));
@@ -230,7 +268,12 @@ async function cleanCommand(issueNumber) {
230
268
  return;
231
269
  }
232
270
  // Close terminal and VS Code windows for this worktree
233
- closeWindowsWithPath(worktreePath);
271
+ try {
272
+ closeWindowsWithPath(worktreePath);
273
+ }
274
+ catch {
275
+ // Ignore errors closing windows
276
+ }
234
277
  // Remove worktree
235
278
  if (fs.existsSync(worktreePath)) {
236
279
  const worktreeSpinner = (0, ora_1.default)('Removing worktree...').start();
@@ -242,7 +285,15 @@ async function cleanCommand(issueNumber) {
242
285
  worktreeSpinner.succeed('Worktree removed');
243
286
  }
244
287
  catch {
245
- worktreeSpinner.warn('Could not remove worktree (may already be removed)');
288
+ // If git worktree remove fails, try removing directory manually
289
+ try {
290
+ fs.rmSync(worktreePath, { recursive: true, force: true });
291
+ (0, child_process_1.execSync)('git worktree prune', { cwd: projectRoot, stdio: 'pipe' });
292
+ worktreeSpinner.succeed('Worktree removed (manually)');
293
+ }
294
+ catch {
295
+ worktreeSpinner.warn('Could not remove worktree directory');
296
+ }
246
297
  }
247
298
  }
248
299
  // Delete branch
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-issue-solver",
3
- "version": "1.6.2",
3
+ "version": "1.6.3",
4
4
  "description": "Automatically solve GitHub issues using Claude Code",
5
5
  "main": "dist/index.js",
6
6
  "bin": {