@erclx/aitk
Advanced tools
| #!/usr/bin/env bash | ||
| # Hands back the absolute path form for a write made from a linked worktree. | ||
| # | ||
| # A relative path emitted from a linked worktree resolves against that | ||
| # worktree rather than the editor root, so the terminal's path detection and | ||
| # the desktop app's link both fail silently: nothing happens on the click | ||
| # and no error appears. This computes the fact a session was asking itself | ||
| # to infer on every response and hands the answer back instead. | ||
| # | ||
| # The entrypoint branch (bare vs. `file://` link) stays prose in | ||
| # governance/rules/core/015-output.md. CLAUDE_CODE_ENTRYPOINT is not among | ||
| # the environment variables Claude Code documents as passed to a hook | ||
| # subprocess, unlike CLAUDE_PROJECT_DIR, so a hook cannot read it reliably. | ||
| # | ||
| # The worktree branch comes from the path rather than from `git rev-parse`, | ||
| # the way `tasks-index.sh` and `memory-index.sh` already derive their main | ||
| # root from a path suffix instead of the session. A git call would answer for | ||
| # whatever directory the hook's own process happens to run in, which is not | ||
| # necessarily the worktree the write came from. | ||
| # Claude Code sends a payload and closes stdin. A bare read with nothing | ||
| # feeding it blocks forever and holds the session open, so the read is | ||
| # bounded. `read` rather than `timeout cat`, which macOS does not ship. | ||
| IFS= read -r -d '' -t 2 input | ||
| [ -n "$input" ] || { | ||
| printf '%s reads a Claude Code hook payload on stdin and cannot be run by hand.\n' "${0##*/}" >&2 | ||
| exit 1 | ||
| } | ||
| tool=$(printf '%s' "$input" | jq -r '.tool_name // empty') | ||
| case "$tool" in | ||
| Write | Edit | MultiEdit) ;; | ||
| *) exit 0 ;; | ||
| esac | ||
| file_path=$(printf '%s' "$input" | jq -r '.tool_input.file_path // empty') | ||
| [ -n "$file_path" ] || exit 0 | ||
| # A path with no worktree segment is either the main worktree, where a | ||
| # relative path already resolves against the editor root, or a path this | ||
| # hook cannot place. Either way there is nothing to hand back. | ||
| case "$file_path" in | ||
| */.claude/worktrees/*) ;; | ||
| *) exit 0 ;; | ||
| esac | ||
| abs_path=$(realpath -- "$file_path" 2>/dev/null) | ||
| if [ -z "$abs_path" ]; then | ||
| jq -nc --arg msg "path-form.sh could not resolve an absolute form for $file_path from this linked worktree. Report the path per the worktree branch in the output rule instead of guessing." \ | ||
| '{hookSpecificOutput:{hookEventName:"PostToolUse",additionalContext:$msg}}' | ||
| exit 0 | ||
| fi | ||
| jq -nc --arg path "$abs_path" \ | ||
| '{hookSpecificOutput:{hookEventName:"PostToolUse",additionalContext:("This write is from a linked worktree. When reporting this path in your response, use its absolute form: " + $path)}}' | ||
| exit 0 |
| { | ||
| "name": "aitk", | ||
| "description": "Automated governance, versioning, and discovery tools for Claude Code.", | ||
| "version": "3.28.0", | ||
| "version": "3.29.0", | ||
| "author": { | ||
@@ -6,0 +6,0 @@ "name": "Eric Le", |
@@ -16,3 +16,3 @@ --- | ||
| - In the main worktree: relative from `pwd` works because `pwd` equals the editor root. | ||
| - In a linked worktree (under `.claude/worktrees/<name>/`): use absolute paths. Relative paths from worktree `pwd` would not resolve against the editor's project root. | ||
| - In a linked worktree (under `.claude/worktrees/<name>/`): use absolute paths. Relative paths from worktree `pwd` would not resolve against the editor's project root. A `PostToolUse` hook computes this form after each write and hands it back as additional context where it is installed. Prefer that form when it arrives, and fall back to computing the absolute path yourself when it does not. | ||
@@ -19,0 +19,0 @@ ## Grouping multiple files |
+1
-1
| { | ||
| "name": "@erclx/aitk", | ||
| "type": "module", | ||
| "version": "3.28.0", | ||
| "version": "3.29.0", | ||
| "description": "Infrastructure and quality tooling for developer workflows", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
@@ -38,2 +38,6 @@ { | ||
| "command": "\"$CLAUDE_PROJECT_DIR\"/.claude/hooks/memory-index.sh" | ||
| }, | ||
| { | ||
| "type": "command", | ||
| "command": "\"$CLAUDE_PROJECT_DIR\"/.claude/hooks/path-form.sh" | ||
| } | ||
@@ -40,0 +44,0 @@ ] |
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
2804705
0.1%597
0.17%33243
0.01%