claude-issue-solver 1.43.6 → 1.44.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/utils/helpers.d.ts +0 -6
- package/dist/utils/helpers.js +15 -50
- package/dist/utils/helpers.test.js +1 -53
- package/package.json +1 -1
package/dist/utils/helpers.d.ts
CHANGED
|
@@ -3,15 +3,9 @@ export declare function checkRequirements(): {
|
|
|
3
3
|
ok: boolean;
|
|
4
4
|
missing: string[];
|
|
5
5
|
};
|
|
6
|
-
/**
|
|
7
|
-
* Generate AppleScript for opening a script in iTerm2.
|
|
8
|
-
* Creates a new window and runs the command directly to avoid session restoration issues.
|
|
9
|
-
*/
|
|
10
|
-
export declare function generateITermOpenScript(script: string): string;
|
|
11
6
|
/**
|
|
12
7
|
* Generate AppleScript for opening a script in Terminal.app.
|
|
13
8
|
* Changes to the script's directory first so the session path matches the worktree.
|
|
14
|
-
* Sends 'n' first to dismiss any oh-my-zsh update prompts, then runs the script with bash.
|
|
15
9
|
*/
|
|
16
10
|
export declare function generateTerminalOpenScript(script: string): string;
|
|
17
11
|
export declare function openInNewTerminal(script: string): void;
|
package/dist/utils/helpers.js
CHANGED
|
@@ -35,15 +35,14 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.slugify = slugify;
|
|
37
37
|
exports.checkRequirements = checkRequirements;
|
|
38
|
-
exports.generateITermOpenScript = generateITermOpenScript;
|
|
39
38
|
exports.generateTerminalOpenScript = generateTerminalOpenScript;
|
|
40
39
|
exports.openInNewTerminal = openInNewTerminal;
|
|
41
40
|
exports.copyEnvFiles = copyEnvFiles;
|
|
42
41
|
exports.symlinkNodeModules = symlinkNodeModules;
|
|
43
42
|
const child_process_1 = require("child_process");
|
|
44
|
-
const fs = __importStar(require("fs"));
|
|
45
43
|
const path = __importStar(require("path"));
|
|
46
44
|
const os = __importStar(require("os"));
|
|
45
|
+
const fs = __importStar(require("fs"));
|
|
47
46
|
function slugify(text) {
|
|
48
47
|
// Remove common prefixes in brackets like [FAQ], [Bug], etc.
|
|
49
48
|
const withoutBrackets = text.replace(/^\[.*?\]\s*/, '');
|
|
@@ -73,30 +72,9 @@ function checkRequirements() {
|
|
|
73
72
|
}
|
|
74
73
|
return { ok: missing.length === 0, missing };
|
|
75
74
|
}
|
|
76
|
-
/**
|
|
77
|
-
* Generate AppleScript for opening a script in iTerm2.
|
|
78
|
-
* Creates a new window and runs the command directly to avoid session restoration issues.
|
|
79
|
-
*/
|
|
80
|
-
function generateITermOpenScript(script) {
|
|
81
|
-
const escapedScript = script.replace(/"/g, '\\"').replace(/'/g, '');
|
|
82
|
-
// Extract directory from script path to set as working directory
|
|
83
|
-
const scriptDir = path.dirname(script.replace(/'/g, ''));
|
|
84
|
-
const escapedDir = scriptDir.replace(/"/g, '\\"');
|
|
85
|
-
// cd to the script's directory first, so session path matches worktree
|
|
86
|
-
const bashCommand = `cd "${escapedDir}" && /bin/bash "${escapedScript}"`;
|
|
87
|
-
const escapedBashCommand = bashCommand.replace(/\\/g, '\\\\').replace(/"/g, '\\"');
|
|
88
|
-
return `
|
|
89
|
-
tell application "iTerm"
|
|
90
|
-
activate
|
|
91
|
-
-- Create a new window with a command to avoid session restoration issues
|
|
92
|
-
create window with default profile command "/bin/bash -c '${bashCommand.replace(/'/g, "'\\''")}'"
|
|
93
|
-
end tell
|
|
94
|
-
`;
|
|
95
|
-
}
|
|
96
75
|
/**
|
|
97
76
|
* Generate AppleScript for opening a script in Terminal.app.
|
|
98
77
|
* Changes to the script's directory first so the session path matches the worktree.
|
|
99
|
-
* Sends 'n' first to dismiss any oh-my-zsh update prompts, then runs the script with bash.
|
|
100
78
|
*/
|
|
101
79
|
function generateTerminalOpenScript(script) {
|
|
102
80
|
const escapedScript = script.replace(/"/g, '\\"');
|
|
@@ -104,38 +82,25 @@ function generateTerminalOpenScript(script) {
|
|
|
104
82
|
const scriptDir = path.dirname(script.replace(/'/g, ''));
|
|
105
83
|
const escapedDir = scriptDir.replace(/"/g, '\\"');
|
|
106
84
|
// cd to the script's directory first, so session path matches worktree
|
|
107
|
-
const bashCommand = `cd "${escapedDir}" && /bin/bash "${escapedScript}"`;
|
|
108
|
-
return `
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
end tell
|
|
113
|
-
`;
|
|
85
|
+
const bashCommand = `cd \\"${escapedDir}\\" && /bin/bash \\"${escapedScript}\\"`;
|
|
86
|
+
return `tell application "Terminal"
|
|
87
|
+
activate
|
|
88
|
+
do script "${bashCommand}"
|
|
89
|
+
end tell`;
|
|
114
90
|
}
|
|
115
91
|
function openInNewTerminal(script) {
|
|
116
92
|
const platform = os.platform();
|
|
117
93
|
if (platform === 'darwin') {
|
|
118
|
-
// macOS -
|
|
119
|
-
const iTermScript = generateITermOpenScript(script);
|
|
94
|
+
// macOS - use Terminal.app (always available, no session restoration issues)
|
|
120
95
|
const terminalScript = generateTerminalOpenScript(script);
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}
|
|
130
|
-
catch {
|
|
131
|
-
// Fallback to Terminal
|
|
132
|
-
try {
|
|
133
|
-
(0, child_process_1.execSync)(`osascript -e '${terminalScript}'`, { stdio: 'pipe' });
|
|
134
|
-
}
|
|
135
|
-
catch {
|
|
136
|
-
console.log('Could not open new terminal. Run manually:');
|
|
137
|
-
console.log(script);
|
|
138
|
-
}
|
|
96
|
+
// Use spawnSync with stdin to avoid shell escaping issues
|
|
97
|
+
const result = (0, child_process_1.spawnSync)('osascript', [], {
|
|
98
|
+
input: terminalScript,
|
|
99
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
100
|
+
});
|
|
101
|
+
if (result.status !== 0) {
|
|
102
|
+
console.log('Could not open new terminal. Run manually:');
|
|
103
|
+
console.log(script);
|
|
139
104
|
}
|
|
140
105
|
}
|
|
141
106
|
else if (platform === 'linux') {
|
|
@@ -22,45 +22,12 @@ const helpers_1 = require("./helpers");
|
|
|
22
22
|
(0, vitest_1.expect)((0, helpers_1.slugify)(longTitle).length).toBeLessThanOrEqual(30);
|
|
23
23
|
});
|
|
24
24
|
});
|
|
25
|
-
(0, vitest_1.describe)('generateITermOpenScript', () => {
|
|
26
|
-
(0, vitest_1.it)('should generate valid AppleScript for iTerm', () => {
|
|
27
|
-
const script = (0, helpers_1.generateITermOpenScript)('/path/to/script.sh');
|
|
28
|
-
(0, vitest_1.expect)(script).toContain('tell application "iTerm"');
|
|
29
|
-
(0, vitest_1.expect)(script).toContain('create window with default profile command');
|
|
30
|
-
});
|
|
31
|
-
(0, vitest_1.it)('should use create window with command to avoid session restoration', () => {
|
|
32
|
-
const script = (0, helpers_1.generateITermOpenScript)('/path/to/script.sh');
|
|
33
|
-
// Should use command parameter to run directly without session restoration
|
|
34
|
-
(0, vitest_1.expect)(script).toContain('create window with default profile command');
|
|
35
|
-
(0, vitest_1.expect)(script).toContain('/bin/bash -c');
|
|
36
|
-
});
|
|
37
|
-
(0, vitest_1.it)('should use /bin/bash to run the script', () => {
|
|
38
|
-
const script = (0, helpers_1.generateITermOpenScript)('/path/to/script.sh');
|
|
39
|
-
(0, vitest_1.expect)(script).toContain('/bin/bash');
|
|
40
|
-
(0, vitest_1.expect)(script).toContain('/path/to/script.sh');
|
|
41
|
-
});
|
|
42
|
-
(0, vitest_1.it)('should handle double quotes in script path without breaking AppleScript', () => {
|
|
43
|
-
const script = (0, helpers_1.generateITermOpenScript)('/path/to/"quoted"/script.sh');
|
|
44
|
-
// Should still contain the path and be valid AppleScript structure
|
|
45
|
-
(0, vitest_1.expect)(script).toContain('tell application "iTerm"');
|
|
46
|
-
(0, vitest_1.expect)(script).toContain('/bin/bash');
|
|
47
|
-
(0, vitest_1.expect)(script).toContain('quoted');
|
|
48
|
-
});
|
|
49
|
-
(0, vitest_1.it)('should handle paths with spaces', () => {
|
|
50
|
-
const script = (0, helpers_1.generateITermOpenScript)('/path/with spaces/script.sh');
|
|
51
|
-
(0, vitest_1.expect)(script).toContain('/path/with spaces/script.sh');
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
25
|
(0, vitest_1.describe)('generateTerminalOpenScript', () => {
|
|
55
26
|
(0, vitest_1.it)('should generate valid AppleScript for Terminal.app', () => {
|
|
56
27
|
const script = (0, helpers_1.generateTerminalOpenScript)('/path/to/script.sh');
|
|
57
28
|
(0, vitest_1.expect)(script).toContain('tell application "Terminal"');
|
|
58
29
|
(0, vitest_1.expect)(script).toContain('do script');
|
|
59
30
|
});
|
|
60
|
-
(0, vitest_1.it)('should send "n" to dismiss oh-my-zsh update prompts', () => {
|
|
61
|
-
const script = (0, helpers_1.generateTerminalOpenScript)('/path/to/script.sh');
|
|
62
|
-
(0, vitest_1.expect)(script).toContain('n;');
|
|
63
|
-
});
|
|
64
31
|
(0, vitest_1.it)('should use /bin/bash to run the script', () => {
|
|
65
32
|
const script = (0, helpers_1.generateTerminalOpenScript)('/path/to/script.sh');
|
|
66
33
|
(0, vitest_1.expect)(script).toContain('/bin/bash');
|
|
@@ -78,26 +45,7 @@ const helpers_1 = require("./helpers");
|
|
|
78
45
|
(0, vitest_1.expect)(script).toContain('/path/with spaces/script.sh');
|
|
79
46
|
});
|
|
80
47
|
});
|
|
81
|
-
(0, vitest_1.describe)('oh-my-zsh bypass behavior', () => {
|
|
82
|
-
(0, vitest_1.it)('iTerm script should run command directly to avoid session restoration', () => {
|
|
83
|
-
const script = (0, helpers_1.generateITermOpenScript)('/test/script.sh');
|
|
84
|
-
// Should use create window with command to avoid session restoration issues
|
|
85
|
-
(0, vitest_1.expect)(script).toContain('create window with default profile command');
|
|
86
|
-
(0, vitest_1.expect)(script).toContain('/bin/bash');
|
|
87
|
-
});
|
|
88
|
-
(0, vitest_1.it)('Terminal script should combine dismiss and command in single do script', () => {
|
|
89
|
-
const script = (0, helpers_1.generateTerminalOpenScript)('/test/script.sh');
|
|
90
|
-
// Should have "n; /bin/bash..." in a single do script call
|
|
91
|
-
(0, vitest_1.expect)(script).toMatch(/do script "n;.*\/bin\/bash/);
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
48
|
(0, vitest_1.describe)('working directory for terminal closing', () => {
|
|
95
|
-
(0, vitest_1.it)('iTerm script should cd to script directory before running', () => {
|
|
96
|
-
const script = (0, helpers_1.generateITermOpenScript)('/path/to/worktree/.claude-runner.sh');
|
|
97
|
-
// Should cd to the script's directory
|
|
98
|
-
(0, vitest_1.expect)(script).toContain('cd "/path/to/worktree"');
|
|
99
|
-
(0, vitest_1.expect)(script).toContain('/bin/bash');
|
|
100
|
-
});
|
|
101
49
|
(0, vitest_1.it)('Terminal script should cd to script directory before running', () => {
|
|
102
50
|
const script = (0, helpers_1.generateTerminalOpenScript)('/path/to/worktree/.claude-runner.sh');
|
|
103
51
|
// Should cd to the script's directory first (quotes are escaped in AppleScript)
|
|
@@ -105,7 +53,7 @@ const helpers_1 = require("./helpers");
|
|
|
105
53
|
(0, vitest_1.expect)(script).toContain('/bin/bash');
|
|
106
54
|
});
|
|
107
55
|
(0, vitest_1.it)('should handle script paths with quotes', () => {
|
|
108
|
-
const script = (0, helpers_1.
|
|
56
|
+
const script = (0, helpers_1.generateTerminalOpenScript)('/path/to/work"tree/.script.sh');
|
|
109
57
|
(0, vitest_1.expect)(script).toContain('/bin/bash');
|
|
110
58
|
// Path should be escaped
|
|
111
59
|
(0, vitest_1.expect)(script).toContain('work');
|