greptile 2.2.6 → 2.2.8

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.
@@ -41,7 +41,7 @@ on open location theURL
41
41
  -- so we launch bash and source the runner script to keep the shell session alive
42
42
  -- after the IDE command (claude/codex/cursor) finishes.
43
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"
44
+ set cleanEnv to "unset CLAUDECODE; source " & runnerPath & " ; exec zsh"
45
45
  if termApp is "Ghostty" then
46
46
  do shell script "open -na Ghostty --args -e zsh -li -c '" & cleanEnv & "' &>/dev/null &"
47
47
  else if termApp is "kitty" then
package/health-server.js CHANGED
@@ -1,27 +1,25 @@
1
1
  #!/usr/bin/env node
2
2
  const http = require('http')
3
+ const https = require('https')
3
4
  const fs = require('fs')
4
5
  const path = require('path')
6
+ const { spawn } = require('child_process')
5
7
 
6
8
  const PORT = 4747
7
9
 
8
10
  // 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).
11
+ // Checks that package.json next to this script still exists.
12
+ // Note: we intentionally don't check `command -v greptile-fix` because
13
+ // launchd runs with a minimal PATH that doesn't include npm global bin.
11
14
  const PACKAGE_MARKER = path.join(__dirname, 'package.json')
12
15
  const SELF_CHECK_INTERVAL_MS = 30_000
16
+ const UPDATE_CHECK_INTERVAL_MS = 6 * 60 * 60 * 1000 // 6 hours
17
+ let isUpdating = false
13
18
 
14
19
  function selfCheck() {
15
20
  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
21
 
24
- if (markerGone || cliGone) {
22
+ if (markerGone) {
25
23
  console.log('Package uninstalled — cleaning up and exiting.')
26
24
  const { execSync } = require('child_process')
27
25
  const home = process.env.HOME || ''
@@ -42,6 +40,57 @@ function selfCheck() {
42
40
  }
43
41
  }
44
42
 
43
+ // Auto-update: periodically check npm registry for a newer version and install it.
44
+ function checkForUpdate() {
45
+ if (isUpdating) return
46
+ let localVersion
47
+ try {
48
+ const pkg = JSON.parse(fs.readFileSync(PACKAGE_MARKER, 'utf8'))
49
+ localVersion = pkg.version
50
+ } catch {
51
+ return // Can't read local version, skip
52
+ }
53
+
54
+ const req = https.get('https://registry.npmjs.org/greptile/latest', { timeout: 10_000 }, (res) => {
55
+ let data = ''
56
+ res.on('data', (chunk) => { data += chunk })
57
+ res.on('end', () => {
58
+ try {
59
+ const latest = JSON.parse(data)
60
+ if (latest.version && latest.version !== localVersion) {
61
+ console.log(`Update available: ${localVersion} → ${latest.version}. Installing...`)
62
+ isUpdating = true
63
+ // Resolve npm path — launchd has minimal PATH
64
+ const npmPaths = ['/opt/homebrew/bin/npm', '/usr/local/bin/npm']
65
+ let npmBin = 'npm'
66
+ for (const p of npmPaths) {
67
+ if (fs.existsSync(p)) { npmBin = p; break }
68
+ }
69
+ const child = spawn(npmBin, ['install', '-g', 'greptile@latest'], {
70
+ stdio: 'ignore',
71
+ detached: true,
72
+ })
73
+ child.unref()
74
+ child.on('close', (code) => {
75
+ isUpdating = false
76
+ if (code === 0) {
77
+ console.log(`Updated to greptile@${latest.version}`)
78
+ } else {
79
+ console.error(`Update failed with exit code ${code}`)
80
+ }
81
+ })
82
+ child.on('error', (err) => {
83
+ isUpdating = false
84
+ console.error('Update spawn error:', err.message)
85
+ })
86
+ }
87
+ } catch {}
88
+ })
89
+ })
90
+ req.on('error', () => {}) // Silently ignore network errors
91
+ req.on('timeout', () => { req.destroy() })
92
+ }
93
+
45
94
  const ALLOWED_ORIGINS = ['https://app.greptile.com', 'https://app.staging.greptile.com', 'http://localhost:3000']
46
95
 
47
96
  const server = http.createServer((req, res) => {
@@ -81,4 +130,7 @@ server.listen(PORT, '127.0.0.1', () => {
81
130
  console.log(`Greptile health server listening on http://127.0.0.1:${PORT}`)
82
131
  // Start self-check loop after server is up
83
132
  setInterval(selfCheck, SELF_CHECK_INTERVAL_MS)
133
+ // Check for updates on startup and then every 6 hours
134
+ checkForUpdate()
135
+ setInterval(checkForUpdate, UPDATE_CHECK_INTERVAL_MS)
84
136
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "greptile",
3
- "version": "2.2.6",
3
+ "version": "2.2.8",
4
4
  "description": "Bridge for Greptile code review 'Fix in Claude Code' and 'Fix in Codex' links",
5
5
  "bin": {
6
6
  "greptile-fix": "bin/greptile-fix.js"
package/postinstall.sh CHANGED
@@ -45,6 +45,8 @@ if [ -f "$PLIST_SRC" ]; then
45
45
  echo "Greptile health server installed and started."
46
46
  fi
47
47
 
48
+ echo ""
49
+ echo "✓ greptile-cli installed successfully."
48
50
  echo ""
49
51
  echo "Repo path mappings are stored in ~/.greptile/repos.json."
50
52
  echo "The first time you click 'Fix in Claude Code' for a repo,"
package/preuninstall.sh CHANGED
@@ -11,7 +11,6 @@ APP_PATH="$HOME/Applications/Greptile Fix.app"
11
11
 
12
12
  if [ -d "$APP_PATH" ]; then
13
13
  rm -rf "$APP_PATH"
14
- echo "Removed: $APP_PATH"
15
14
  fi
16
15
 
17
16
  # --- Health server LaunchAgent ---
@@ -19,5 +18,6 @@ PLIST_PATH="$HOME/Library/LaunchAgents/com.greptile.health.plist"
19
18
  if [ -f "$PLIST_PATH" ]; then
20
19
  launchctl unload "$PLIST_PATH" 2>/dev/null || true
21
20
  rm -f "$PLIST_PATH"
22
- echo "Removed Greptile health server LaunchAgent."
23
21
  fi
22
+
23
+ echo "✓ greptile-cli uninstalled successfully."