greptile 2.2.1 → 2.2.3

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.
Files changed (2) hide show
  1. package/health-server.js +27 -1
  2. package/package.json +1 -1
package/health-server.js CHANGED
@@ -1,10 +1,34 @@
1
1
  #!/usr/bin/env node
2
2
  const http = require('http')
3
+ const fs = require('fs')
4
+ const path = require('path')
3
5
 
4
6
  const PORT = 4747
5
7
 
8
+ // Self-destruct: if the package has been uninstalled (package.json gone),
9
+ // clean up the LaunchAgent and exit so the health server doesn't linger.
10
+ const PACKAGE_MARKER = path.join(__dirname, 'package.json')
11
+ const SELF_CHECK_INTERVAL_MS = 30_000
12
+
13
+ function selfCheck() {
14
+ if (!fs.existsSync(PACKAGE_MARKER)) {
15
+ console.log('Package uninstalled — cleaning up and exiting.')
16
+ const plistPath = path.join(process.env.HOME || '', 'Library/LaunchAgents/com.greptile.health.plist')
17
+ try {
18
+ fs.unlinkSync(plistPath)
19
+ } catch {}
20
+ server.close()
21
+ process.exit(0)
22
+ }
23
+ }
24
+
25
+ const ALLOWED_ORIGINS = ['https://app.greptile.com', 'https://staging.greptile.com', 'http://localhost:3000']
26
+
6
27
  const server = http.createServer((req, res) => {
7
- res.setHeader('Access-Control-Allow-Origin', '*')
28
+ const origin = req.headers.origin || ''
29
+ if (ALLOWED_ORIGINS.includes(origin)) {
30
+ res.setHeader('Access-Control-Allow-Origin', origin)
31
+ }
8
32
  res.setHeader('Access-Control-Allow-Methods', 'GET, OPTIONS')
9
33
  res.setHeader('Access-Control-Allow-Headers', 'Content-Type')
10
34
 
@@ -35,4 +59,6 @@ server.on('error', (err) => {
35
59
 
36
60
  server.listen(PORT, '127.0.0.1', () => {
37
61
  console.log(`Greptile health server listening on http://127.0.0.1:${PORT}`)
62
+ // Start self-check loop after server is up
63
+ setInterval(selfCheck, SELF_CHECK_INTERVAL_MS)
38
64
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "greptile",
3
- "version": "2.2.1",
3
+ "version": "2.2.3",
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"