From fb15bc528c97324be4b85fab84ddc7487817d28f Mon Sep 17 00:00:00 2001 From: Logan Gagne Date: Sun, 21 Jun 2026 15:48:41 -0400 Subject: [PATCH] fix(session): replace Skill(rename) with direct JSONL rename script MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Skill(rename) is a UI command that cannot be invoked programmatically — the harness rejects it with "rename is a UI command, not a skill." Replace it with a session-local script that renames the session without user input. - Add scripts/rename-session: finds the active session by CWD match in ~/.claude/sessions/.json, appends a custom-title record to the session JSONL, and patches the live PID file for immediate UI update - Update session-start step 4: call rename-session with the base name already built in step 3 (- or wip-) - Update session-issue step 6: call rename-session with the - base name already built in step 5 - Bump version 4.4.0 → 4.5.0 Co-Authored-By: Claude Sonnet 4.6 --- .../session/.claude-plugin/plugin.json | 2 +- plugins-claude/session/scripts/rename-session | 54 +++++++++++++++++++ .../session/skills/session-issue/SKILL.md | 12 +++-- .../session/skills/session-start/SKILL.md | 12 +++-- .../session/.claude-plugin/plugin.json | 2 +- 5 files changed, 72 insertions(+), 10 deletions(-) create mode 100755 plugins-claude/session/scripts/rename-session diff --git a/plugins-claude/session/.claude-plugin/plugin.json b/plugins-claude/session/.claude-plugin/plugin.json index fda70ba..5c64db7 100644 --- a/plugins-claude/session/.claude-plugin/plugin.json +++ b/plugins-claude/session/.claude-plugin/plugin.json @@ -1,6 +1,6 @@ { "name": "session", - "version": "4.4.0", + "version": "4.5.0", "description": "Work session management — issue-driven and freeform doors sharing an explore-then-plan spine, with multi-agent orchestration and a review-gated PR finalizer", "author": { "name": "Logan Gagne" diff --git a/plugins-claude/session/scripts/rename-session b/plugins-claude/session/scripts/rename-session new file mode 100755 index 0000000..128d113 --- /dev/null +++ b/plugins-claude/session/scripts/rename-session @@ -0,0 +1,54 @@ +#!/usr/bin/env bash +# Rename the active Claude Code session for the current CWD. +# Usage: rename-session +set -euo pipefail + +NEW_NAME="${1:-}" +if [[ -z "$NEW_NAME" ]]; then + echo "Usage: rename-session " >&2 + exit 1 +fi + +CWD="$(pwd)" +SESSIONS_DIR="$HOME/.claude/sessions" + +# Find the session file for this CWD +SESSION_FILE="" +for f in "$SESSIONS_DIR"/*.json; do + [[ -f "$f" ]] || continue + if jq -e --arg cwd "$CWD" '.cwd == $cwd' "$f" >/dev/null 2>&1; then + SESSION_FILE="$f" + break + fi +done + +if [[ -z "$SESSION_FILE" ]]; then + echo "rename-session: no active session found for cwd=$CWD" >&2 + exit 1 +fi + +SESSION_ID=$(jq -r '.sessionId' "$SESSION_FILE") +if [[ -z "$SESSION_ID" || "$SESSION_ID" == "null" ]]; then + echo "rename-session: could not read sessionId from $SESSION_FILE" >&2 + exit 1 +fi + +# Encode CWD: replace every / with - (leading / becomes leading -) +ENCODED_CWD=$(echo "$CWD" | sed 's|/|-|g') +JSONL_PATH="$HOME/.claude/projects/${ENCODED_CWD}/${SESSION_ID}.jsonl" + +if [[ ! -f "$JSONL_PATH" ]]; then + echo "rename-session: session JSONL not found: $JSONL_PATH" >&2 + exit 1 +fi + +# Append custom-title record — this is what /rename writes +jq -nc --arg n "$NEW_NAME" --arg s "$SESSION_ID" \ + '{"type":"custom-title","customTitle":$n,"sessionId":$s}' >> "$JSONL_PATH" + +# Patch the live PID file so the UI updates immediately +TEMP=$(mktemp) +jq --arg n "$NEW_NAME" '.name = $n' "$SESSION_FILE" > "$TEMP" +rm -f "$SESSION_FILE" && mv "$TEMP" "$SESSION_FILE" + +echo "Session renamed to: $NEW_NAME" diff --git a/plugins-claude/session/skills/session-issue/SKILL.md b/plugins-claude/session/skills/session-issue/SKILL.md index 51456e1..a9a4790 100644 --- a/plugins-claude/session/skills/session-issue/SKILL.md +++ b/plugins-claude/session/skills/session-issue/SKILL.md @@ -87,10 +87,14 @@ begin-work spine (explore → plan). To start from your own description instead, number — the linkage lives in the PR's `Closes #N`, which is what auto-closes the issue on merge. -6. **Rename this session** — invoke the built-in rename via the `Skill` tool - (`skill: "rename"`, no args) so the session title reflects the issue being - worked on. The rename auto-generates a short descriptive name from the current - conversation context — call it now, while the issue title and summary are fresh. +6. **Rename this session** — call the rename script using the base name from + step 5 (the `-` you just built): + + ```bash + bash ${CLAUDE_PLUGIN_ROOT}/scripts/rename-session "" + ``` + + Call this now, while the issue title and summary are fresh. ### Phase 3 — Run the spine diff --git a/plugins-claude/session/skills/session-start/SKILL.md b/plugins-claude/session/skills/session-start/SKILL.md index 85884ef..1f63464 100644 --- a/plugins-claude/session/skills/session-start/SKILL.md +++ b/plugins-claude/session/skills/session-start/SKILL.md @@ -53,10 +53,14 @@ issues instead, use `/session:session-issue`; for a read-only status view, use - **Freeform** → base name `wip-` (3-5 word slug from the description). No issue linked; the description is the context. -4. **Rename this session** — invoke the built-in rename via the `Skill` tool - (`skill: "rename"`, no args). Call it regardless of whether this is new work - or a continuation — the description from Phase 0 is in context and the rename - auto-generates a short descriptive name from it. +4. **Rename this session** — call the rename script using the base name from + step 3 (the `-` or `wip-` you just built): + + ```bash + bash ${CLAUDE_PLUGIN_ROOT}/scripts/rename-session "" + ``` + + Call this regardless of whether it is new work or a continuation. ### Phase 2 — Run the spine diff --git a/plugins-copilot/session/.claude-plugin/plugin.json b/plugins-copilot/session/.claude-plugin/plugin.json index fda70ba..5c64db7 100644 --- a/plugins-copilot/session/.claude-plugin/plugin.json +++ b/plugins-copilot/session/.claude-plugin/plugin.json @@ -1,6 +1,6 @@ { "name": "session", - "version": "4.4.0", + "version": "4.5.0", "description": "Work session management — issue-driven and freeform doors sharing an explore-then-plan spine, with multi-agent orchestration and a review-gated PR finalizer", "author": { "name": "Logan Gagne"