gsd-init 1.0.14 → 1.0.15

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gsd-init",
3
- "version": "1.0.14",
3
+ "version": "1.0.15",
4
4
  "description": "Set up GSD observer/worker tmux system in a project",
5
5
  "bin": {
6
6
  "gsd-init": "bin/gsd.js"
@@ -1,9 +1,51 @@
1
1
  #!/usr/bin/env bash
2
- WORKER_SESSION="${GSD_WORKER_SESSION:-gsd-worker}"
3
- OBSERVER_SESSION="${GSD_OBSERVER_SESSION:-gsd-observer}"
4
- echo "[gsd-observer] Tearing down sessions..."
2
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
3
+ PROJECT_DIR="$(cd "${SCRIPT_DIR}/../.." && pwd)"
4
+ PROJECT_NAME="$(basename "$PROJECT_DIR")"
5
+
6
+ WORKER_SESSION="${GSD_WORKER_SESSION:-gsd-worker-${PROJECT_NAME}}"
7
+ OBSERVER_SESSION="${GSD_OBSERVER_SESSION:-gsd-observer-${PROJECT_NAME}}"
8
+
9
+ echo "[gsd] Tearing down sessions..."
5
10
  tmux kill-session -t "$WORKER_SESSION" 2>/dev/null && echo " Killed: $WORKER_SESSION" || echo " Not running: $WORKER_SESSION"
6
11
  tmux kill-session -t "$OBSERVER_SESSION" 2>/dev/null && echo " Killed: $OBSERVER_SESSION" || echo " Not running: $OBSERVER_SESSION"
7
- echo "[gsd-observer] Cleaning up temp files..."
12
+
13
+ echo "[gsd] Cleaning up temp files..."
8
14
  rm -f /tmp/gsd-event-*.json /tmp/gsd-response-*.json /tmp/gsd-last-event-phase
15
+
16
+ echo "[gsd] Closing Terminal windows..."
17
+ osascript <<EOF 2>/dev/null || true
18
+ tell application "Terminal"
19
+ set wins to every window
20
+ repeat with w in wins
21
+ try
22
+ set cmd to custom title of w
23
+ on error
24
+ set cmd to ""
25
+ end try
26
+ if cmd contains "$WORKER_SESSION" or cmd contains "$OBSERVER_SESSION" then
27
+ close w
28
+ end if
29
+ end repeat
30
+ end tell
31
+ EOF
32
+
33
+ # Also close by matching the tmux attach command in the tab
34
+ osascript <<EOF 2>/dev/null || true
35
+ tell application "Terminal"
36
+ set wins to every window
37
+ repeat with w in wins
38
+ repeat with t in every tab of w
39
+ set p to processes of t
40
+ repeat with proc in p
41
+ if proc contains "$WORKER_SESSION" or proc contains "$OBSERVER_SESSION" then
42
+ close w
43
+ exit repeat
44
+ end if
45
+ end repeat
46
+ end repeat
47
+ end repeat
48
+ end tell
49
+ EOF
50
+
9
51
  echo " Done."