greptile 2.2.4 → 2.2.6
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/greptile-fix.applescript +24 -37
- package/health-server.js +25 -5
- package/package.json +1 -1
package/greptile-fix.applescript
CHANGED
|
@@ -14,55 +14,42 @@ on open location theURL
|
|
|
14
14
|
set runnerPath to do shell script "PATH=/opt/homebrew/bin:/usr/local/bin:$PATH greptile-fix " & quoted form of theURL & " 2>> /tmp/greptile-fix.log"
|
|
15
15
|
|
|
16
16
|
if runnerPath is not "" then
|
|
17
|
-
-- Detect terminal
|
|
17
|
+
-- Detect terminal by checking running processes via shell (no accessibility permissions needed).
|
|
18
|
+
-- Check non-default terminals first; fall back to Terminal.app.
|
|
18
19
|
set termApp to "Terminal"
|
|
19
|
-
set knownTerminals to {"iTerm2", "Ghostty", "Warp", "kitty", "WezTerm", "Alacritty", "Terminal"}
|
|
20
|
-
-- Map process names to the app name expected by "open -a"
|
|
21
|
-
-- (iTerm2's process name is "iTerm2" but the app name is "iTerm")
|
|
22
|
-
set termAppNames to {"iTerm", "Ghostty", "Warp", "kitty", "WezTerm", "Alacritty", "Terminal"}
|
|
23
20
|
try
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
set
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
-- Otherwise pick the first running terminal we recognize
|
|
38
|
-
if not foundFront then
|
|
39
|
-
repeat with i from 1 to count of knownTerminals
|
|
40
|
-
if item i of knownTerminals is in runningApps then
|
|
41
|
-
set termApp to item i of termAppNames
|
|
42
|
-
exit repeat
|
|
43
|
-
end if
|
|
44
|
-
end repeat
|
|
21
|
+
set ps to do shell script "ps -eo comm= 2>/dev/null"
|
|
22
|
+
if ps contains "/Ghostty.app/" then
|
|
23
|
+
set termApp to "Ghostty"
|
|
24
|
+
else if ps contains "/iTerm.app/" then
|
|
25
|
+
set termApp to "iTerm"
|
|
26
|
+
else if ps contains "/Warp.app/" then
|
|
27
|
+
set termApp to "Warp"
|
|
28
|
+
else if ps contains "/kitty.app/" then
|
|
29
|
+
set termApp to "kitty"
|
|
30
|
+
else if ps contains "/WezTerm.app/" then
|
|
31
|
+
set termApp to "WezTerm"
|
|
32
|
+
else if ps contains "/Alacritty.app/" then
|
|
33
|
+
set termApp to "Alacritty"
|
|
45
34
|
end if
|
|
46
35
|
end try
|
|
47
36
|
|
|
48
37
|
do shell script "echo 'Detected terminal: " & termApp & "' >> /tmp/greptile-fix.log"
|
|
49
38
|
|
|
50
39
|
-- Terminal-specific launch commands for macOS.
|
|
51
|
-
--
|
|
52
|
-
--
|
|
53
|
-
--
|
|
54
|
-
--
|
|
55
|
-
|
|
56
|
-
-- WezTerm: https://wezterm.org/cli/start.html
|
|
57
|
-
-- Alacritty: https://man.archlinux.org/man/alacritty.1
|
|
40
|
+
-- Ghostty/kitty/WezTerm/Alacritty close the window when the -e command exits,
|
|
41
|
+
-- so we launch bash and source the runner script to keep the shell session alive
|
|
42
|
+
-- after the IDE command (claude/codex/cursor) finishes.
|
|
43
|
+
-- Unset CLAUDECODE so the new session doesn't think it's nested inside an existing one.
|
|
44
|
+
set cleanEnv to "unset CLAUDECODE; source " & quoted form of runnerPath & " ; exec zsh"
|
|
58
45
|
if termApp is "Ghostty" then
|
|
59
|
-
do shell script "open -na Ghostty --args -e
|
|
46
|
+
do shell script "open -na Ghostty --args -e zsh -li -c '" & cleanEnv & "' &>/dev/null &"
|
|
60
47
|
else if termApp is "kitty" then
|
|
61
|
-
do shell script "open -na kitty --args
|
|
48
|
+
do shell script "open -na kitty --args zsh -li -c '" & cleanEnv & "' &>/dev/null &"
|
|
62
49
|
else if termApp is "WezTerm" then
|
|
63
|
-
do shell script "open -na WezTerm --args start --
|
|
50
|
+
do shell script "open -na WezTerm --args start -- zsh -li -c '" & cleanEnv & "' &>/dev/null &"
|
|
64
51
|
else if termApp is "Alacritty" then
|
|
65
|
-
do shell script "open -na Alacritty --args -e
|
|
52
|
+
do shell script "open -na Alacritty --args -e zsh -li -c '" & cleanEnv & "' &>/dev/null &"
|
|
66
53
|
else
|
|
67
54
|
-- Terminal.app, iTerm, and Warp natively execute scripts via "open -a"
|
|
68
55
|
do shell script "open -a " & quoted form of termApp & " " & quoted form of runnerPath
|
package/health-server.js
CHANGED
|
@@ -5,24 +5,44 @@ const path = require('path')
|
|
|
5
5
|
|
|
6
6
|
const PORT = 4747
|
|
7
7
|
|
|
8
|
-
// Self-destruct: if the package has been uninstalled
|
|
9
|
-
//
|
|
8
|
+
// Self-destruct: if the package has been uninstalled, clean up and exit.
|
|
9
|
+
// Checks two signals: 1) package.json next to this script is gone, or
|
|
10
|
+
// 2) greptile-fix is no longer in PATH (handles npm global uninstall).
|
|
10
11
|
const PACKAGE_MARKER = path.join(__dirname, 'package.json')
|
|
11
12
|
const SELF_CHECK_INTERVAL_MS = 30_000
|
|
12
13
|
|
|
13
14
|
function selfCheck() {
|
|
14
|
-
|
|
15
|
+
const markerGone = !fs.existsSync(PACKAGE_MARKER)
|
|
16
|
+
let cliGone = false
|
|
17
|
+
try {
|
|
18
|
+
const { execSync } = require('child_process')
|
|
19
|
+
execSync('command -v greptile-fix', { stdio: 'ignore' })
|
|
20
|
+
} catch {
|
|
21
|
+
cliGone = true
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (markerGone || cliGone) {
|
|
15
25
|
console.log('Package uninstalled — cleaning up and exiting.')
|
|
16
|
-
const
|
|
26
|
+
const { execSync } = require('child_process')
|
|
27
|
+
const home = process.env.HOME || ''
|
|
28
|
+
const plistPath = path.join(home, 'Library/LaunchAgents/com.greptile.health.plist')
|
|
29
|
+
// Remove .app bundle and plist file
|
|
30
|
+
try {
|
|
31
|
+
fs.rmSync(path.join(home, 'Applications/Greptile Fix.app'), { recursive: true, force: true })
|
|
32
|
+
} catch {}
|
|
17
33
|
try {
|
|
18
34
|
fs.unlinkSync(plistPath)
|
|
19
35
|
} catch {}
|
|
20
36
|
server.close()
|
|
37
|
+
// Remove the launchd job by label so KeepAlive won't restart us
|
|
38
|
+
try {
|
|
39
|
+
execSync('launchctl remove com.greptile.health 2>/dev/null')
|
|
40
|
+
} catch {}
|
|
21
41
|
process.exit(0)
|
|
22
42
|
}
|
|
23
43
|
}
|
|
24
44
|
|
|
25
|
-
const ALLOWED_ORIGINS = ['https://app.greptile.com', 'https://staging.greptile.com', 'http://localhost:3000']
|
|
45
|
+
const ALLOWED_ORIGINS = ['https://app.greptile.com', 'https://app.staging.greptile.com', 'http://localhost:3000']
|
|
26
46
|
|
|
27
47
|
const server = http.createServer((req, res) => {
|
|
28
48
|
const origin = req.headers.origin || ''
|