]> git.ekhem.eu.org Git - guix.git/commitdiff
[home] Sync agent name, add daemon test and status-line hook.
authorJakub Czajka <jakub@ekhem.eu.org>
Fri, 31 Jul 2026 09:22:56 +0000 (09:22 +0000)
committerJakub Czajka <jakub@ekhem.eu.org>
Sun, 22 Nov 2026 10:42:39 +0000 (10:42 +0000)
.claude/hooks/status-line
.claude/settings.json
tests/vps-home.scm

index e85be774dc7cfb5ccf95af8737328826874d08df..2eabd9dcab0fa0773ef94ae1566a320f8a8ce9d2 100755 (executable)
@@ -3,7 +3,7 @@
 # License: GPL-3.0 or later.
 #
 # status-line — Display the current branch or worktree in the
-# Claude Code status bar.
+# Claude Code status bar and sync the paseo agent name.
 
 # Pre-flight: critical environment variables.
 if [ -z "$GUIX_BIN" ]; then
@@ -19,11 +19,53 @@ fi
 
 GIT_BIN="$HOME/.guix-profile/bin/git"
 
+# Determine worktree state and compute an abbreviated name
+# (first 7 characters of the session ID, like a git short hash).
+wt_abbrev=""
 if echo "$PWD" | $GUIX_BIN/grep -q '/worktrees/'; then
-    echo "🌿 $CLAUDE_CODE_SESSION_ID"
+    wt_abbrev=$(echo "$CLAUDE_CODE_SESSION_ID" | $GUIX_BIN/cut -c1-7)
+    echo "🌿 $wt_abbrev"
 else
     if [ -x "$GIT_BIN" ]; then
         branch=$($GIT_BIN -C "$PWD" branch --show-current 2>/dev/null)
         [ -n "$branch" ] && echo "🌿 $branch"
     fi
 fi
+
+# Sync paseo agent name with current worktree state.
+PASEO="$HOME/.guix-home/profile/bin/paseo"
+
+# Find the agent ID: prefer PASEO_AGENT_ID from env, fall back to
+# finding the running agent via paseo ls.
+agent_id="${PASEO_AGENT_ID}"
+if [ -z "$agent_id" ] && [ -x "$PASEO" ]; then
+    agent_id=$("$PASEO" ls --json 2>/dev/null \
+        | $GUIX_BIN/grep -B10 '"status": "running"' \
+        | $GUIX_BIN/grep '"id"' \
+        | $GUIX_BIN/sed 's/.*"id": "\([^"]*\)".*/\1/' \
+        | $GUIX_BIN/head -1)
+fi
+
+if [ -n "$agent_id" ] && [ -x "$PASEO" ]; then
+    current_name=$("$PASEO" inspect "$agent_id" --json 2>/dev/null \
+        | $GUIX_BIN/grep '"Name"' \
+        | $GUIX_BIN/sed \
+            's/.*"Name"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/')
+
+    if [ -n "$wt_abbrev" ]; then
+        # In a worktree: prepend the abbreviation as prefix.
+        prefix="🌿 $wt_abbrev"
+        if ! echo "$current_name" | $GUIX_BIN/grep -qF "$prefix"; then
+            "$PASEO" agent update "$agent_id" \
+                --name "$prefix $current_name" >/dev/null 2>&1
+        fi
+    else
+        # Outside a worktree: strip any worktree prefix.
+        if echo "$current_name" | $GUIX_BIN/grep -q '🌿'; then
+            clean_name=$(echo "$current_name" \
+                | $GUIX_BIN/sed 's/^🌿 [a-f0-9]\{1,8\} //')
+            "$PASEO" agent update "$agent_id" \
+                --name "$clean_name" >/dev/null 2>&1
+        fi
+    fi
+fi
index f9249f50e5de002ad952d67dc8d95633884e0632..099447f71f02a0b4218529f4e14e2b5e7f6928d4 100644 (file)
             "statusMessage": "Format and build Guile file."
           }
         ]
+      },
+      {
+        "matcher": "EnterWorktree|ExitWorktree",
+        "hooks": [
+          {
+            "type": "command",
+            "command": "${CLAUDE_PROJECT_DIR}/.claude/hooks/status-line"
+          }
+        ]
       }
     ],
     "Stop": [
index 7fcc3de3cb85ca32c189aadb1808804d3a238506..d877a2ccafde191bededeb1b8b0beef5e8c7cdff 100644 (file)
                          (format (current-error-port) "~a: ~s~%"
                                  #$label result) #f)))))
 
+(define %paseo-timeout-body
+  (let ((bin (file-append paseo "/bin/paseo"))
+        (timeout (file-append coreutils "/bin/timeout")))
+    `(let* ((st (system* ,timeout
+                         "5"
+                         ,bin
+                         "daemon"
+                         "start"
+                         "--foreground"))
+            (rc (status:exit-val st)))
+       (= rc 124))))
+
 (define (vps-home-test-cases marionette)
   #~(begin
       (marionette-eval '#$%home-prelude
@@ -81,4 +93,7 @@
                                     #$marionette))
       (test-assert "home: .guile exists"
                    (marionette-eval '(file-exists? "/home/dak/.guile")
+                                    #$marionette))
+      (test-assert "paseo: daemon starts"
+                   (marionette-eval '#$%paseo-timeout-body
                                     #$marionette))))