claude-issue-solver 1.4.0 → 1.5.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.
@@ -0,0 +1 @@
1
+ export declare function goCommand(issueNumber?: number): Promise<void>;
@@ -0,0 +1,149 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.goCommand = goCommand;
7
+ const chalk_1 = __importDefault(require("chalk"));
8
+ const inquirer_1 = __importDefault(require("inquirer"));
9
+ const child_process_1 = require("child_process");
10
+ const git_1 = require("../utils/git");
11
+ function getIssueWorktrees() {
12
+ const projectRoot = (0, git_1.getProjectRoot)();
13
+ const projectName = (0, git_1.getProjectName)();
14
+ const worktrees = [];
15
+ // Get all worktrees from git
16
+ const output = (0, git_1.exec)('git worktree list --porcelain', projectRoot);
17
+ if (!output)
18
+ return worktrees;
19
+ const lines = output.split('\n');
20
+ let currentPath = '';
21
+ let currentBranch = '';
22
+ for (const line of lines) {
23
+ if (line.startsWith('worktree ')) {
24
+ currentPath = line.replace('worktree ', '');
25
+ }
26
+ else if (line.startsWith('branch refs/heads/')) {
27
+ currentBranch = line.replace('branch refs/heads/', '');
28
+ // Check if this is an issue branch
29
+ const match = currentBranch.match(/^issue-(\d+)-/);
30
+ if (match && currentPath.includes(`${projectName}-issue-`)) {
31
+ worktrees.push({
32
+ path: currentPath,
33
+ branch: currentBranch,
34
+ issueNumber: match[1],
35
+ });
36
+ }
37
+ }
38
+ }
39
+ return worktrees;
40
+ }
41
+ function getPRForBranch(branch) {
42
+ try {
43
+ const output = (0, child_process_1.execSync)(`gh pr list --head "${branch}" --json url --jq '.[0].url'`, {
44
+ encoding: 'utf-8',
45
+ stdio: ['pipe', 'pipe', 'pipe'],
46
+ }).trim();
47
+ return output || null;
48
+ }
49
+ catch {
50
+ return null;
51
+ }
52
+ }
53
+ async function goCommand(issueNumber) {
54
+ const worktrees = getIssueWorktrees();
55
+ if (worktrees.length === 0) {
56
+ console.log(chalk_1.default.yellow('\nNo issue worktrees found.'));
57
+ console.log(chalk_1.default.dim('Run `claude-issue <number>` to start working on an issue.'));
58
+ return;
59
+ }
60
+ let selectedWorktree;
61
+ if (issueNumber) {
62
+ // Find specific worktree
63
+ const found = worktrees.find((wt) => wt.issueNumber === String(issueNumber));
64
+ if (!found) {
65
+ console.log(chalk_1.default.red(`\nāŒ No worktree found for issue #${issueNumber}`));
66
+ console.log(chalk_1.default.dim('\nAvailable worktrees:'));
67
+ for (const wt of worktrees) {
68
+ console.log(chalk_1.default.dim(` #${wt.issueNumber}: ${wt.path}`));
69
+ }
70
+ return;
71
+ }
72
+ selectedWorktree = found;
73
+ }
74
+ else {
75
+ // Show selection
76
+ console.log(chalk_1.default.bold('\nšŸ“‚ Issue worktrees:\n'));
77
+ const choices = worktrees.map((wt) => ({
78
+ name: `#${wt.issueNumber}\t${wt.branch}`,
79
+ value: wt,
80
+ }));
81
+ choices.push({
82
+ name: chalk_1.default.dim('Cancel'),
83
+ value: null,
84
+ });
85
+ const { selected } = await inquirer_1.default.prompt([
86
+ {
87
+ type: 'list',
88
+ name: 'selected',
89
+ message: 'Select a worktree to open:',
90
+ choices,
91
+ pageSize: 15,
92
+ },
93
+ ]);
94
+ if (!selected) {
95
+ console.log(chalk_1.default.dim('Cancelled.'));
96
+ return;
97
+ }
98
+ selectedWorktree = selected;
99
+ }
100
+ // Get PR info
101
+ const prUrl = getPRForBranch(selectedWorktree.branch);
102
+ console.log();
103
+ console.log(chalk_1.default.bold(`šŸ“‚ Issue #${selectedWorktree.issueNumber}`));
104
+ console.log(chalk_1.default.dim(` Path: ${selectedWorktree.path}`));
105
+ console.log(chalk_1.default.dim(` Branch: ${selectedWorktree.branch}`));
106
+ if (prUrl) {
107
+ console.log(chalk_1.default.cyan(` PR: ${prUrl}`));
108
+ }
109
+ console.log();
110
+ // Ask what to do
111
+ const actions = [
112
+ { name: 'šŸ“ Open in VS Code', value: 'vscode' },
113
+ { name: 'šŸ“‚ Open in Finder', value: 'finder' },
114
+ { name: 'šŸ’» Print cd command', value: 'cd' },
115
+ ];
116
+ if (prUrl) {
117
+ actions.unshift({ name: 'šŸ”— Open PR in browser', value: 'pr' });
118
+ }
119
+ actions.push({ name: chalk_1.default.dim('Cancel'), value: 'cancel' });
120
+ const { action } = await inquirer_1.default.prompt([
121
+ {
122
+ type: 'list',
123
+ name: 'action',
124
+ message: 'What would you like to do?',
125
+ choices: actions,
126
+ },
127
+ ]);
128
+ switch (action) {
129
+ case 'pr':
130
+ console.log(chalk_1.default.dim(`\nOpening PR in browser...`));
131
+ (0, child_process_1.execSync)(`open "${prUrl}"`, { stdio: 'pipe' });
132
+ break;
133
+ case 'vscode':
134
+ console.log(chalk_1.default.dim(`\nOpening in VS Code...`));
135
+ (0, child_process_1.execSync)(`code "${selectedWorktree.path}"`, { stdio: 'pipe' });
136
+ break;
137
+ case 'finder':
138
+ console.log(chalk_1.default.dim(`\nOpening in Finder...`));
139
+ (0, child_process_1.execSync)(`open "${selectedWorktree.path}"`, { stdio: 'pipe' });
140
+ break;
141
+ case 'cd':
142
+ console.log(chalk_1.default.dim(`\nRun this command:\n`));
143
+ console.log(chalk_1.default.cyan(`cd "${selectedWorktree.path}"`));
144
+ break;
145
+ case 'cancel':
146
+ console.log(chalk_1.default.dim('Cancelled.'));
147
+ break;
148
+ }
149
+ }
package/dist/index.js CHANGED
@@ -13,6 +13,7 @@ const solve_1 = require("./commands/solve");
13
13
  const pr_1 = require("./commands/pr");
14
14
  const clean_1 = require("./commands/clean");
15
15
  const select_1 = require("./commands/select");
16
+ const go_1 = require("./commands/go");
16
17
  // eslint-disable-next-line @typescript-eslint/no-var-requires
17
18
  const packageJson = require('../package.json');
18
19
  const program = new commander_1.Command();
@@ -93,4 +94,16 @@ program
93
94
  await (0, clean_1.cleanAllCommand)();
94
95
  }
95
96
  });
97
+ // Go command - navigate to worktree and open PR
98
+ program
99
+ .command('go [issue]')
100
+ .description('Navigate to an issue worktree, open VS Code, or view PR')
101
+ .action(async (issue) => {
102
+ const issueNumber = issue ? parseInt(issue, 10) : undefined;
103
+ if (issue && isNaN(issueNumber)) {
104
+ console.log(chalk_1.default.red(`āŒ Invalid issue number: ${issue}`));
105
+ process.exit(1);
106
+ }
107
+ await (0, go_1.goCommand)(issueNumber);
108
+ });
96
109
  program.parse();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-issue-solver",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
4
4
  "description": "Automatically solve GitHub issues using Claude Code",
5
5
  "main": "dist/index.js",
6
6
  "bin": {