From b81680037c4b68f7631dcb3b696fd96ddaa26aa1 Mon Sep 17 00:00:00 2001 From: Jakub Czajka Date: Fri, 31 Jul 2026 09:22:56 +0000 Subject: [PATCH] [paseo] Sync agent name, add daemon test and status-line hook --- .claude/hooks/status-line | 38 +++++++++++++++++++++++++++++++++++++- .claude/settings.json | 9 +++++++++ tests/paseo.scm | 22 ++++++++++++++++------ 3 files changed, 62 insertions(+), 7 deletions(-) diff --git a/.claude/hooks/status-line b/.claude/hooks/status-line index e85be77..e36628d 100755 --- a/.claude/hooks/status-line +++ b/.claude/hooks/status-line @@ -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 @@ -27,3 +27,39 @@ else [ -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 echo "$PWD" | $GUIX_BIN/grep -q '/worktrees/'; then + suffix="🌿 $CLAUDE_CODE_SESSION_ID" + if ! echo "$current_name" | $GUIX_BIN/grep -qF "$suffix"; then + "$PASEO" agent update "$agent_id" \ + --name "$current_name $suffix" >/dev/null 2>&1 + fi + else + if echo "$current_name" | $GUIX_BIN/grep -q '🌿'; then + clean_name=$(echo "$current_name" \ + | $GUIX_BIN/sed 's/ 🌿 [a-f0-9-]*$//') + "$PASEO" agent update "$agent_id" \ + --name "$clean_name" >/dev/null 2>&1 + fi + fi +fi diff --git a/.claude/settings.json b/.claude/settings.json index f9249f5..099447f 100644 --- a/.claude/settings.json +++ b/.claude/settings.json @@ -62,6 +62,15 @@ "statusMessage": "Format and build Guile file." } ] + }, + { + "matcher": "EnterWorktree|ExitWorktree", + "hooks": [ + { + "type": "command", + "command": "${CLAUDE_PROJECT_DIR}/.claude/hooks/status-line" + } + ] } ], "Stop": [ diff --git a/tests/paseo.scm b/tests/paseo.scm index e277325..98dce52 100644 --- a/tests/paseo.scm +++ b/tests/paseo.scm @@ -1,15 +1,25 @@ ;;; Copyright (c) 2026 Jakub Czajka ;;; License: GPL-3.0 or later. ;;; -;;; Paseo test cases. +;;; Paseo test cases — verifies the daemon can start under +;;; timeout(1) without crashing. (define-module (tests paseo) - #:use-module (guix gexp) - #:use-module (tests common) #:use-module (conf home paseo) + #:use-module (gnu packages base) + #:use-module (guix gexp) #:export (paseo-test-cases)) +(define %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 (paseo-test-cases marionette) - "Return a gexp with Paseo test assertion." - #~(begin - #$(assert-binary-exists "paseo: binary exists" paseo "paseo" marionette))) + "Return a gexp with Paseo test assertions." + #~(test-assert "paseo: daemon starts" + (marionette-eval '#$%timeout-body + #$marionette))) -- 2.47.3