Skip to content

Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows

docs(extending): simplify hook-log alias body; drop brittle hash match (#2169)

Maximilian Rooscec8d934ed71
diff --git a/docs/content/extending.md b/docs/content/extending.md
index 6d46bb7fd..674f1543e 100644
--- a/docs/content/extending.md
+++ b/docs/content/extending.md
@@ -140,10 +140,16 @@ Alias names that collide with built-in step commands (`commit`, `squash`, `rebas
[aliases]
# Tail the current worktree's post-start hook named {{ name }}:
# wt step hook-log --name=server
-hook-log = '''tail -f "$(wt config state logs --format=json | jq -r --arg name "{{ name }}" '.hook_output[] | select(.branch == "{{ branch }}" and .hook_type == "post-start" and (.name == $name or (.name | startswith($name + "-")))) | .path' | head -1)"'''
+hook-log = '''
+tail -f "$(wt config state logs --format=json | jq -r --arg name "{{ name }}" '
+ .hook_output[]
+ | select(.branch == "{{ branch }}" and .hook_type == "post-start" and .name == $name)
+ | .path
+' | head -1)"
+'''
```
-The `startswith($name + "-")` branch matches the sanitized-with-hash form (`server-abc`) so the same alias works for hook names that required sanitization.
+Hook names that required sanitization (had invalid filename characters) pick up a short hash suffix on disk, e.g. `server-abc` for configured name `server`. The alias matches on the exact on-disk `name`, so pass the sanitized form when filtering those.
### Recipe: move or copy in-progress changes to a new worktree
diff --git a/skills/worktrunk/reference/extending.md b/skills/worktrunk/reference/extending.md
index a2c4b472a..72148a877 100644
--- a/skills/worktrunk/reference/extending.md
+++ b/skills/worktrunk/reference/extending.md
@@ -137,10 +137,16 @@ Alias names that collide with built-in step commands (`commit`, `squash`, `rebas
[aliases]
# Tail the current worktree's post-start hook named {{ name }}:
# wt step hook-log --name=server
-hook-log = '''tail -f "$(wt config state logs --format=json | jq -r --arg name "{{ name }}" '.hook_output[] | select(.branch == "{{ branch }}" and .hook_type == "post-start" and (.name == $name or (.name | startswith($name + "-")))) | .path' | head -1)"'''
+hook-log = '''
+tail -f "$(wt config state logs --format=json | jq -r --arg name "{{ name }}" '
+ .hook_output[]
+ | select(.branch == "{{ branch }}" and .hook_type == "post-start" and .name == $name)
+ | .path
+' | head -1)"
+'''
```
-The `startswith($name + "-")` branch matches the sanitized-with-hash form (`server-abc`) so the same alias works for hook names that required sanitization.
+Hook names that required sanitization (had invalid filename characters) pick up a short hash suffix on disk, e.g. `server-abc` for configured name `server`. The alias matches on the exact on-disk `name`, so pass the sanitized form when filtering those.
### Recipe: move or copy in-progress changes to a new worktree