greptile 2.2.7 → 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.
package/health-server.js CHANGED
@@ -1,7 +1,9 @@
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
 
@@ -11,6 +13,8 @@ const PORT = 4747
11
13
  // launchd runs with a minimal PATH that doesn't include npm global bin.
12
14
  const PACKAGE_MARKER = path.join(__dirname, 'package.json')
13
15
  const SELF_CHECK_INTERVAL_MS = 30_000
16
+ const UPDATE_CHECK_INTERVAL_MS = 6 * 60 * 60 * 1000 // 6 hours
17
+ let isUpdating = false
14
18
 
15
19
  function selfCheck() {
16
20
  const markerGone = !fs.existsSync(PACKAGE_MARKER)
@@ -36,6 +40,57 @@ function selfCheck() {
36
40
  }
37
41
  }
38
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
+
39
94
  const ALLOWED_ORIGINS = ['https://app.greptile.com', 'https://app.staging.greptile.com', 'http://localhost:3000']
40
95
 
41
96
  const server = http.createServer((req, res) => {
@@ -75,4 +130,7 @@ server.listen(PORT, '127.0.0.1', () => {
75
130
  console.log(`Greptile health server listening on http://127.0.0.1:${PORT}`)
76
131
  // Start self-check loop after server is up
77
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)
78
136
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "greptile",
3
- "version": "2.2.7",
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."